Features or the benefits are what make a product successful. In the previous article, we examined the history of Java. Almost from its 1.0 release in 1996 Java has been immensely popular. There are literally hundreds of programming languages out there. Some of these such as Python are general purpose. Others such as R cater to a certain niche. And still in this myriad of mumbo jumbo, Java stands out.
So, what makes Java so special and different? In this article we will examine some of the reasons behind the popularity of Java. There are of course other, more subtle reasons behind the celebrity status of Java, and we will also look at those over the course of next few articles.
The Java White Paper Buzzwords
Sun Microsystems had a strange habit of summarizing its business practices and products in eleven words. These eleven words were constantly emphasized to both customers and employees. Java, as one of the original products of the company too received its share. These buzzwords succintly summarize some of the most important features of the Java programming language
- Simple – This is easily the number one reason you should learn Java. Java was intentionally designed to be simple in syntax and clear in semantics. The language intentionally aovids clumsy features such as operator overloading, pointer mechanics, multiple inheritance and use of header files. Java was intentionally designed to syntactically close to C and C++. Further, Java uses the borrowed features without introducing changes of its own. For example, the switch statement could easily have been improved. But to ease the learning process, Java does not introduce idiosyncrasies of its own.
- Object oriented – object oriented methodology is a program design technique that has been most popular for the last few decades. Java has been designed to be object oriented from ground-up. This means that Java makes you very hard to write non object-oriented code. Of course, object oriented design is not the only design technique. There are serious but less popular challengers such as pure/hybrid functional design.
- Networked – As explained in the previous article, the main reason behind the explosive growth of Java in initial years was the networked and distributed nature of the language. Internet programming has always been easy in Java, thanks to its support for both application level protocols such as HTTP & FTP and transport layer protocols such as TCP and UDP. As will be demonstrated later, common operations such as accessing URLs and writing REST clients are amazingly easy in Java.The Java white paper also mentions the distributed nature of Java as implemented by RMI. RMI or Remote method invocation allows you to executed methods on a JVM other than from where it is invoked. This may be a JVM on the same physical machine or a machine located half a world away. In spite of the benefits offered by RMI, it’s popularity has waned over the years primarily because web services offer the same functionality but in a more standardized way.
- Secure – Java security is like onion. There are layers upon layers of it in every nook and corner. To begin with, there are no pointers to fool around. The boundaries between objects are further secured by coding practices such as encapsulation.
Next, there is a bytecode verifier sitting in the classloader of JVM that makes it impossible to load a malformed and malicious code into JVM. Of course, what can’t be loaded, can’t be run.
Then there is a security manager that allows running new or untrusted bytecodes in a protected “sandbox” environment.
Java provides implementation of standard cryptographic algorithms such as RSA and hash algorithms such as MD5 and SHA1.
- Architecture-neutral – The Java compiler does not generate machine code but bytecode. This bytecode can be run inside a JVM. Since, there is a JVM for almost every relevant platform, the bytecode can be run anywhere. Thus, the code written on one operating system runs fine everywhere else.
- Portable – Though in a sense the architecture-neturality describe above makes a Java program portable, but Java portability goes a step further. First, data sizes are defined by the language and not by the operating system. So the size of an int is always 4 bytes in Java (unlike C and C++). Further, there are GUI libraries such as Swing and AWT that have consistent behavior/look and feel across all operating systems. A Swing program, for example, appears exactly the same on both Windows and UNIX.
- Interpreted – The Java compiler generates bytecode and the interpreter runs the bytecode. Thus Java execution happens as though it were a truly interpreted language (much like Python and PERL). There is a hotspot compiler, but consider it as a performance enhancement feature.
- High-Performance – While most agree that Java runs slower than C and C++, in today’s world, performance is not about being able to save that last ounce of bit or CPU cycle. With the rise in popularity of Cloud and Big Data, it’s much more important to scale horizontally – meaning to be able to use a lot of computers simulatenously.
Java, because it is distributed language, can be designed to run a program on several JVMs on various machine and still give an impression to the client that a single VM is running. This typically requires using 64 bit JVM (for heap sizes more than 2GB) and passing in the -d64 option on Oracle JVM.
Java was multithreaded from the word go. Unlike C++ where threading was an afterthought, Java has always supported multithreading.
- Dynamic – Java is dynamic in the sense that there is a rich support for discovering information about runtime objects. This introspection feature is provided through Reflection API. It allows the programmer to make decisions at runtime.
We are socialSpread the word