From Node.js to Go

Junerey Casuga
Jun 22, 2020 · 3 min read

At Conflux, we love JavaScript. In fact, most of our APIs were built using Koa, a Node.js framework designed by the same team behind Express. And even though we’re slowly moving into Flutter when it comes to building mobile applications, we still use ReactJS for building UIs for web.

Since we are a team who loves to learn and explore new things, we are always on a look out to things that we think would benefit us. So, we decided to take a look into Go.

Why Go?

JS is a good language, but with numerous flaws. One of them is not being a statically typed language. What about TypeScript you must say? Yes, we do write all of our projects in TypeScript but it doesn’t always guarantee the type-correctness at runtime.

Another is performance. You probably know already that Javascript is not one of the most performant language out there. There are of course many options when it comes to performance such as Rust, Haskell, Elixir and so on. But we think Go is a great place to start as it is one of the simplest among the options.

Interestingly enough, even Ryan Dahl, the creator of Node.js took interest in Go.

“If you’re building a server, I can’t imagine using anything other than Go” — Ryan Dahl, creator of Node.js

Then TJ Holowaychuk, the author of Express, migrated into Go in 2014.

“If you’re doing distributed work then you’ll find Go’s expressive concurrency primitives very helpful.” — TJ Holowaychuk, creator of Express.js

The Switch

As developers coming from Node.js, switching to Go isn’t easy. We had to deal with a learning curve before we can even start building our microservices. Thankfully, we found a framework that allowed us to quickly enter the world of Go.

Fiber is a new web framework written in Go and is inspired by Express. It has a lot of methods and principles that seem to be very common to Express but still has Go’s performance.

Here’s a simple Hello World example using Fiber:

Sample “Hello, world” example using Fiber

If you have used Express, the code snippet above might look something familiar. If not, take a look at an example written using Express below:

Sample “Hello, world” example using Express

Conclusion

Of course the given examples above doesn’t show everything about Fiber and Express. There would still be differences between the languages they were using. Especially in terms of the discipline between writing a Go application and a Node.js application.

We just think that Fiber gave us a “feel like home” feeling because of its borrowed methods and philosophy from Express.

And since we will be writing more Go applications in the future, we have also published a Fiber REST boilerplate on Github. Our Fiber REST boilerplate can be found here: https://github.com/conflux-tech/fiber-rest-boilerplate

If you’re looking for a talented team to build your application, Conflux might be the choice for you 😎

Conflux

Learn about Conflux’s process on product development, engineering, and design

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store