Title: Java Characteristics
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER

Java Characteristics

1. Java is an open-source project. The Sun corporation created Java in the beginning. Oracle bought Sun, so Oracle now is the keeper of the Java open-source project. Oracle has made a heavy investment in using Java in the Oracle database world.
2. Java is portable. The same Java code can run on all platforms supporting java. We give such code the name 100% pure java. It is possible to write non-portable java. But in general java is a lot more portable than other languages such as C. To make your Java programs run on all of the different architectures (i.e. Windows, Macs, Linux, Unix, etc.), a Java Virtual Machine module(JVM) is written for each architecture that we want to run Java on. Note that the JVM for Windows is different than the JVM for a Mac. However, the top level interface to your program provided by the JVM to your program is the same for all architectures.
3. Java can run in a browser as an Applet. In order for this to work, the browser needs to include a JVM to execute the applet code. My Whiteboard that I will use in this class is an Applet. Applets were the big splash when Java first came out. However, today we are more interested in Java for Android application development, Web site development and other similar applications. Some of you have heard about security issues with Java. It turns out that the Applet capability has had some security holes in recent years. The security problems seem to be isolated to Applets which is not as important today as it used to be. The Java developers have been addressing these issues.
4. Execution Environment is protected (Java Doesn't Allow Error Prone Things)- The Java Virtual machine does not allow you to directly access memory through pointers. Breathe a sigh of relief to all of you C programmers that have crashed your application by writing into memory that didn't belong to you, or trashed the memory chain by freeing up a bad memory pointer.

5. Java provides some very powerful libraries - You can do a lot with a small amount of code because of the power in the java libraries. You can find ready made libraries for GUI, Email, Image manipulation, XML parsing, accessing databases, etc.
6. J2EE (Server Side Java) - There is a lot of momentum today associated with using Java on Servers. Java Server Pages, Java Servlets are all hot areas today in the Non-Microsoft world. For example Blackboard is created using a J2EE architecture. Microsoft's competing platform to J2EE is the ".NET" architecture.
7. Java is big in the Android O.S.- Java is the normal language used on the Android OS for application development. You basically have a Linux platform with an Android Java development environment on top.
8. Everything is a Class - Well almost everything anyway. It takes some learning, but object oriented programming can be good to you once you get used to it. I used to have a negative attitude about Object Oriented programming, but once you get over the hump it's worth the effort.
9. Layers of Abstraction - At the lowest layer of code types we have Machine Code & and Assembly Language. The next layer up contains traditional computer languages which work at a higher level than Machine Code/and Assembly Language such as Fortran, Cobol, C, Pascal, C++. These languages are easier for the user, but in the end they generate machine code. Most of these languages are optimized for speed and do not waste time trying to prevent programmer errors.

Java does not attempt to be the world's fastest language. On the other hand, Java uses interpreted machine instructions which implement higher level operations than Machine Code/Assembly language. Also this interpreted Java machine code is the same on all processors and operating systems. The Java interpreted code also has built in protections to halt operations when the programmer has created erroneous logic. C# and the new .NET architecture aligns itself very closely with the Java philosophy.
10. Java Tools - Like traditional computer languages, Java requires a Compiler and Editor. Unlike traditional languages which implement CPU machine code directly, Java requires an Interpreter to execute the interpreted machine instructions. This interpreter goes by the name JVM (Java Virtual Machine).
11. Error Types - In general, the sooner an error is identified, the easier it is to fix it. The book identifies 3 kinds of errors:
  - compile-time errors - In the process of converting Java code to interpreted machine instructions, the compiler can report errors found. Errors caught by the compiler are the cheapest, quickest and easiest to fix. Give the compiler opportunities to find errors.
  - run-time errors - When your program is executing, Java has built in checks which must be satisfied, or else the Interpreter halts the program with a run-time exception which typically reports all known error information
  - logical errors - In this case the Java compiler and interpreter are OK with the programmer's effort. However, the wrong result is created because the programmer used bad logic.
12. When would Java be a bad choice? -In real-time systems where it is important to execute in some small amount of time like say 4 milli-seconds, it would not be a good idea to use Java. Java does a lot of good things for you for programs where humans are involved, because humans don't notice small delays. In a language like C or C++, you can allocate memory but you are resonsible for freeing it up. Failure to do so will result in bad things. In a language like Java, you don't have to free up memory that gets allocated. Periodically, Java will determine that it is short on memory and it goes out and collects any unused memory ... this is called Garbage collection. Even though Garbage collection is relatively quick, it is a disaster for programs that deal with small time windows like 4 milli-seconds.

Last Modified: June 2, 2014 4:08 PM