Back to the future with JAVA

Manu Jha
5 min readFeb 4, 2021

It is not enough for code to work”- A line which appears to be flawed to the eyes of pseudo programmers. But those who know, know.

I was never a fan of any programming language. They are tools we get adjusted to over a period of time. With every change, there is a new experience. The main belief stays the same : If you can enunciate it, you can code it. JAVA is that one tool which comes with the biggest instruction manual, yet for a developer whose base was Javascript agility of the language was a surprise. The year is 2021 and after 2 weeks of working on Java 11, I questioned myself one thing; Why did I not dive in this pool before.

I might not be a great programmer, but I aspire to be a programmer with great habits. JAVA has a defined, structured, tried and tested path of crafting involuntary skills in a developer which makes her/him disciplined and dedicated to their code. 2 weeks into development and I already take proud of each line I have typed. It’s no surprise that people who have base in JAVA are going places and industries out there have blind faith on the language. Sometimes I wonder if the term “Nothing is Impossible” was coined by someone who was programming with JAVA.

Why JAVA Over Other Languages ?

Simple answer to this question, there is no reason to it. Gone are the days when JAVA faced backlash for not supporting functional programming, dynamic typing, first class objects etc.

I had heard people swearing on multithreading when it came to JAVA but when I started working on it, executor services felt smoother than hot knife on butter. Using eclipse can be a good experience but I coming from Westorm background I preferred sticking to IntelliJ and that has been one of the best decisions I have made. The transition could not be smoother. So to answer the ghost in the closet, what does JAVA offer which makes it language of the future. The answer is, EVERYTHING.

Let’s go through some of the amazing things JAVA has to offer us today:

  • Records — The record is a new type of class in Java that makes it easy to create immutable data objects. Prior to records, creating an immutable data transfer object (DTO) would in itself take multiple lines of code. Example :
public class Person {
private final String name;
private final int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}

With records the lines of code shrink to 1 as follows :

public record Person(String name, int age) {}
  • Hidden Classes — The goal of hidden classes is to allow the runtime creation of classes that are not discoverable. This means they cannot be linked by other classes, nor can they be discovered via reflection (This is another awesome feature which has been existing for ages now). Classes such as these typically have a short lifecycle, and thus, hidden classes are designed to be efficient with both loading and unloading.
  • Pattern matching — Pattern matching allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely. For Node Js developers, this can be same as using instanceOf operator
  • Single command execution — There is no more the need of compiling the JAVA program using the javac tool first. We can directly run the file with java command and it implicitly compiles.
  • JAVA string methods — The JAVA string methods like lines(), strip(), stripLeading(), stripTrailing(), repeat() etc could not be less than life saviour at instances.
  • Lambda parameters are in itself a boon to someone coming to JAVA from JS background. They are self explanatory and make life easy.
  • Epsilon: A No-Op Garbage Collector — Unlike the JVM GC which is responsible for allocating memory and releasing it, Epsilon only allocates memory. It allocates memory for things like performance testing, memory pressure testing, VM interface testing, extremely short lived jobs etc.
  • Helpful NullPointerExceptions — Probably one of my favourite features so far in the new version of JAVA, By an analysis of the bytecode instructions of a program, in the future the JVM should be able to show precisely which variable results in a zero value. Then the JVM will output a null-detail message in the NullPointerException, which appears next to the usual message. The above example would look like this:
Exception in thread "main" java.lang.NullPointerException:Cannot assign field 'i' because 'a' is null.at Prog.main(Prog.java:5)

The list can be never ending. JAVA has been proving it’s worth at every step and every page turned reveals a new feature which makes life easy for developers.

My Gateway To JAVA

I entered into JAVA with blank mind and low hopes of picking it up as I did with Node JS. To my surprise the language greeted me with open arms. My first line of code and I could hear confetti around. The JAVA stack at inception of my project was as follows :

  • JAVA Open JDK 11
  • MyBatis
  • MySql
  • Spring Boot

With previous experience on Typescript and Loopback 4, Spring boot was a piece of cake. MyBatis might appear quite tricky but it is really simple and comes in a small package. It was highly flexible and easy to work with. I read that stored procedure are highly compatible with MyBatis as compared to Hibernate but I have not had personal hands on later so any conclusion would be void.

Conclusion

After working on some latest languages like Python 3, Node Js, DENO, ROR and GoLang, I feel that the statement that JAVA is not the future stays nullified. The potential of the language and love it gets from the community is beyond quantifying. The future would definitely have exponential progress when it comes to application development.. and when it happens, JAVA would be the torch lighting and guiding the path for many. Truth can only be found in one place: the code, and JAVA code speaks a lot about it’s wisdom, class and reliability with poise.

--

--

Manu Jha

I am just another developer shaping ideas into reality by sitting in air conditioned room in my sweatpants sipping coffee and having vision of making an impact.