Welcome to Java Foundations! Java is purported, by its designers, to be a "simple" programming language. While reasonable arguments can be made that illustrate Java's simplicity in comparison to a language like C++, developers coming from languages such as the xBASE derivatives, Visual Basic or PowerBuilder, will probably not agree that Java is simple at all. To fully exploit the power of Java, you need to understand and apply the principles of object-oriented analysis, design and programming. You need to learn the nearly 150 classes that comprise the core Java class libraries. You need to have at least a basic understanding of distributed software component models such as CORBA and COM/OLE/ACTIVEX. To develop network and Internet applications you need to understand client/server principles, sockets, URLs, etc. In short, regardless of what some publishers may imply, Java is not a programming language for "dummies" or "idiots". Nor will the average programmer be more than marginally proficient in Java after 21 days of experience.
The Java programming language is a capable, fully object-oriented programming language that is perhaps better suited for developing large-scale, complex applications than the simple applets for which it has gained its reputation. The promise of Java is that skilled, diligent programmers will be able to develop such applications more quickly, more easily and at less cost than they can develop equivalent programs in other languages.
The articles that I'll be writing for this column will address fundamental concepts that new Java programmers may not have been exposed to previously. Many of the articles will explore issues related to object-oriented programming. Other articles will concentrate on elements of the Java language or on classes included in the Java libraries. This month, I take a look at the underlying technologies that are lumped into this thing called "Java" and encourage you to consider the technologies independently when considering the appropriateness of Java for you and/or your company.
Java is comprised of three, essentially independent, technologies. These are: the Java programming language, the Java class libraries and the Java virtual machine. None of these technologies are radically new. The fact that they are all bundled together and promoted under the name Java is more of a marketing decision than a technological one.
The term "Java" is a trademark of Sun Microsystems, Inc. Sun has made detailed specifications of the Java language and of the Java virtual machine publicly available to establish Java as an "open" platform. Using the specifications, other companies can independently develop implementations of the language, class libraries and virtual machine that they can then sell without owing royalties to Sun. If the independently developed versions of the technologies pass a set of compatibility tests, Sun will allow the other companies to label their products as "Java compatible." Sun has reserved the term "Java" for use on the versions of the technologies it develops internally.
To understand how these technologies are related, let's look at how a Java program is created. The source code of a Java program, as for most compiled languages, is stored in one or more text files that contain the step-by-step instructions which are executed when the program is run. The source files, each of which usually defines a single Java class, are named with the name of the class they define followed by the extension .java. Each source file is individually submitted to the Java compiler for compilation. If the compiler doesn't find any errors in the source file, it produces a .class file that corresponds to the name of the Java class it contains.
Unlike the machine-specific object files that are produced by most compilers, the Java .class files do not contain any platform-specific code. The .class files contain platform-independent "bytecodes" which are essentially a form of machine code designed for the Java virtual machine.
In current implementations, the Java virtual machine is a platform-dependent software program that, at runtime, converts the platform-independent bytecodes into the machine-specific instructions required for the Java program to run.
So, the thing that makes the Java programming language portable is the fact that it is compiled to the platform-independent bytecodes required by the virtual machine. Consequently, if compilers for other languages were designed to compile them to the same platform-independent bytecodes, then the other languages would be just as portable as Java. In fact, several projects are underway to allow other languages, such as Ada, to be compiled to the bytecode format. Sun even indicates, in its Java Virtual Machine Specification, that it will consider "extensions to the Java Virtual Machine to provide better support for other languages."
The primary disadvantage of compiling Java programs to bytecodes is the performance penalty, incurred during the execution of the program, which results from having to convert the Java program bytecodes to the platform-specific instructions of the host machine. To eliminate this disadvantage, several companies are working on native compilers for Java that produce platform-specific executables.
As you can see, different companies have different plans for Java. Sun's primary goal is to insure that Java programs will run successfully, without recompilation, on any platform which has the Java virtual machine. However, Sun is not being altruistic. Sun has introduced the JavaOS operating system and the JavaChip chipsets, which are intended to eliminate the need for other operating systems or hardware to run Java programs. Sun recently introduced the JavaStation network computer; a diskless device that is capable of downloading and running Java programs. For Sun, Java is a way to release the stranglehold that Microsoft has on developers so that Sun can sell more hardware.
Needless to say, Microsoft has responded very aggressively. Microsoft is purportedly developing a native-code compiler for Java that produces faster, Windows-specific executables. It has also developed Windows-specific class libraries that it will ship with its development tools.
So, how do you evaluate the appropriateness of Java for your development needs? The Java programming language is a good object-oriented programming language. In addition to full support of the object-oriented paradigm, it provides automatic memory management, garbage collection, safe arrays, multithreading and language-level support for namespaces and exception handling. These features alone make the language worthy of consideration.
If you are developing Internet applets, or applications that need to run on heterogeneous networks, then you'll probably want to stick with the pure Java libraries. If, however, you are developing programs that are geared towards Windows machines, you may very well benefit from the Microsoft-provided class libraries and native executables. It comes down to the fact that you should pick the tool that best helps you balance the conflicting demands of software quality, implementation time-frames and development costs.
About the Author
Mark Robinson is the president/CEO of Cyberian Foundations, a software development/consulting firm that specializes in developing object-oriented business applications. His clients include Xerox, IBM, Sealy and numerous small businesses. He can be reached at firstname.lastname@example.org