Java Programming (What & Why)?

What is JAVA and Why is it important?

As previously stated, JAVA is a high-level programming language. It was released in 1995 and was developed by Sun Microsystems. Earlier to its release, C was a dominant high-level language since 1972. Meanwhile, C++ was also in the process of release as an extension of C and was released a few years later in 1998. C is platform-dependent and extensively used for system programming.

But JAVA has been a remarkable milestone in the history of programming languages. JAVA came with exclusive features like write-once run everywhere. The concept of platform independence and its extreme utility in the domain of application programming.

Let us look into the detail, the features of JAVA which were mentioned in the previous lesson.

Features

JAVA was designed to be simple, object-oriented, platform-independent, portable, secured, robust, architecture-neutral, interpreted, high performance, multithread, distributed, and dynamic.

Let us go through each of it and find out, why and how are these features a boon.

  • Simple: JAVA has a simple and user-friendly syntax. It is very easy to understand. Java syntax removes the ambiguous concepts of C++ and is re-implemented in a simpler way. Key features like pointers and operator overloading have been intentionally omitted to keep it simple and effective.
  • Object-Oriented: JAVA is known to be an object-oriented programming language. In our previous lectures, while explaining the OOPs paradigm, we referred data as an object. In Java, we consider every entity as an object, and this overall combination of various objects serves the desired purpose.
    • While perceiving the surrounding, we see so many objects all around. Let’s take an example. We see books, we see the shelf. Each of it is an object, and the purpose of the shelf(object 1) is to organize the books(object 2), to be kept in it. We are more used to visualize entities as an object all around. This concept is the base of Java making it easier to use, visualize, and implement.
  • Platform Independent: The ones familiar with languages as C, would know the program while running first compiles. This compilation is dependent on the platform in which it is running. So if we compile code in the windows machine, we cannot expect it to run in Macintosh or Linux.
    • In this case, JAVA upon compilation creates bytecode which is platform-independent. The bytecode is interpreted by the JVM(Java Virtual Machine) while running. Hence the bytecode generated in one platform can easily run on any other platform. This makes Java, write once run anywhere.
  • Portable: As mentioned above, the bytecode generated on one platform is to be taken into another platform and run easily without any explicit implementation.
  • Secure: Java has a fame for its security. It is possible to develop virus-free applications because:
    • Java omits the use of any explicit pointers.
    • The Bytecode Verifier checks for illegal code that can violate the access right.
  • Robust: By robustness, we mean strong and durable. It has strong memory management and no explicit pointers. The automatic garbage collection avoids misuse of any dangling/garbage object. The exception handling, compile-time error, and runtime checking make JAVA robust.
  • Architecture Neutral: Ones familiar with C would know that the same data type occupies different sizes in physical memory on the basis of memory-architecture. The int occupies 2 bytes in a 32-bit machine and 4 bytes in a 64-bit machine.
    • However, Java is architecture-neutral and is not dependant on the implementation i.e int occupies 4 bytes of memory irrespective of architectures in Java.
  • Interpreted: Java is an interpreted language. The bytecode generated upon compile is interpreted to machine-specific, machine instructions while execution without storing physically. The overall process is light-weighted.
  • High performance: As mentioned above, Java is an interpreted language, so the bytecode generated is near-native code, and is not fast relative to compiled language as C/C++. But, Java delivers high performance with the use of a just-in-time compiler.
  • Multithread: In Java, we can write a program capable of performing concurrent tasks( many tasks at the same time). In order to do so, we have the concept of thread( a lightweight process ), that utilizes a common memory area instead of dedicated thread-specific memory. So the execution of multiple threads concurrently is known as multithreading.
  • Distributed: Java is distributed. It has been designed for the distributed environment of the internet. It makes it feasible to access accessible files from any machine in the network by calling the methods.
  • Dynamic: .Java is a dynamic language.

Let us take a real-life example to understand, what do we mean by dynamic. There is a queue comprising both male and female. On the basis of gender, the host directs them to a specific floor. The host’s decision depends on gender and is not fixed. In short, the host here is dynamic.

Similarly, java supports the dynamic loading of classes upon demand. Apart from loading, garbage collection is one of the perspectives to witness dynamicity.

So the above stated are features of JAVA. All of these features will be seen with practical examples in future classes.