- Comparison of ABAP and Java
This is a comparison of the
ABAP with the Java programming language. As two modern object oriented, garbage-collected programming languages, there are many conceptual similarities. However, the two languages with completely different histories also have many differences. This page documents the strong general similarities of the languages and points out those areas where the languages differ. Both languages were designed carefully, and if one language has a feature another lacks it is the result of a conscious design decision. Thus, the reader is advised to avoid the temptation to 'keep score,' and instead think about why the designers made each decision.Language
Syntax
While Java's syntax is based on C and
C++ , the syntax of ABAP is not based entirely on a previous language, but has some syntax elements in common withCOBOL ).For example, each statement ends with a semicolon (;) in Java, while ABAP uses a dot (.). Character strings are surrounded by double quotes in Java (") and single quotes (') in ABAP.
Comments are indicated by // or /* in Java and by * or " in ABAP. Whitespace is usually ignored in Java, while it can make a difference in ABAP. [ [http://www.abap2java.com/Whitespace Whitespace in ABAP and Java] ]Parameters in method calls are given the specified order in Java, while the parameter names usually have to be given in ABAP (
Named parameter s). Java supports one or no returning parameters of a method, and any number of importing parameters, while ABAP supports also several exporting or changing parameters.Both languages do not support
operator overloading as well.For many of the operators in Java (+, -, =), ABAP offers built-in functional keywords (ADD, SUBTRACT, MOVE).Furthermore, both ABAP and Java do not allow
pointer arithmetic, by which certain addresses in memory can be explicitly be accessed in languages like C, which are considered unsafe by some language designers.
= Example ("Hello World") =ABAP
PROGRAM TEST.WRITE 'Hello World'.Java
Data types
Both languages support the idea of
primitive type s. ABAP has more primitive types than Java, for example a special built-in floating point data type called PACKED or P, or the character type NUMC that can only contain numeric characters.In contrast to ABAP, Java has a built-in boolean type, while ABAP programmers usually use a character type with the length 1 for this. [ [http://www.abap2java.com/Data_type Comparison of data types in Java and ABAP] ]Strings are supported by both languages.
ABAP allows the programmers to create self-defined composite data types, which are called structures.Since ABAP release 4.5, self-defined data types can also be defined in the so-called ABAP dictionary, [ [http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm The ABAP Dictionary on help.sap.com] ] which makes these definitions available across different applications.
Object handling
Both languages are object oriented. Java was object oriented from the beginning, while object oriented concepts were embedded into the ABAP language with release 4.6. Both languages use garbage collection as a means of reclaiming memory resources, rather than formal de-allocation of memory.
Platform independence
Java Code can run independently on a client or centrally on a server. Java code is not compiled into
machine code , like many other languages including ABAP, but intobyte code . This code is interpreted by the platform-specificJava Virtual Machine (JVM), which translates the byte code into the machine code of the platform. Thus, Java can run on any platform for which such a JVM is available.ABAP code usually does not run directly on a client, but on an
application server . Clients usually connect to the server viaSAPgui or aweb browser (BSP ,WebDynpro ). Therefore, ABAP applications can be used on any client for which a SAPGui client or a web browser is available.History
ABAP is much older than Java. While Java was released by
Sun Microsystems in 1995, [Jon Byous, [http://java.sun.com/features/1998/05/birthday.html "Java technology: The early years"] . Sun Developer Network, no date [ca. 1998] . RetrievedApril 22 ,2005 .] ABAP was created by SAP in the 1980s as the report language for its business applicationSAP R/2 . Until today, ABAP is mainly used inside SAP as well as by SAP customers and consultants, to develop, modify, and extend SAP applications, likeSAP R/3 orSAP ERP . SAP's newest platform solutionNetWeaver supports bothABAP and Java. Java, on the other hand, was never intended to be used inside a certain company or for a certain product only, but focused on a broader market from the beginning. It is now widely used in many different programming areas such asnetwork computing ,web application s, orbusiness software . All the concepts that ABAP supported since the first release are still supported and all the keywords are still valid, which is one reason why ABAP has many more keywords than Java.See also
*
Comparison of Java and C++
*Comparison of the Java and .Net platforms References
External links
* [http://java.sun.com/docs/books/jls/ Java Language Specification (Sun)]
* [http://help.sap.com SAP Help Portal]
* [http://www.sdn.sap.com/irj/sdn/developerareas/abap ABAP] in the [http://www.sdn.sap.com SAP Developer Network]
* [http://www.abap2java.com ABAP2Java.com - Online Dictionary and Translation between ABAP and Java]
Wikimedia Foundation. 2010.