OOhh ... It's Java!Last week we began to take a look at object-oriented concepts on our way to understanding how a language such as Java might benefit the computational scientist. Before we can know how Java can help anyone, though, we have to know something about Java. So, welcome to our Java primer. Java, naturally, contains all of the object-oriented (OO) features that were discussed in last week's article (although in truth, inheritance is a somewhat different animal in Java than it is in C++), but it also has a lot of goodies that its OO brethren can't match. One such enhancement is the compile-once-run-anywhere nature of Java. As the name implies, this means that Java code compiled on my Sun workstation should have no problem running on your PC. Practically, this means that all the worries traditionally associated with porting code from one computer platform to another are now taken off of the programmer's shoulder. Of course, at some level there has to be consideration for the specific platform in question. However, rather than force a different compile for each machine, Java code runs on the Java Virtual Machine (JVM). The JVM interacts with compiled Java code the same on all machines, but it interacts differently with different machines. Therefore, once the JVM is installed on a machine, any Java code compiled on any machine should be able to run. Another important feature of Java is automatic memory management. This seem quite nifty to those of us who have spent much time in a language that uses dynamic memory allocation, such as C and C++. As anyone in this category can tell you, memory problems can cause some outlandish behavior from your code, and they can be nearly impossible to track at times. In Java, though, memory management is done automatically. This means you don't have to allocate space for a buffer, and you don't have to free it. This means that things like out-of-bounds errors are greatly reduced, and large core files could be a thing of the past! The area where Java is quite unlike many other languages is the maturity of its existing standard libraries. There are classes for everything from manipulating strings to drawing pictures, and much more. These classes make the job of the developer much easier, as he can grab one that is close to what he wants and then extend it to get the desired behavior. To see what is currently available, you can visit Sun's Java website at http://java.sun.com. If it all sounds like wine and roses, don't be duped. Learning to code effectively in Java is no mean task, especially if
The copyright of the article OOhh ... It's Java! in Scientific Computing is owned by Adam Hughes. Permission to republish OOhh ... It's Java! in print or online must be granted by the author in writing.
Go To Page: 1 2 Articles in this Topic Discussions in this Topic |