Java: The Language of the Future

// Yes, this will run if you compile it

import javax.swing.JOptionPane;

class LanguageOfTheFuture
{
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null, "If Java is truly the " +
“\"Language of the future\" like it's worshippers claim, we'll” +
all be speaking in code soon enough.”, "Java", JOptionPane.INFORMATION_MESSAGE);

System.exit(0);
}
}

Of course, I still prefer civilized conversation with my friends.

For those of you who don't know what I'm talking about, Java has nothing to do with coffee. It's a programming language created in 1991 by James Gosling (yes, he is Canadian) of Sun Microsystems. The original project name was Oak, but the release name was Java.

So what's so beautiful about this language that leads programmers to believe it's the "Language to end all languages"? Let's start with a crash course on the fundamentals of the Java language.

Sun Microsystems implemented the first public release of Java in 1995. The Java language is derived (to an extent) from the C/C++ language. The common goal of the Java language was to provide a more simplified language than C++ that was object-orientied, would allow one file to be viewed on multiple operating systems, and would have easy-to-use built-in server-side functionality. One of Java's biggest advantages is the ability for cross-platform support. That is to say, I could create a file in the Eclipse Software Development Kit (SDK), compile the program to an executable Java Archive (JAR) file, send that JAR file to another computer with another Operating System (OS) on it, and run the program without any errors. This cannot be done with a .exe from Windows, .app from Mac, or a Linux executable (which doesn't have an extension). These executable formats are native to their OS. A JAR file can be run on any OS (Windows, Mac, Linux, or Solaris) that the Java Runtime Environment (JRE) is present on. Unlike an executable JAR file, the JRE is native to the OS you're running. You must download and install the JRE for your OS before you can execute a JAR file.


Java has three different "types." Java Standard Edition (SE), Java Enterprise Edition (EE), and Java Mobile Edition (ME).

Another huge advantage to Java is server-side functionality and simplicity. Java SE supports server functionality, but Java EE enhances this functionality a great deal. I could take that same application I just compiled and, instead of making it an executable JAR file, I could compile it to an Applet and upload it to a web server. You could then create a web page that would implement that Java Applet and, there you have it, you've just put your application on the internet for viewing anywhere in the world using any browser that supports Java.

Java was also designed to be highly portable. What you may not realize is how often you use Java applications. Your cell phone, your PDA, your MP3 player, your cars MP3/CD player, and yes, the new iPhone. Most of the applications running on your mobile devices are probably programmed with Java ME.

Another big advantage to the Java language is... it's FREE! Everybody loves free, right? The JRE is free, the Java SDK is free, and you can always find a free compiler. The Java language was designed to be Open Source; the code shared freely for learning purposes and better development.

Let's walk through the creation of a simple Java stand-alone application. I go to www.Eclipse.org and download the editor/compiler for my system: Mac OS X. After installing, I run Eclipse and create a new project. Let's just use the simple program I wrote above. I plop that into a .java file that I've created in my project and save it. I compile my program and run it. It seems to work fine, so now I want to send the program to one of my buddies for them to check out. Can I send the file I just created when I compiled the program? No! In Java, when you compile you do not make an executable. You make a .class file, which can only be viewed by people with the Java SDK. The SDK is a fairly large download, and unless you're developing Java applications, there's no use for it, so the average person won't have it. When I compiled the application, all I created was some byte code. Byte code is interpretted by JRE and converted into machine code to run the application on the OS you're currently running on... that's why they have platform specific JREs. But still, my .class is byte code, but the JRE can't run it without the SDK to help it. If I want to make an executable I have do one more step. I must "Export" my project from Eclipse. Using Eclipse, this process is far more difficult than it should be, but it works out in the end. Eclipse will then build a JAR file which can be executed on any computer, any operating system, that is running the JRE.

Still... the end user must have the JRE.

Sure, Java makes pretty GUIs. And the language, in most cases, is a heck of a lot more clean and pretty than C++ (minus formatting). But that's a hassle... it takes me longer to compile, and I can't guarantee you will be able to view the file immedietly after you recieve it. And the JRE is no small file! It's not a "quick download."

C++ may be an older language, but it is NOT a dead language, so quit saying that! C++ has features that Java decided to drop because they were too confusing, or Java just didn't want to handle them. (Pointers CAN be useful, people. They're not always a headache once you figure them out.) C++ still communicates with hardware better than Java. C++ does formatting of output WAY better than Java. I don't know why Java made formatting such a headache when they were stealing the language from C++. They simplified so many things, but formatting they unsimplified! It was simple in C++...

I like the idea of passing one file around to four different OSs. I also like the idea of sending an executable JAR file through email so Gmail doesn't gripe about me sending an "executable file" (refering to a .exe). C may be dead, but C++ is still alive and well. Java has a lot of nice things, don't get me wrong. In general, I like Java better than C++. But C++ is still a more powerful language. The code and final application of Java are far prettier than C++.

Still... in the words of Joel Whitehouse, "Yah, Java has a better syntactical design. But gosh darn it. I like that I can compile a 3k executable in C++!"

Still... as my Java teacher says frequently, "No, it's not magic... it's just Java."