Java is the name of an Island in Indonesia and the name of a type of Coffey and a programming language. As a programmer you are most probably interested in the programming language. Since 1995 Java has been the fastest growing programming language ever and took the was vastly spread in the software community. For many programmers and end users there is a lot of mystery about Java and what it can and cannot do and for that this article came to exist.
The revolution of Java
The advantage that makes Java a revolutionary language is that it gathers all of the advantages of the other languages. And the following are some of the advantages of Java which make it a jump forward for the software industry.
- automatic garbage collection
- network and “Internet” aware
- simplicity and ease-of-use
Many other languages such as C and Pascal are procedural language which means they are structured on functions. Procedures passed parameters (primitive data types like integers, characters, strings, and floating point numbers). The logic of the code was treated separately from the data. You needed to pass the data structures for the procedures in order to manipulate their contents. This was a major source of problems as some parts of the code may do things that are not expected in other parts and tracking which function is causing the problem was a nightmare especially of the code is large.
In some programming languages such as C you could obtain a reference to the memory locations which was a fast but unsafe way to read and write into memory because you could accidentally overwrite on the memory locations.
Java is an object oriented language that deals with objects. Objects contain both the data and the behavior of the objects which is represented as functions or methods. Each object is an instance of a certain class. The class is the definition of the structure of its objects. In Java almost every variable is an object except most of the primary types such as int and float an example of object types is the String type. All objects in java inherit from one single class called Object. Object oriented software design is an advanced way to develop software than procedural programming.
There many object oriented languages today such as Smalltalk. But Java is designed as an object oriented language from scratch. Some other languages such as C++ and Basic are partially object oriented. In C++, you can still overwrite the contents of data structures and objects, causing the application to crash. Thankfully, Java prohibits direct access to memory contents, leading to a more robust system.
Most programming languages are designed for a specific operating system and processor architecture. When source code (the instructions that make up a program) are compiled, it is converted to machine code which can be executed only on one type of machine. This process produces native code, which is extremely fast.
There is another type of language which is the interpreted languages. Interpreted languages are languages that are compiled to binary code that can be read by an interpreter (Mediator software) and that interpreter will perform the actions on the operating system. And this way the code of the program does not need to be compiled into the machine code of the operating system running on the machine.
The approach Java takes offers many big advantages over other interpreted languages. Firstly, the source code is protected from being viewed and modified – only the bytecode needs to be made available to users. Secondly, security mechanisms can scan bytecode for signs of modification or harmful code, that is in addition to the other security mechanisms of Java. Most of all though, it means that the Java code can be compiled once, and run on any machine and operating system that supports a Java Virtual Machine (JVM). Java can run on Unix, Windows, Macintosh, and even the Palm Pilot. Java can even run inside a web browser, or a web server. Being portable indicates that the application only has to be written one time – and can then run on a wider range of machines and operating systems. This saves lots of time, and money.
If you have ever written complicated applications in C, or PERL languages, most probably you have exposed to the concept of multiple processes before. An application can split itself into separate processes, which run concurrently. Each process replicates code and data, resulting in more memory consumption. Getting the processes to communicate together can be complex, and frustrating. Creating each process needs a call to the operating system on which the program is running, which consumes extra CPU time as well.
A much better execution model is to use multiple threads of execution, referred to as threads for short. Threads can share the same data and code, making it easier and faster to share data between threads. They also occupy less memory and CPU overhead. Some other languages, like C++, support threads, but they are very complex to use. Java has support for multiple threads built tightly into the core of the language. Threads require a different way of programming thinking, but can be understood and implemented very quickly. Threads in Java are very simple and rapid to use, and the use of threads in applications is quite often.
Automatic garbage collection
The term garbage collection refers to the reclamation of unused memory space (unreferenced objects). When applications code creates objects, the JVM allocates some memory space for the storage of such objects. When objects are no longer needed (no reference to the object exists anymore), the memory space can be reclaimed for later use by the JVM.
Other languages like C++ force programmers to allocate and deallocate memory for data and objects manually. This makes much extra complexity for the programmer, but also causes another big problem – memory leaks. When programmers for any reason forget to deallocate the previously allocated memory, the amount of free memory available is decreased on the system. Programs that frequently create and destroy many objects may eventually find that there is no memory left and thus the application will not function properly. In Java, the programmer is free from such burdens, as the JVM will perform automatic garbage collection of unused objects.
Security is a big issue with Java. Because applets are downloaded remotely on the client machine, and executed in the browser, security is of great concern. We don’t want applets to be reading our personal documents, deleting private files, or causing any problems. At the API level, there are very strong security restrictions on the file and network access for applets, and also support for digital signatures to ensure the integrity and safety of downloaded applet code. The strong security mechanisms in Java help to protect against unintended or intentional security violations and problems, but it is of a great importance to remember that no system is perfect. The most vulnerable link in the chain is the JVM on which the applet runs – a JVM with known security problems can be prone to attack. It is also worth noting that while there have been a few identified weaknesses in JVMs, they are very rare, and mostly fixed quickly.
Network and “Internet” aware
Java was designed to be “Internet” aware and friendly, and to be able to perform network programming and operations. The Java API provides excellent network support, from sockets and IP addresses, to URLs and HTTP. It’s quite easy to make network applications in Java, and the code is completely portable across platforms. In other languages such as C/C++, the networking code must be written again for different operating systems, and is usually much more complex.
Java also provides the means for much more exciting network programming such as remote-method invocation (RMI), CORBA and JINI, Such distributed technologies makes Java the language of choice for developing large distributed systems such as enterprise applications. The advantage of Java in this area makes it the choice of big corporations such as IBM and Oracle to use as the development language and technologies that they deliver to their clients. On one hand Java is an open source language which means it will never have a monopoly problem and on the other hand the Java open source community is large which will provide a pool of free to use quality code.
Simplicity and ease-of-use
Java was originated from C++. C++ is a very powerful and popular language that was commonly used during the 90’s and still being used in some embedded applications and restart programs. C++ was a very complicated language with some features such as multiple inheritance, templates and pointers which were not very productive. Java on the contrary is object oriented where pointers to memory locations were removed and the usage of object references was used instead also multiple-inheritance is no longer allowed which removes the source of many programming problems. Java provides ton of APIs such as the I/O and Network libraries which makes the life of the developers much easier by providing ready to use code and eliminating the low level development effort. When you use Java most probably you will never go back to the other languages after experiencing the easiness of Java.
Java is a very powerful programming language that delivers a set of features for the developers that makes them save time and effort and avoid mistakes. Java is widely used now by major software houses and continues to spread over time with the support of large corporations such as IBM and Oracle.