DEV Community

loading...
Cover image for You Had Me At Node.js
HarperDB

You Had Me At Node.js

Margo McCabe
On the innovative team @ HarperDB. Podcast host. Tech blogger. DevRel. Women in tech.
Updated on ・4 min read

Ah, Node.js, the handy dandy, tried and true, fast and easy, lightweight and scalable, JavaScript runtime environment. (Yes, that’s the official technical definition 😆). There are a couple reasons I’d like to take a Node-first deep dive today:

The (actual) technical definition of Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. (So, Node.js is actually not a framework or a library). Node came out around 2009, the npm package manager was released the following year, and the world has never been the same ever since. Ryan Dahl first introduced Node.js as an open-source project, which was then sponsored by Joyent. Now used for both front end and back end development, Node.js is highly performant and designed to build scalable network applications. It operates on a single threaded event based loop to make all executions non-blocking. It can handle tons of concurrent connections with a single server, avoiding the burden of managing thread concurrency. Node.js has a “unique advantage because millions of frontend developers that write JavaScript for the browser are now able to write the server-side code in addition to the client-side code without the need to learn a completely different language.”

Pros of Node.js

  • Easy to learn
  • Lightweight, scalable, and performant
  • Fullstack JavaScript, can serve both client and server-side applications
  • Support of large and active community; npm
  • Handles requests simultaneously

Why do developers love Node.js? The team at HarperDB can speak from experience, as they decided to build a database from the ground up in Node.js (you can learn more about this somewhat crazy endeavor here). Generally, Node is lightweight and scalable, enables rapid development, and npm has incredible packages. It promotes efficiency and overall developer productivity as well as code sharing and reuse. One amazing benefit of using Node is as technology is advancing, most of the cool stuff that you want and need is on npm. The community has already done the heavy lifting for you and there are tons of free tools available.

Node.js is great for use cases like real-time web apps, chat and messaging apps, social media, multiplayer games, collaboration tools, API, and even databases! :)

What about the other side of the coin? The list is short, but let’s discuss the potential downsides of Node.js.

Cons of Node.js

  • Does not have direct control of the Operating System/File System
  • May not be as performant as C/C++ (depending on project/use case)
  • Potential performance bottlenecks with heavy computation tasks
  • Relies on callbacks

One author states that one of the main drawbacks of Node.js is its inability to process CPU bound tasks. It is worth noting that there is a native Node.js threading library available that addresses this issue, but out of the box, node is single-threaded. Additionally, due to its asynchronous nature, Node.js relies heavily on callbacks, the functions that run after each task in the queue is finished. While callbacks can be a powerful feature, they open the door for complex and inefficient code if not properly understood. C/C++ can be faster, but can also be more complicated and not necessarily as scalable horizontally.

Global Livestream: Build a Node.js CRUD App with HarperDB!

What are your thoughts? Are you already a member of the Node.js appreciation group, or maybe you haven’t had a chance to check it out yet? Either way, you’re in luck! You can check out the livestream to learn about Node or expand upon your current skills, while building your own Node.js app.

We were excited to host Idris Olubisi, a Software Engineer and Speaker based in Nigeria, as he built a Node.js CRUD application with HarperDB. HarperDB offers unrivaled flexibility, protection, and value for almost every use case, and we'll do it all with a single installation that can run in the cloud, on-premise, and at the edge. CRUD is essentially the basic functionality of an application that deals with Creating, Reading, Updating, and Deleting records. And you’re already familiar with the awesome benefits of working with Node.js!

Meet Idris:
This month’s guest speaker, Idris Olubisi, is a Software Engineer, Technical Writer, and Speaker based in Lagos, Nigeria. He is a Contributor for GatsbyJS and Mentor & Technical Coordinator for She Code Africa. He has extensive experience in the entire project life cycle, from concept to implementation to integration. Idris is an expert at problem-solving, technical leadership, communications, and presentations.

All are welcome! This free virtual code along will be followed by Q&A with Idris and the HarperDB team, so bring your questions. (If you’d like, you can also check out HarperDB’s Node.js SDK available at the Marketplace or on npm).



Alt Text

Discussion (4)

Collapse
moopet profile image
Ben Sinclair

... unique advantage because millions of frontend developers that write JavaScript for the browser are now able to write the server-side code in addition to the client-side code without the need to learn a completely different language

Javascript in node was pretty different to how it was on the front end in 2009, and it's pretty different entirely in 2021. Javascript today is practically a different language - or at least the way it's written is.

Reading the list of "pros" you have there, I'm struck by the way that you could apply them to a bunch of other languages as well - minus the front-end bit, but it's been a decade and things like React and Next are still kludges trying to get the same code to work in both environments.

You had me at, "decided to build a database from the ground up" though :)

Collapse
margo_hdb profile image
Margo McCabe Author

You bring up some great points! At the end of the day, determining which language is "best" sometimes just depends on personal preference and experience. With our team for example, the main (and simplest) reason they chose to build a database in Node is because they already knew it really well.

Collapse
a92gerasimov profile image
Andrei Gerasimov

Do you think Node is perfect for fast prototyping?
It is really cool you can cover both back-end and front-end just with one language!
I think using MongoDB makes it even much easier as well.

Collapse
margo_hdb profile image
Margo McCabe Author

Yeah, JavaScript is super flexible and makes it easy for developers to get prototypes up and running quickly. It's also a stable and robust language so you can solidify code into robust production worthy code.

MongoDB is great, but HarperDB can be easier to use and manage, and it has some other advantages as well. You can learn more from our benchmarks, or attend our livestream next week to see HarperDB in action!