Java Language Background

Java Toasters?

The JAVA books claim that the original developers at SUN (a team led by James Gosling) were frustrated C++ programmers trying to develop software for electronic devices like intelligent toasters and microwave ovens. They decided that C++ and C were too hard to use, which is very true, and set out to create a more device independent way to program. Unfortunately, being C++ programmers at heart, the language they developed is still very much oriented to developers with a C++ background and rather arcane for us normal geeks. It was called "Oak" in it's original form but that name conflicted with another programming language. When the Web appeared on the Internet, the developers realized that, with a little tweaking, the device independence of the language would work for the environment of the Web where many different computer types are trying to access things transparently. They named the updated language "Java". I suspect that the war between Netscape and Microsoft for browser market actually made Java into a success. Netscape jumped on it quickly as a way to add slick new capabilities to Navigator and stay "out front". Interest snowballed from there.

NetRexx

Fortunately, if you don't like the C++ style of syntax used in Java, Mike Cowlishaw from IBM has devised another language you can use to create Java programs. It is based on the Rexx language he created and is called NetRexx. Rexx was designed to be very easy to learn and use and NetRexx carries forward much of those same principles. Unfortunately, since much of a Java program's code consists of calls to other Java code, you still need to understand and read Java to program in NetRexx and the learning curve is steep. Once you get over that, it may be easier and faster to program in NetRexx. Mike originally wrote a Rexx program that translated the NetRexx syntax into Java code. Then he rewrote the Rexx translator code in NetRexx code and compiled it into Java bytecode. That means that the NetRexx translator runs on any platform that runs Java. We will compare NetRexx code to straight Java code later when we get to the nut-n-bolts of coding Java programs. Note that the NetRexx translator/compiler calls the Java compiler to compile NetRexx code into Java bytecode by default, but it has a "-keep" option which will save the generated Java source code if desired. Other reasons for considering NetRexx: The syntax is better if you have a mainframe Rexx background and I have found it very helpful in learning Java to translate textbook examples from Java to NetRexx or vice-versa.

C/C++ Problems

You can ignore this part if you have no experience with C or C++or don't care! What were the problems with C/C++ which Java was trying to fix? The biggest problem is "pointers" or passing data structures by way of addresses. This left the usage and interpretation of the passed structure up to someone who may not have designed it and who might do unexpected things to it which cause the program to puke. In Java, data is tightly linked with the code originally associated with it and, though it can be passed, nothing can be done to it that the original author did not allow (in theory). Another problem with C/C++ is that you have to allocate memory from a pool when you need it and then you have to remember to put it back when you are done with it. If you forget to do that properly, especially in code which has loops, you can cause the program to quickly run out of memory and fail unpredictably. Program users love it when they are left staring at their computer wondering where their data they just spent an hour entering went when the computer froze up. Java is supposed to be a little better because it automatically allocates memory and frees it when it is no longer being used (in theory). I won't go into any more details on this stuff, because it is only of historical interest as far as I am concerned and I want to get into the language quickly, as I suspect you also do.

The Java Advantage

So what is so slick about Java?
(1) Java is said to be "robust": in other words, easy to write stable programs. I have no idea how true that is personally, so I am reserving judgement.
(2) Java is designed to run on any type of computer system. Now that I can get my teeth into! As a programmer, I hate the idea that my code will only run on one specific type of system, and probably not for very long before it is too obsolete to maintain.
(3) Java is supposed to be network aware. I guess that means that you can access a file or object on a remote system over a network as easily as a local item (easier if you are writing an applet!). It sounds good anyway.
(4) Java is designed to allow the program code to run on a different machine than the one it resides on. A good idea, if it really works, because it is a major hassle to distribute, install, configure, and maintain software on lots of systems. So far this only seems to apply to applets though. My question: So where is the customized individual profile info stored for Java then? I suspect you still would have to think long and hard about that question!

Java Security?

Security is supposed to be a big deal for Java programming, but that seems to apply mainly to applets downloaded over the Internet and is sort of a pre-emptive anti-virus scheme. I will postpone discussing any details until we talk about Web browsers and sandboxes. On with the show: this course is intended to be brief and cut as much of the fluff as it can so you can get to the real programming stuff as quick as possible!