Personal Information Portal - a.k.a Blog
May 12, 2000
by Sergey Kucherov
Why there are not enough Java programmers? Right now there are huge demands in this expertise on the market. Employers willing to pay top price for right skills and still they do not have enough. The reason for that is quite obvious. Java language is only five years old. This time is not enough to expect a big number of experienced programmers.
By the way, it is not a big deal to find experienced programmers and teach them new tricks. It is why you can find a lot of ads where the Java or C++ skills demanded as equal. Is that so?
The purpose of the paper is to suggest an idea to use the experience of Object Pascal developers on mission-critical Java projects. Sometimes such experience will be much more useful than strong C/C++ skills.
In 1980 Bjarne Stroustrup develops a set of languages -- collectively referred to as "C With Classes". Later, in 1986 Stroustrup have published "The C++ Programming Language" (2). The syntax and ideology of new language was based on the legacy of C (1).
In 1986 Apple released Object Pascal language for Macintosh. The Pascal (3) language naturally adapted the object-oriented paradigm by adding object as a new type. Later, in 1989 Borland introduced Turbo Pascal 5.5 (4) -- first Object-oriented version of Turbo Pascal. In 1995 Borland released new integrated development environment -- Delphi (5). Borland have made further changes in Object Pascal language and used it a base programming language for Delphi.
Java (6) has been introduced by SUN Microsystems in 1995 as a pure object-oriented language. It inherited syntax of C++ (7) but with completely new ideology The ideological differences between Java and C++ is the major confusion for C and C++ developers who start working with Java after having several years of C++ development.
C++ inherited C source code structure, where you have to declare all functions in each source file where you going to call these functions. To simplify the process C and C++ introduce "header files" which contains functions and classes declarations. Then you have to use "#include" statement to combine text from header file and the original source code. The compiler does not care have you used #include statement or just type declaration in source file.
// #include "module.h"
class MyClass {
public:
double Fahrenheit();
private:
double C;
}
// implementation of methods
int MyClass::Fahrenheit() {
return C*9/5 + 32;
}
// #include "module.h"
class MyClass {
public:
double Fahrenheit();
private:
double C;
}
// using the instance of MyClass
...
F = Temp->Fahrenheit();
Unlike C and C++, a Java program has modular structure. You can combine Java classes to a Package. To use classes from particular package you have to import them:
// use all classes from the package
import module.*;
// using the instance of MyClass
...
F = Temp.Fahrenheit();
This is pretty familiar for an Object Pascal programmer. In Pascal language you can declare classes in units and use these classes in other programs and units:
uses module;
...
F := Temp.Fahrenheit;
Java language syntax has been inherited from C++. All major operators and keywords are much more familiar for C/C++ programmer than anybody else. However, it is not so easy for a programmer to stop "think" on C++ and start "think" on Java. Unlike an Object Pascal developer C++ programmer still too close to physical memory terms and an assembler code.
Java does not support operator overloading. It is quite obvious for an Object Pascal developer. The disturbing practice of operator overloading will confuse a C++ developer who just started to work with Java.
The same story about multiple inheritance. Both Java and Object Pascal support interfaces but ones will not allow inheriting from several classes. Experienced C++ developers will have some design problems when they face a situation where they used to implement multiple inheritance.
There is no Boolean type in C++. As result you may use any integer value as a Boolean one considering 0 as False and
all non-zero values as True. There much more discipline in Java and Object Pascal languages. You must use Boolean
expressions in conditions:if ((x++) != 0) {}
Java is a pure object-oriented language. There are no stand-alone procedures and functions; there are no constants and no global variables. There are no pointers, structures and no inline assembler code. Both Object Pascal and C++ have all of these legacy instruments available for programmers. However, in C++ those instruments are much often in use than in Object Pascal.
There is no need in pointer arithmetic in Object Pascal. Most of operations with strings and arrays were implemented on the language level. In Java there are a lot of system classes to support strings and arrays. For example, this is how you to deal with arrays in C++:
double data[10];
double* size = data + 10;
double* current = data;
while (current < size) {
doSomethingWith(*current++);
}
You cannot do the same thing in Java, but you do not have to. Use index to refer to an array element:
double[] data = new double[10];
int size = data.length;
int current = 0;
while (current < size) {
doSomethingWith( data[current++] );
}
The same easy way to deal with arrays we have in Pascal:
var
data: array[0..10] of double;
current: integer;
begin
for current := 0 to High(data) do begin
doSomethingWith( data[current] );
end;
end;
Java is platform-independent language. There are Java virtual machines (VM) for most of existing platforms and operating systems. The VM concept enables programmers to separate program logic from processor-specific optimization tasks.
This concept is very familiar for Pascal programmers. There are tools to manipulate with physical memory and assembler code, but it is not necessary to use it. The Pascal machine provides developer with enough freedom to create efficient programs.
Like it's predecessor C, the C++ language remains strongly oriented to particular platform and operating system. Working with one platform for a long time makes a programmer "oriented" to the particular development style. Because there are no common virtual C++ machine the C++ language oriented to real machines. There are way to develop a platform-independent code on C++, however it will be rather multi-platform code:
void I_WaitVBL(int count)
{
#ifdef SGI
sginap(1);
#else
#ifdef SUN
sleep(0);
#else
usleep (count * (1000000/70) );
#endif
#endif
}
[1]
Brian W. Kernighan, Dennis M. Ritchie.
The C Programming Language: ANSI C Version.
Prentice Hall. 1988. ISBN: 0131103628
(*)
[2]
Bjarne Stroustrup.
The C++ Programming Language.
Addison Wesley Longman, Inc. 1999. ISBN: 0201700735
(*)
[3]
Kathleen Jensen, Nikalus Wirth.
Pascal User Manual and Report: ISO Pascal Standard.
Springer-Verlag New York, Inc. 1991. ISBN: 0387976493
(*)
[4]
Ben R. Ezzell.
Object-Oriented Programming in Turbo Pascal 5.5
Addison Wesley Longman, Inc. 1990. ISBN: 0201523752
(*)
[5]
Steve Teixeira.
Delphi 5 Developer's Guide
Macmillan USA Publishing. 1999. ISBN: 0672317818
(*)
[6]
Ken Arnold, James Gosling.
The Java Programming Language
Addison Wesley Longman, Inc. 1997. ISBN: 0201310066
(*)
[7]
Mike C. Daconta.
Java 2 and Javascript for C and C++ Programmers with Cdrom
Wiley, John & Sons, Inc. 1998. ISBN: 0471327190
(*)