Comparison of ABAP and Java

From Wikipedia, the free encyclopedia

This article is part of the
Programming Language Comparison
series.
General Comparison
Basic Syntax
Basic Instructions
Arrays
Associative arrays
String Operations
String Functions
Object-oriented programming
Database access

Evaluation strategy
List of "hello world" programs

Comparison of ALGOL 68 and C++
Compatibility of C and C++
Comparison of C and Pascal
Comparison of C++ and Java
Comparison of C# and Java
Comparison of C# and Visual Basic .NET
Comparison of ABAP and Java
This box: view  talk  edit

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.

Contents

[edit] Language

[edit] Syntax

While Java's syntax is based on C and C++, the syntax of ABAP is not based on any previous language (or better get many syntax element from COBOL). 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.[1]

Parameters in method calls are given the specified order in Java, while the parameter names usually have to be given in ABAP (Named parameters). 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.

[edit] Example ("Hello World")

[edit] ABAP

PROGRAM TEST.
WRITE 'Hello World'.

[edit] Java

// Hello.java
public class Hello{
  public static void main(String [] args){
    System.out.println("Hello World");
  }
}

[edit] Data types

Both languages support the idea of primitive types. 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.[2]

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,[3] which makes these definitions available across different applications.

[edit] 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.

[edit] 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 into byte code. This code is interpreted by the platform-specific Java 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 via SAPgui or a web browser (BSP, WebDynpro). Therefore, ABAP applications can be used on any client for which a SAPGui client or a web browser is available.


[edit] History

ABAP is much older than Java. While Java was released by Sun Microsystems in 1995,[4] ABAP was created by SAP in the 1980s as the report language for its business application SAP 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, like SAP R/3 or SAP ERP. SAP's newest platform solution NetWeaver supports both ABAP 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 as network computing, web applications, or business 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.

[edit] See also

[edit] References

  1. ^ Whitespace in ABAP and Java
  2. ^ Comparison of data types in Java and ABAP
  3. ^ The ABAP Dictionary on help.sap.com
  4. ^ Jon Byous, Java technology: The early years. Sun Developer Network, no date [ca. 1998]. Retrieved April 22, 2005.

[edit] External links