5 things I've learned shifting from NodeJS to Java

Background story

I've been working mostly as a JavaScript We developer for the past 5 years or so. I consider myself a software developer rather stick with one particular subdomain such as ERP or DBA.

I have a background in Sage and Oracle ERP, Salesforce, some Hybrid Mobile Development but also as a test automation pioneer in one of the companies I worked.

I like working with Ruby on Rails but now with the impact of Covid, I prefer for the moment at least stick with enterprise grade proven technologies.

I easily get bored with repetitive task but I do respect people who can do similar things for long period of time and this is the way to become an expert in a field.

After several years, I've moved primarily from NodeJS to Java. Here's the first differences I've noted. I have plenty of experience with Java as well.

String Interpolation / Template literals

const age = 3 ;

console.log(`I'm ${age} years old!`)

With Java, it's String.format("I'm %s years old!", age).

JSON Deserialization

With NodeJS, JSON deserialization is built in and easy to use without external libraries. This is because JSON known as JavaScript Object Notation is part of JavaScript or EcmaScript standards.

You can simply use JSON.parse() function to parse a valid string into a JSON object.

With Java you can do it manually though if you're going to use the default libraries. However, you can also use the Jackson library with the object type, and it will do all the heavy duty for you.

Date Time manipulation and formatting

The built in Date Time manipulation and formatting libraries in JavaScript are too barebones unless you write your own abstraction methods. I prefer using third party libraries such as momentJS or the latest LuxonJS.

However, the default ones in Java are sufficient and easy to use:  you don't need any external library.

Key Value Pair

This data structure is an excellent way to simplify your codes logic and a natural way of representing data. For example, in your phone contacts, each number is unique representing a contact. The key is the number and the value contains the rest of the data. This also helps with efficiently retrieving the value if you know the key.

With JavaScript, you can create an object like const obj = { 'key' : 'property' }.

With Java, you need to use a HashMap (or TreeMap) and specify the type e.g. HashMap<string, string> data = new HashMap<>;

Repository

I started using JavaScript in Web Development at a time when you had to manually download libraries like jQuery and add to your projects.

Nevertheless, the biggest issue in my opinion was managing dependencies, sometimes different libraries use the same dependencies but then at one point, when you updated one of them, it broke another one.

Then came bower solving this problem. NPM eventually replaced it and abstracted all the dependencies.

I also used bundler with Ruby on Rails web development projects and pip for some python automation scripts.

When I was learning Java at university several years back, we had to download and separately add the jar files, was quite a hassle. Thankfully the projects I later worked on in Java already had the libraries required.

Now I'm using maven, and with IntelliJ idea, adding, updating and removing libraries is a breeze.

Conclusion

As a Software Developer, at least one point in our career, we are going to move onto new technologies. For me the best way to navigate through this is to master the fundamentals and learn how it works in the new technologies.