This introduction to Java focuses on knowing the Java Programming Language. We will cover Java’s significant characteristics and components, why it was invented, and a brief history. The Java Tutorials series focuses on Learning Core Java and some of the fundamental and advanced features of Java Language. In this first article of the series, let’s get introduced to Java Language.
Java is an objec-oriented programming language that has been alive for years and still holds the top spot in the popular languages chart. Since invented, Java has been empowering several Enterprise Applications, Microservices, Desktop Applications, Mobile devices, and embedded devices. Java has excellent adaptability and can be used in various requirements as the first choice language.
Java was developed at Sun Microsystems by James Gosling and was initially named Oak. The reason behind yet another programming language was some API shortfalls of C/C++ and a need for a portable programming language. As Java was developed as an alternative to C++, its syntax and programming style is inspired by C++ and supports Object Oriented Programming standards.
Java is one of the world’s most popular and widely used Programming Languages. According to a recent developer survey by StackOverflow, 33% of professional developers use Java. The below chart.
Java is primarily known for its cross-platform abilities, that is, Write Once, Run Anywhere (WORA) behaviour. That means a Java program can be written on one machine (operating system) and run on another without changing. It used widely used to develop Desktop, Web, Mobile and device-embedded applications.
Along with the above, below are some of the significant features of the Java Programming Language
- Simple: Java was intentionally made simple. The syntax is kept similar to C++ to reduce the learning curve. A Java programmer doesn’t need to deal with complex things like pointers, destroying unused objects, operator overloading etc.
- Cross Platform: No matter which machine, or device you are on, you write the same program. Java has no coding constructs coupled with the underlying hardware or platform.
- Secure: Java is considered a secure language because it keeps the object and memory management to itself. Developers can’t manipulate the memory pointers. The Java bytecode verifier and class loader verify if the loaded class is the correct one with a legitimate bytecode.
- Portable: As discussed earlier, once compiled into the bytecode, a java program can be transferred, sent as an email, or downloaded from the internet and run on any machine without any issue. That is why we can develop applications on our mac or windows machines, and once the project is built, we can quickly ship the archive to the production environment, which is primarily a UNIX-based system.
What is an Object Oriented Programming Language?
In Object Oriented Languages, the primary importance is given to Objects. When we write real-world programs, we model real-world entities; while doing so, we need to represent them in the form of Objects. Java is one of the Object Oriented Programming Languages.
In Java, each Object has some properties. The properties define the state of the Objet. Along with the properties, the objects also have behaviours. Behaviours are represented in the form of methods. Behaviours mainly access or change the Object’s state or invoke other objects’ behaviours.
Java is considered Object Oriented, but it is not purely object-oriented. Java has a few primitive datatypes (e,g, int, float, double etc), which are not objects but special-purpose datatypes. Another thing is the static variable. Like primitives, the static variables do not follow the Object Oriented paradigm.
Write Once, Run Anywhere (WORA)
When a program is written, it is usually textual and human-readable. We need to compile this program before we run it. Each language has a compiler that, first of all, validates your program for any syntactical mistakes. Once your program is correct, it will convert into a more machine-level program. (remember: to run your program, it needs to be transformed into Operating System and Hardware level instructions).
In most programming languages, including C/C++, the Compiler is the one who converts programs into machine instructions. However, Java thought it differently. Java created a virtual machine called Java Virtual Machine, which sits between the program and the operating system. A Java program, once compiled, doesn’t get compiled into machine instructions. When we run a Java programmer, the Interpreter sitting in JVM does this parsing. As the parsing happens at runtime, we can run a Compiled Java Program on any operating system. While for other languages like C/C++, we need to recompile the program on the operating system it wants to run on.
Top-level Java has many components like JVM, JRE, library, tools, JDK, Garbage Collection, ClassLoader etc. But to understand it better, let’s first look at the essential components of Java.
- Java Virtual Machine (JVM)
- Java Runtime Environment (JRE)
- Java Development Kit (JDK)
When we download Java, we have two options. Either download Java Development Kit (JDK) or Java Runtime Environment (JRE). JDK will be required for writing and compiling the Java Applications, and JRE is needed to run the Java Programs. Typically, the deployment environments like production have JRE installed on it.
To learn more, please read What JVM, JDK and JRE are.
Java Release History
In this theoretical post, we had a brief about Java Programming Language. We have covered a brief history of Java, its features and why Java is so a popular programming language. We have learnt that Java is an Object Oriented Programming Language and Java’s most important characteristic is Write Once, Run Anywhere (WORA).
We will continue diving deeper into this lovely language in the upcoming articles.