I had been using NodeJS ever since the first version was released. The benefits of NodeJS is no doubt a lot but recently some projects have changed my mind.
When I started programming about 6 years ago, Java, Python, Ruby were the leaders in backend development. I studied Java in school. The concept of Object Oriented Programming and Polymorphism were useful. They could be applied and you’ll have a structured architecture which makes development easy. But I felt the Java too bloated and I don’t understand why do I need to use a WSGI server to host a web service for python in production. It felt too much of a hassle.
Then came NodeJS. It’s Javascript for Server Side! And I already knew a little Javascript with all the frontend development so why not give it a try?
Creating a web service was super easy. Using the built in package manager npm
I could just install expressjs
and with a little boilerplate codes I’m up with a http server running. The heart of NodeJS is the event-loop. It makes it simple but also fast with asynchronous programming. The standard library is also very comprehensive. I really love streams in NodeJS. Being able to stream raw data saves a lot time saving the data while also keeping the memory consumption to a watermark threshold. It’s very convenient to perform sequenced tasks with streams. I feel that Javascript is a very loose functional programming language which provides a lot of flexibility but at a cost. It takes quite a lot of experience to ensure variables are casted to the correct data type correctly. Honestly, I still prefer using just NodeJS than with Typescript up till now. My thinking is if you want a typed-language, why not just use Java. In recent years, Java has been also improving a lot.
After using NodeJS for so long, I felt I hit a plateau. I wanted to improve and with all the buzz going about with Golang, why not take the chance to try it. And so I did. In one of my projects, I had to develop an application which can run on a Windows machine and communicate over Serial. I had the idea to create a virtual Serial port and use Golang to handle the communication.
With a little of research, it seemed feasible. I used com0com
to create 2 virtual COM ports and a simple go-serial
to establish a channel to communicate over. I struggled a little with the syntax and Go’s handling of errors. But as soon as I get a hold on it, everything worked.
The best part is Golang’s ability to compile the source code into a binary. With the binary, all I needed was to deploy the binary on the client’s deployment machine and it’s done. No npm install
of packages, no worries that the source code is exposed.
My next step is to try concurrency using goroutines in Golang. From what I understand, goroutines are like thread which can be run in parallel with the main application. The good thing is goroutines are very easy to use. Adding a go
in front of a function will execute it as a goroutine — it’s that simple.
Anyway, these are just my views on NodeJS and Golang. Different problems requires different solutions and so there’s no BEST tool to solve a problem. There is always a better tool, but is it worth the risk, effort and time to get hold of the new tool? Or is it better to use the tool you are good with? It boils down to your personal choice and for this time, I chose to pick a new tool to use.