What is Node.JS, really?

You’ve heard of Node.JS (probably) but what exactly is it? Should you care? There has been a lot of buzz around Node.JS lately — and there’s traction to back it up. Some major companies have adopted the framework including PayPal, LinkedIn, Netflix, Uber, eBay, and many more.

As the name implies, Node.JS is powered by JavaScript. In brief, its an event driven framework that competes with the likes of PHP, Django, and other web technologies.

What is it used for?

Really, Node.JS can be used for just about anything. From dev tools to production deployments. Since Node runs server-side JavaScript, it’s just as capable as any other language. Support for reading ports and files — functionality that is usually restricted when running in the browser, is now available at your fingertips.

Realistically speaking, when people refer to Node.JS, they typically mean Node.JS + Express, essentially a web server. The entire stack can be handled this way, removing the need for Apache or NGINX. This framework can be a great choice for real-time applications and building a custom API.

What makes it so popular?

JavaScript is arguably the most popular language on the planet. Many programmers have a basic familiarity with the language; but the benefits don’t end there. Over 73% of websites rely on JavaScript for important functionality. It’s used to create the beautiful, interactive experiences we’ve grown accustomed to. Traditionally, this creates a divide between front end and back end development. While back end developers learn PHP, Java, or, gasp, C, front end developers learn JavaScript, HTML, and CSS. Not with Node.JS. Both front end and back end development can be done entirely with JavaScript. This simplifies the stack and eliminates impedance mismatch.

The need… the need for speed! Node relies on Chromium’s V8 engine. This means the JavaScript doesn’t stay as raw (and potentially slow) JavaScript. Instead, it’s compiled into machine code, much like C would be. This has huge implications for both performance and efficiency of the application. An uncorroborated post claims Walmart’s overall CPU usage never exceeded 1% after switching to Node.JS, even with over 200 million daily users.

A thriving community. Community support is truly top notch. Tutorials, guides, and troubleshooting information is available in abundance. The package manager, NPM is also top notch. Tracking and installing project dependencies could not be easier. Want bootstrap? Easy, npm install bootstrap. Similar to pip’s requirements.txt, you can create a config.json file outlying all the dependencies. Once complete, a simple npm install will ensure everything is ready to go.

Those of you that prefer NoSQL like databases can rejoice. MongoDB (and similar) are commonly used within a Node application and support is prolific. Object Role Modeling is quickly becoming the preferred method to develop in Node.JS — but not to worry, those that prefer standard relational databases have plenty of support too.

What’s the catch?

Node.JS is heavily event driven. I consider this both a pro and a con. Event driven programming (more on this in the next section) can be tricky at first and bugs can be hard to track down.

JavaScript doesn’t have a standard library. Sure, there are community packages for just about anything, but there’s not one package but six or more. Choice is not always good, with six ways to do things, there’s often 5 ways to do it incorrectly. The default packages included with Node.JS can even be replaced if you’re unsatisfied.

Production environments are much more complex than standard Apache/NGINX setups. Error handling is essential, since just one bug will crash the entire process. To utilize multi-threaded systems, one server should be started for every thread. This necessitates a local load balancer to share the same port and a method to cluster the separate instances.

Can we address this “event driven” thing?

This is best illustrated by analogy. Dan York has an excellent article explaining the event driven model. In his post he compares the situation to ordering fast food. In a traditional thread based model, one person would get to the front of the line, place an order and stand around waiting until his food was prepped; holding up everyone behind him. In contrast, an event based model would order the food, then step aside until he’s notified that his order is up. This way, the patron behind him can place an order immediately.

Here’s some pseudo code to illustrate the point. A traditional thread based model might look something like this:

var currentUser = db.getUser(userId);

In contrast, an event driven model uses callbacks.

db.getuser(userId, function(user, error){
    if (!error) {
    } else {

The anonymous callback function is called only after the user information is retrieved from the database. In the event driven model, it’s likely doSomethingElse() will be executed before logging the user information. In the thread based model, of course, this would never happen. We’re stuck “waiting in line” for the database call (the thread blocks) before continuing with the program’s execution.

Do you plan on using Node.JS for your next project? Wish your company would make the switch? I’d love to hear your thoughts!

NextCloud vs. OwnCloud: History & Feature Comparison

If you’ve done research into self-hosted cloud storage, there are two main contenders that typically pop up: Nextcloud and ownCloud. So which one’s right for you? What’s the real difference between the two? Let’s find out.

For the impatient among you, I’m going to get right to the point. Nextcloud is the superior option in nearly every case. Why? I guess you’ll have to keep reading.

The story began long ago (2010), in a far away land (Germany). Frank Karlitschek, a KDE developer, started working on ownCloud. He envisioned an alternative to DropBox, one more focused on privacy. In his blog, he argued “Privacy is the foundation of democracy.” In 2011, ownCloud Inc. was born in conjunction with the original software release. The company went on to raise 6.3 million USD in 2014 as it started to target more lucrative enterprise clients. The future looked bright for the young startup, but just two years later, things got messy.

On April 27, 2016 Frank Karlitschek left ownCloud. A few short days later, he founded Nextcloud, a direct rival. Karlitschek stayed pretty tight-lipped about the whole situation, but actions speak very loudly here. Leaving the company you co-founded and days later creating a competitor is a bold move indeed.

Investors agreed. Behind the scenes, ownCloud was on the verge of sealing a major deal. Karlitschek, along with several other core members, abandoning ship to form Nextcloud, was more than enough to send investors reeling. And the final nail in the coffin? Nextcloud decided to offer free support for any users migrating from ownCloud.

Just days later, ownCloud (the US company) shut its doors for the last time. So why the debate? OwnCloud is dead, right? Well… not quite. Like a good zombie, it won’t go down easy. While US based ownCloud Inc. had all its credit revoked, the parent German company, ownCloud GmbH, carries on to this day.

Karlitschek has never discussed the exact reasons leading up to his departure, though in the blog post announcing his resignation, he states, “…the company could have done a better job recognizing the achievements of the community. It sometimes has a tendency to control the work too closely and discuss things internally.” Most speculate ownCloud’s lack of interest in the outside development community ultimately lead to Karlitchek’s decision.

Today, OwnCloud continues to focus on its enterprise business, having a number of features available only to paying customers. In contrast, Nextcloud focuses heavily on security features: brute force protection, 2FA, video verification, and more. Nextcloud also remains 100% open source. This means all its features are included standard — enterprise customers just pay for support.

Enough history, let’s get on with the feature list.

Feature NextCloud ownCloud
Open source Mostly
Unlimited storage
Mobile app support
Automatic media upload
Integration with Outlook Premium only
Text search
Version control
Calendar, contacts, etc x
Notifications x
Server-side encryption
Client-side encryption Yes, but buggy x
Access controls Great Good

Normally, I would jump right into the feature comparison, but I felt in this unique case, the history should play a role in the decision. Which software do you use? Let me know in the comments.