What is Java? Java is a programming language which was devised within Sun Microsystems in the mid-1990s (most notably by James Gosling, an appropriately-bearded genius who, although the language as we know it today is the collective work of dozens, if not hundreds of people, is regarded as Java's creator).
The motivations behind Java are many and varied. Had it been "just another computer language" it would never have taken off - after all, the world already had C, C++, BASIC, Ada, COBOL, FORTRAN, Smalltalk and any number of others. Instead, it pushed the boundaries of programming languages in a number of ways.
Although object-oriented (OO) languages had been around (in the form of Smalltalk et al) for donkey's years, Java brought object orientation to the masses. Although C++ had been a valiant attempt to bring OO to the ever-popular C, it was always a bit of a nasty bolt-on kludge, whereas Java was inherently object-oriented from the ground up. It was no accident that the syntax of Java, although more extensive than C++, resembled C/C++ sufficiently to make it reasonably straightforward for a C++ developer to migrate his skills into the Java world.
Although C, with its foundations in the Unix world, has been inherently capable of working at a very low level with networks, Java's creators took note of the fact that the Internet was clearly going to be huge. IP networking, in particular, was going to rule the world and made the language's networking abilities a much more high-level concept. Although you can fart about with low-level sockets, if you wish, you can also give Java a simple URL and say: "Go use that bit of code over there" in next to no code. In a single swipe, distributed code re-use was a reality - a massive leap forward when compared to languages of the past.
The third key aspect of Java is that when you write a Java program and compile it, you're not actually compiling it in the true sense of the word. Traditionally, compilation means that you take some high-level code, run it through a compiler and end up with a program that will execute only on a single type of CPU, running a specific operating system. Compile a program on an Intel machine running Windows and you'll get a program that'll only run on another Intel machine running Windows. Okay, you can get cross-compilers that allow you to (say) tell the compiler to output code for a Mac running MacOS 9 even though it's on a Windows-based PC, but the rule still applies - the resulting code will run only on a Mac with MacOS 9.
With Java, the finished product is actually somewhere between the high-level code and the architecture-specific machine code; the form is termed "bytecode". In order to run a Java program, you need to first install a "Java virtual machine" (JVM) on whatever computer you want to run it on. The JVM takes the bytecode and converts it, on the fly, into machine-specific instructions that are then run on the computer's processor. This means that any compiled Java program can run on any machine equipped with a JVM, regardless of its processor or operating system, a massive potential bonus for software developers.
Java's good points
The main benefits to Java, then, are:
• It's a language that is reasonably easy to learn (and indeed, it's used as the first teaching language in many universities). It's easy for C and C++ developers, in particular, to pick up Java. • It's a write once, run anywhere kind of language - a Java program will run on any JVM-equipped computer (which these days means anything from a pocket computer to an IBM mainframe). • Unlike certain proprietary systems (Delphi or VB, for instance) the language is open and in most cases you can pick up a compiler (and even a natty GUI-based development environment) for free. • It provides immense potential for code re-use, which in turn brings the potential for very rapid application development. • Since its inception in 1996, peripheral developments have taken place to ensure it has kept up with, for example, database integration and XML integration, so it's still a modern language.
Java's bad points
The only real downside with Java is its performance. When Sun first touted Java as a product, it went hand-in-hand with the JavaStation - a diskless workstation that Sun hoped would lead the migration of the world toward diskless, "thin client" computing. Although the first JavaStations performed poorly, this wasn't perceived as a problem because the intention was always to produce a Java-specific microprocessor that would massively enhance the performance of the language.
This processor never quite made it off the drawing board, though, which means that to this day Java is still an interpreted language - that is, when you run a program, the JVM has to take the bytecode and expend a wad of processor and memory converting it into the machine code that the host machine can run. There have been valiant attempts to optimise this conversion process - most notably using the Just-In-Time, or JIT compiler, which instead of compiling the whole program at once, predicatively converts lumps of code just before they're likely to be needed. Regardless of the optimisation attempts that have been made, though, Java code is generally much slower than a natively-compiled equivalent.
Java programs can also have big memory footprints - particularly when you consider that to run a program, the JVM has to be in memory as well. A quick check on the binaries directory of the latest Sun JVM for Windows reveals that there's over 7MB of stuff in there - and although this isn't all in RAM at once, it's an overhead that you can do without in the average computer. Even Sun's internal Java guys have raised performance and memory hunger as huge issues - have a look at this link for the evidence.
Java is an immensely powerful language and is absolutely certain to play a key role in the future of corporate computing. In these days when people, like IBM, talk of plonking a JVM on every computer in the enterprise and using the entire building's computing power as a single distributed processor, Java is, and will always be, the only candidate for the language in which the business applications will be written.
Even without this move to "amorphous blob computing" (did we just invent a new term there?) Java is hugely attractive for software vendors, as they only have to write and compile their applications once and they'll run on pretty well any platform.
For now, though, Java's use in centralised, multi-user systems where performance counts is questionable. Experience has shown that although it'll work just great if you can throw CPU cycles and masses of RAM at it, if you're developing (say) a customer-facing Web application, you'd probably shy away from Java on the average mid-range Web application.
Find your next job with techworld jobs