Java Fundamentals

Java is by far the most popular programming language in the world. It runs servers for websites, on mobile and smart phones and embedded devices. Chances are that you have several instances of Java ready to run in wallet in your credit and debit cards. There’s no battery but when a card is put into a reader, that power kicks it into life.

The name Java applies to both the programming language and the platform for running Java programs. Java source code is compiled to Java bytecode, a process that is called managed code. This is portable across all operating systems and is loaded and executed by the Java Virtual Machine (JVM). If you aren’t a developer and just want to run Java code then you need the JRE (Java Runtime Environment) installed. If you wish to develop Java applications then you need the Java Software Development Kit (JDK) which has the Java Compiler, debugger and other tools. There are other JDKs as well developed by IBM, Red Hat and even Oracle itself.

The Java platform splits into four different areas with SE (Standard Edition) being the one that most developers learn. Then there is EE (Enterprise Edition), an extension of SE with added APIs used in application servers, including the Java web pages (JSP). At the low end, ME (Micro-Edition) is used in low cost feature phones and was very popular before smart phones appeared. Finally there is Java Card that lets Java applications run on smart cards and SIM cards.

The year 2013 did not start well for Java. A 0-day exploit had been discovered in Java SE 7 (mad some versions of Java 4-7) in early January and the US Federal Government advised everyone who had Java available in their browser to remove it. The reach of the bug meant that potentially 850 million computers were at risk. Apple also moved to disable the Java plugin on Macs. It wasn’t enabled by default but upgrading to the latest Mac version with it already installed put users at risk.

Java SE 7 was launched at the end of July 2011 and by March 2013 there had been 17 releases with a total of 140 fixes. According to Wikipedia, the previous version Java SE 6 had 43 updates between May 2007 and March 2013 and tackled almost 250 bug fixes as well as functionality enhancements and changes needed for the underlying operating systems.

As if that wasn’t bad enough, Oracle took a pounding in the courts in its battle with Google over the Java APIs. Google had written its own open source JVM called Dalvik. This is low level code that executes Java on Android mobiles and was developed in a “clean room” with code that is compatible with Java’s APIs. A “clean room” is a way of developing code that does the same as existing code and proving that it wasn’t copied.

Oracle, which owns copyrights and patents on Java, claimed that Dalvik infringed its intellectual property and demanded payment. Their loss of this case means that software developers are free to write code that does the same function or specification as of any methods in the Java API. If an API is published as a standard why should developers be penalized for writing code that uses it? Although Android’s Java is not quite the same as the Oracle published Java, it’s near enough that you can program Android in Java.

The big news for Java is the impending release of Java SE 8 in about six months’ time. Project Coin, which was to determine the small language changes that would be added to JDK 7, ran from February to March 2009 and solicited proposals for features to be included in Java SE 7. Not all features made it in that release, and the remainder are included in Java SE 8. New features in Jave SE 8 will include lambda expressions, which are a form of anonymous method that can be called on a list of objects. It’s similar syntax to the Lambda expressions in C# 3.0.


new Thread(() -> { while(true){ System.out.println("Hello"); }}).start();

Why Did Java Become so Popular?

The biggest improvement of Java over C++ was that it did not require memory management. C and C++ both required programmers to track dynamic memory allocations and clean up afterwards, a source of many difficult bugs. Java, on the other hand, handled that itself, and included garbage collection. This eliminated that whole class of memory leak related bugs. It may not have been quite as fast as code written in C++, though in many cases it can be. Games still tend to be written in C++ because of that speed, but Java was more than fast enough for businesses. Over the years, improvement in the Jitter (the Just-in-time code compiler that transforms Java bytecode into machine code) has meant that further performance gains have been possible.

The Future of Java

Oracle has a road map planned with Java 9 coming along in a couple of years, according to Wikipedia. However, it might well pay to keep an eye out on Scala, by the professor who wrote the Java compiler. Scala combines object oriented programming like Java with functional programming

Java’s biggest rival in the desktop world is C#, which shares 80-90% similarity in syntax though a much smaller market share. Like Java, C# runs managed code that is turned into native machine code when loaded. Despite starting five years later, C# has slightly bypassed Java technically and there is a certain amount of borrowing of features between the two languages.

Post a Comment

Your email address will not be published.