Geeks Chicago Technology News

Nike, PayPal, and GM use the very popular AngularJS and Node.js, but should you?

Posted about 6 months ago ago by

AngularJS and Node.js

The two JavaScript tools of AngularJS and Node.js — the former client-side, the latter server-side — have exploded in popularity in recent years. Major companies such as Nike, General Motors, PayPal and the Guardian have incorporated AngularJS into their web stack, while LinkedIn, CBS, eBay and the New York Times all rely on Node.js to power their websites to some extent. Programming blogs and developer conferences are singing the praises of both technologies and abuzz with the latest news and rumors.

While AngularJS and Node.js are both undoubtedly powerful parts of a web developer's toolset, all of this excitement and attention can be intimidating for newcomers, and it's important to separate the facts from the hype. So where did Angular and Node come from, and what exactly makes them so popular?

They Both Use JavaScript

JavaScript has come a long way from its lowly status as a quick patch for the limitations of HTML, when it was used for little more than creating popup windows or making the user's cursor change colors. A whole host of JavaScript technologies has appeared on the web development scene in the past decade, and Angular and Node are firmly in line with that tradition. Because both are built using JavaScript, they play nicely with other JavaScript technologies, such as jQuery, AJAX, JSON and React.js. Furthermore, the technical barriers are low: Because developers are already familiar with JavaScript as a web language, they don't need much convincing in order for them to try out another useful JavaScript technology, which helped drive adoption for both Angular and Node.

Node Is Fast and Lightweight

Node has an event-driven architecture, which means that all of its calls and operations use an event loop, a single thread that executes tasks asynchronously. This is in sharp contrast with the traditional approach of using either synchronous execution or asynchronous execution using multithreading, which uses a lot of memory but was preferred in other programming languages because of the difficulty of implementing an event-driven architecture.

Node's asynchronous, single-threaded architecture is simpler to do in JavaScript, and it means that the technology is very fast and scalable, supporting tens of thousands of connections on the same server. In performance comparisons, Node is more than able to compete with and even exceed other backend technologies, like Java, PHP and Python.

Angular Is Unique and Feature-Rich

Angular provides a number of features to JavaScript developers that make it an extremely popular choice of web framework. For one, Angular is a model-view-controller (MVC) framework; MVC applications store data somewhere in a model, provide a view to the user and connect the two using a controller, which updates the view when the model changes and updates the model when the user interacts with the view. What makes Angular stand out among MVC frameworks is that it supports two-way data binding. This term simply means that data is automatically synchronized between the model and the view, rather than the developer having to write code to keep the two updated and in sync.

To accomplish two-way data binding, Angular makes use of directives. These are attributes or markers that are attached to HTML code and tell the Angular controller how to connect parts of the web page (the view) to the data behind the scenes (the model). Many developers find Angular's declarative approach preferable to using a procedural approach, as with standard JavaScript. Developers also tend to see Angular directives and HTML as less complicated and easier to refactor than JavaScript, and working with Angular removes the need to worry about cross-browser compatibility in JavaScript.

Angular vs. Node

Node and Angular are both trendy open-source JavaScript technologies that are part of the MEAN web development stack and supported to some extent by Google: Angular is mainly developed and maintained by Google, while Node runs on top of the V8 JavaScript engine for Google Chrome. Apart from these superficial similarities, however, the two are quite different.

As mentioned in the introduction, one of the biggest distinctions is the fact that they're intended to run in two different places: Angular is a front-end (client-side) technology, while Node is a back-end (server-side) technology. This difference is indicative of the two technologies' diverging goals and philosophies. Node is a platform and runtime environment for running applications on a server that is intended to provide fast response times to web requests, while Angular is a web development framework for building dynamic websites and web applications. Although Node and Angular frequently work together in harmony (e.g., as part of the MEAN stack), they don't need each other to exist; Angular can cooperate with other server-side platforms, and Node can cooperate with other client-side frameworks.

Final Thoughts

While you'll often see Node and Angular used together for the same web application, and many full-stack web developers are familiar with both technologies, the two are intended for very different purposes. In addition, as Node and Angular have grown, they've been joined by a variety of other popular competing JavaScript web technologies, including Meteor for full-stack web applications and React, Backbone and Ember for front-end development. Rather than get caught up in the trends and hype, however, it's important to thoughtfully evaluate which of the frameworks and platforms are best for your purposes and be open to changing your mind as the world of web development changes.