In this digital age we use computers for more reasons than one. There are billions of people who have come across millions of software, web applications, mobile applications, games etc. in their lives. But there are only a few who wonder how these softwares are developed, what is the science working behind them, etc. So, if you feel the emotional resonance with this piece of thought then you are at the right place.
This post is for amateurs who have just heard the name JAVA and are curious to explore. Here I will introduce java platform and elucidate why java technology is both a language as well as a platform.
But first let us recollect the basic concepts of computing. We know a computer is an electronic device capable of performing computations, which can understand only binary signals.
For example, 5 volt electronic signal may represent binary 1 and 0 volt signal may represent binary 0. Our computer is continuously fed with these signals and eight bits of such signals are grouped together to interpret Text, numerical and symbols (in an eight bit processor). Current day processor is capable of decoding 64 bit at a time.
Suppose we want to add two numbers, how are we going to tell this to the computer? Yes, we will use a programming language (a high level language) and type our instructions. These instructions will be transformed into assembly code (symbolic form of instructions) using compilers and further transformed into machine code (consisting of only 0s and 1s) using assembler and this machine code will be transmitted to the processor. In today’s time compilers and assemblers are combined together and they directly convert our high level code into machine code.
A combination of Operating System and the processor is called the PLATFORM. Thus, Windows operating system running on an Intel processor makes up a platform. Now, with a change in processor, the assembly instructions will also change. Likewise, with a change in Operating System, the level and nature of operating system level calls will also change.
As a developer, we would always want our software program to work on all platforms available. So we would have to buy separate compilers which would convert our high level code into the native machine code.
But this in an expensive affair and may, as well, cause compatibility issues. Hence, buying and installing a separate compiler for different platforms is not feasible. So, what can be an alternative solution? Here enters our Java language.
Let us see how Java deals with different platforms with an example of adding two numbers.
The code to display addition of two numbers is system.out.println(1+2), and saved as a .java file.
Using the java compiler, the code is converted into an intermediate code called the bytecode. The output is a .class file. This code is not understood by any platform, but only a virtual platform called the Java Virtual Machine.
This Virtual Machine resides in the RAM of your operating system and works as an intermediary between our code and the platform we are working on. When the Virtual Machine is fed with this bytecode, it identifies the platform and converts the bytecode into the native machine code.
Hence, java is a language as well as a platform (JVM).
We can also conclude that JVM is an abstract machine. It is platform dependent because configuration of each OS differs. But it makes Java platform-independent.