Java (A Cup of Coffee)
Java is a widely used programming Language. You can run Java program on almost any platform e.g. Window, Unix, Linux, Apple etc. The most important feature of Java is WORA, i.e. Write Once Run Anywhere.
Let's start with the Architecture of Java.
Think about a 'C' language program. You follow the following process to run the 'C' Program.
- Create a 'C' Program
- Compile the Program
- Link the Program with Library
- Run the Program/ Load the program into Memory
Why we compile the program?. To convert the program in Machine Language. What is Machine Language? Machine Language is in the form of 0 and 1. But I think in Computer each and everything is in 0 and 1. When we write 'A' in a computer, it first converts into ASCII equivalent and then converts into binary (e.g. 1000001), and then stores into the computer. This means our 'C' Program was already in 0 and 1, then why we compiled it?
Dear Learner exactly we converts the program into OS Compatible Code, and each OS has it own format of code. Threfore we can;t use the format of one OS into another OS. If we wish to run the 'C' program on two different OSs then we need 2 different compilers.
OK, now lets we have 2 different compilers.
But each OS works internally in different mode, you can't guanratee the uniformity of same program on two different OS.
Generally you used Turbo-C compiler, in which the size of the 'int' is 2 bytes, but on unix size of the 'int' is 4 bytes.This is main the difference.
But Java designers wants uniformity, i.e. program performed in same mode/form on all Operating Systems and this was not the possible with the architecture of 'C'. That's why they designed the JVM (Java Virtual Machine), which is a mediator between your Java program and Operating System. JVM's are machine dependent but their working is machine independent. JVM uses 'Byte Code' as source code, therefore you need a translator (compiler) to converts the Java Source Code into 'Byte Code', but 'Byte Code' is not the Machine Code, each JVM has its own translator know as JIT, JIT converts the byte code into machine code on runtime.
Java has two translators.
1) 1st translator converts the Java Source Code into Byte Code.
2) 2nd translator converts the Byte Code into Machine Code.
Due to the mediator Java porgrams are appx.3-5 times slow as compare to the C/C++.
But it has following features.
- Secure
- Robust
- Pointerless
- No Garbage Data
- Object Oriented
- Potable
- Dynamic
- Simple- Syntax is similar to C/C++
- WORA-Write Once Run Anywhere