The Goal of This Article
This is a not so technical comparison (you can find more specific tech comparisons elsewhere). I just wanted to outline how it feels to develop web applications in Node.js when you are a Java developer by trade.
So please remember, this article is full of personal opinions.
Before starting, I outline a few premises:
What I’m Trying to Compare
I would like to highlight some of the differences that are perceived when developing an application based on the Node/Express stack compared to one based on Spring Boot.
Why I’m Comparing These
TL;DR: After completing a contracted project, I decided to test another ecosystem to check if it could avoid some of Java’s most criticized points.
One of my last customers was a company that was creating a crypto exchange (yes, quite a common thing in today’s market, but not so common for an Italian based company). They contracted me to join their teams (three different developing teams) and help them build their platform. I mainly developed microservices for authorization and authentication, core transactions processing, and other stuff like customers’ KYC microservices and code libraries shared among different microservices.
That was a big and interesting project.
But during discussions with other teams and people I often heard critiques of Java-based web development in favor of Python or Go. Some of the critiques on Java that the other languages seemed to not suffer from were:
I’m a software developer working in the Java language. I’ve been developing Java-based software for about 15 years.
and 4. should be considered when spinning up hundreds of Docker-based microservices but I think that this scale problem may be nonsense, since, if you have hundreds of microservices running, your organization is probably fairly profitable and you can afford “expensive” instances to support memory-greedy Java applications.
I must be honest, sometimes I think that in 2019 all of the five points above are really reasonable critiques so I wanted to experiment with self-funded projects to test some other technologies.
Since I needed to do web development and not necessarily microservices-based projects, after a quick (really quick) look at GO, I decided against that language. I think it is a great language (from what I read) but it’s not the right tool for my current projects.
I leave to you all the observations regarding dynamic typing, which, in my opinion, isn’t a big deal.
Node.js Is Single-Threaded
Okay, this is one of the most “shocking” things for a Java developer. But the shock vanishes after a few moments. You should consider that everything runs on a single thread (on any Java web app you have multiple threads) and that callback functions (asynchronous functions) are queued and executed when it is better to execute them, but all the code runs on a single thread (the key to Node.js’s speed and low memory consumption). From a Java developer’s point of view, this means:
The JS Equivalent to the Spring Boot Ecosystem: Express.js, Passport.js, Sequelize
If we limit the comparison to the MVC web application part only, Spring Boot is definitely fabulous: light and fast, complete and extremely configurable. From this point of view, a Java developer does not feel any major shortcomings compared to what the counterpart of Express.js offers.
Express.js also offers the same potential. One thing that, depending on personal taste, can be more appreciated or not is the routing: instead of being defined at the level of Java annotation it is defined at the level of routing files.
More generally, Spring Boot indicates a very precise way to organize code into packages (models, services, controllers) while in an Express.js context there are no such guidelines. Nevertheless, it is possible to reapply a similar code structure and there are often projects where the code is structured in a similar way to a Spring Boot project.
ORM in Java has always been, from my point of view, the Achilles heel of Java applications. The Java standard is roughly Hibernate (despite the various alternatives, however widespread, such as Jooq and MyBatis), while, for the JS world related to relational DBs, the most popular library is Sequelize.
Hibernate vs. Sequelize
TL;DR: Hibernate is still the most complete, mature, and versatile solution, but at a very high cost! Sequelize may cover 90% of your use cases.
I don’t hate Hibernate, but I surely don’t love it. It’s over engineered, slow, and complicated. It’s like an elephant. It can, however, do anything with any supported DB. On the contrary, Sequelize is small and simple but can’t manage all use cases.
Some of the things I discovered through the use of Sequelize:
There are also some things that I love in Sequelize, like the easiness to create queries at runtime (that’s a breeze, you can compose a JSON object at runtime and pass it to the query engine). Try to do it while creating a JPQL query or consider how overcomplicated it is to do with certain criteria. Honestly, using Hibernate and Spring Data JPA while trying to dynamically filter a query at runtime by some fields is a pain in the ass, while it is really easy (as it should be with any framework/language) to do in Sequelize.
Another aspect where Sequelize shines in respect to Hibernate is when you hit some hard cases and need to do a native query: both of them let you execute native queries, but, honestly, it is a lot simpler to convert the results to their models in Sequelize than in Spring Data JPA/Hibernate.
And I’m not talking about startup time: introducing Hibernate adds seconds to boot time, while Sequelize is quite immediate.
As a final consideration, it’s quite obvious that:
BigDecimal class are perfect for that scope).
We, at HireFullStackDeveloperIndia, implement the right strategic approach to offer a wide variety through customized Vue.js development services to suit your requirements at most competitive prices.
Vue.js is a scalable framework with a robust in-build stack that can extend itself to operate apps of any proportion. Moreover, vue.js is the best framework to seamlessly create astonishing single-page applications.
Our Vue.js developers have gained tremendous expertise by delivering services to clients worldwide over multiple industries in the area of front-end development. Our adept developers are experts in Vue development and can provide the best value-added user interfaces and web apps.
We assure our clients to have a prime user interface that reaches end-users and target the audience with the exceptional user experience across a variety of devices and platforms. Our expert team of developers serves your business to move ahead on the path of success, where your enterprise can have an advantage over others.
Here are some key benefits that you can avail when you decide to hire vue.js developers in USA from HireFullStackDeveloperIndia:
If you are looking to hire React Native developers in USA, then choosing HireFullStackDeveloperIndia would be the best as we offer some of the best talents when it comes to Vue.js.
Learn Node.js API Development from absolute scratch. This video is for complete beginners getting started guide!