Advantages and disadvantages of Java
Java is a general-purpose, robust, secure, and object-oriented programming language. It is a high-level language, I.e., its syntax uses English like language. It was developed by Sun Microsystems in the year 1995. It is now maintained and distributed by Oracle. Java has its runtime environment and API; therefore, it is also called a platform.
Java is used in a large number of applications over the years. However, it has various advantages and disadvantages given below.
Java is a simple programming language since it is easy to learn and easy to understand. Its syntax is based on C++, and it uses automatic garbage collection; therefore, we don't need to remove the unreferenced objects from memory. Java has also removed the features like explicit pointers, operator overloading, etc., making it easy to read and write.
Java uses an object-oriented paradigm, which makes it more practical. Everything in Java is an object which takes care of both data and behavior. Java uses object-oriented concepts like object, class, inheritance, encapsulation, polymorphism, and abstraction.
Java is a secured programming language because it doesn't use Explicit pointers. Also, Java programs run inside the virtual machine sandbox. JRE also provides a classloader, which is used to load the class into JVM dynamically. It separates the class packages of the local file system from the ones that are being imported from the network.
Java is a robust programming language since it uses strong memory management. We can also handle exceptions through the Java code. Also, we can use type checking to make our code more secure. It doesn't provide explicit pointers so that the programmer cannot access the memory directly from the code.
5. Platform independent
Java code can run on multiple platforms directly, I.e., we need not compile it every time. It is right once, runs anywhere language (WORA) which can be converted into byte code at the compile time. The byte code is a platform-independent code that can run on multiple platforms.
Java uses a multi-threaded environment in which a bigger task can be converted into various threads and run separately. The main advantage of multi-threading is that we need not provide memory to every running thread.
Java needs to be interpreted during runtime, which allows it to run on every operating system, but it also makes it perform slower than the languages like C and C++. On the other hand, the C++ program needs to be compiled on each operating system, directly to binary and therefore runs faster.
2. Memory consumption
Java program consumes more memory since it runs on top of Java virtual machine.
Java programming language is a bit costly due to its higher processing and memory requirements. We need better hardware to run the Java program.
4. Less machine interactive
Java lacks when it comes to interacting directly with machines, making it less viable for the software that needs to run quickly and run directly with the machine, as explicit pointers are also missing in Java.
5. Garbage collection
Java provides automatic garbage collection that cannot be controlled by the programmer. It doesn't provide the methods like delete() and free() to free the memory.
However, due to the various disadvantages, Java is one of the most used programming languages due to its advantages, making it platform-independent, secure and a robust programming language.