Why Java Was Loved 20 Years Ago and Disliked Today

Exploring the Reasons Behind Java’s Popularity and Decline in the Tech Industry

Nishant Aanjaney Jalan
CodeX

--

Java has been around for nearly 30 years. 3 billion devices run Java since 1997. Now that newer JVM languages such as Kotlin and Scala are popular, has Java become obsolete? Did people hate Java?

I believe there were quite a lot of people who loved Java. I am proud that I was one of them. When languages like Kotlin and Scala emerged, I found those languages better. In no way that meant I hated Java.

Java’s popularity was so significant that ECMAScript was nicknamed JavaScript since it replaced Web Assembly as quickly as Java in our hearts.

I wasn’t born when Java bloomed at that age. However, I can list a couple of pointers that indicate Java was a loved language.

Why was Java so popular among programmers?

  1. Platform Independent — Since Java runs on the Java Virtual Machine(JVM), the same code could run on multiple platforms without any hassle. C, on the other hand, had multiple compilers that wrote assembly code for different ISAs. If a C program could run on Machine A, it was not guaranteed to run on Machine B.
  2. Similar syntax to C and C++ — Java shared a similar syntax to C and C++, which allowed programmers to switch to Java without having to relearn everything.
  3. No more pointers — Java eliminated external handling of pointers. This implied you did not have those annoying segfaults anymore. Java used pointers (of course), but the code was abstracted in various ways.
  4. Automatic Garbage Collector — In C and C++, the programmer had to manually free up memory when the object is no longer in use (calls for major memory leaks). In Java, based on certain rules that the programmer should be aware of, the garbage collector will automatically free up unused allocated memory for you.
  5. Object-Oriented Programming — Haskell was a purely functional language. It was heavily dependent on mathematical skills and required practice to master. Java was a purely object-oriented language, which related to real life well. The shift smoothed the learning curve (which of course gets very difficult later).
  6. Clear structure — Java’s syntax was very structured. Everything in a class aids in comprehending related information and functions. Since the first “Hello, World!”, you are required to have a basic understanding of the class syntax. Important principles, design patterns and programming paradigms could be easily explained with the help of Java.

Reviewing the reasons above, there is no reason to hate Java. Java was the language in the 2000s. Multiple government software and banks used Java, and some of them still do.

But what happened now?

No matter what people say, Java is declining now. Although Java is still maintained, and there are still many Java developers across the globe, the past glory of the language is now gone.

  1. Nullity — As the creator of “null references”, Tony Hoare, in an interview, said that “[it] is a billion dollar mistake” as it leads to unexpected behaviours and program crashes. Java, adopting the use of null, in the core library, makes it similar to handling a segfault errors in C.
  2. Rigidity — After programming in Java for a while, you would notice you write the same code multiple times. As technology advanced, there was a huge spike in increased boilerplate code in Java, thereby making it bulky.
  3. No functional language support — As I said earlier, Java was purely object-oriented. However, programmers required features involved in both imperative and declarative languages.
  4. A flaw in Inheritance Abstraction — We have four access specifiers in Java: public, protected, private and package-protected/default/friendly. There was no way to allow access to sub-classes and restrict access to other classes in the package.

Java 8 Improvements

Java maintainers did not ignore the requests of developers.

  1. Functional support — They introduced functional interfaces with the Stream API. However, due to backward compatibility, implementing it is still quite chunky.
  2. Optional<T> class Optional<T> is a workaround for the nullity problem. Nevertheless, including Optional<T> doesn’t eliminate the possibility of null, since it is ingrained in Java’s core library.

Java 12 Improvement

The introduction of switch expressions reduced some of the boilerplates in conditional control flow.

Java 16 improvement

Java introduced records that remove much of the boilerplate while writing POJOs (Plain Old Java Objects).

On-coming of Kotlin and Scala

Like Java was created to be an improvement over C++, Kotlin is created to be an improvement from Java.

Benefits of Kotlin

  1. Reduced Boilerplate greatly.
  2. Ingrained null-safety.
  3. Introduced String templates (inspired by Python/PHP).
  4. Introduced sealed classes (inspired by Rust/Haskell).
  5. Multi-paradigm language (improved OOP and incorporated functional).
  6. Operator overloading (like in C and Python).
  7. Introduced data classes (which are records in Java).
  8. Other miscellaneous features like extension and inline functions, and coroutines.

Since I have never programmed in Scala, I am choosing not to discuss its benefits here in this article.

Conclusion

Just because something better came along, it does not mean we hate Java.

Java was the star programming language, and we cannot overlook how it helped transform programming languages today. Java was built to solve some problems and, as a side effect, created new problems. The way I see it, 10 years down the line, people will start complaining about today’s languages and a new language would be created to address those problems.

If you hate Java, remember that if it was not for Java, modern languages would not be as powerful as they are today.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.” ― Bjarne Stroustrup, The C++ Programming Language

I hope you enjoyed reading my article and learnt something. Thank you! Check out my “Everything Kotlin” reading list where I publish articles on advanced Kotlin concepts and best practices.

Everything Kotlin

22 stories

Love what I do?

Consider Buying me a coffee!
Want to connect?

My GitHub profile.
My Portfolio website.

--

--

Nishant Aanjaney Jalan
CodeX
Editor for

Undergraduate Student | CS and Math Teacher | Android & Full-Stack Developer | Oracle Certified Java Programmer | https://cybercoder-naj.github.io