STK-node

Pages
Contributors: D___Run___
Favorited Favorite 0

What is Node.js and Johnny-Five?

What is Node.js?

node logo

Node.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. The Node.js package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Basically, Node.js is the ability and environment to run JavaScript on the server side (hardware) of a project rather than in a browser. This enables you to interact with things you weren't normally able to, such as the file system, launch processes (programs) or your operating system.

Node.js is super modular, which means that it is made up of a bunch of puzzle pieces called modules. Being so modular is great because it allows you to install the software that you really need, rather than a bunch of stuff that you may or may not use in the end.

npm logo

Node.js has a huge community of developers who create and use a slew of third-party modules housed in NPM, which is the Node Package Manager. You will be using npm a lot if you are working through this guide; it will be your source of modules to work with a number of APIs and enable you to get different services to talk to your hardware. Speaking of NPM and modules, you will be interacting with your RedBoard by using the Johhny-Five module and installing it through NPM!

What is Johnny-Five?

J5 logo

Johnny-Five is the JavaScript Robotics and IoT Platform. Released by Bocoup in 2012, Johnny-Five is maintained by a community of passionate software developers and hardware engineers. More than 75 developers have made contributions toward building a robust, extensible and composable ecosystem.

Essentially, Johnny-Five (J5) enables JavaScript programmers to develop around embedded development boards such as an Arduino, Raspberry Pi or Tessel 2. Johnny-Five supports more than X different development boards for use in robotics, IoT and other hardware interactions.

J5 is easily installed as a Node.js module and, just like the rest of Node, supports asynchronous programming. This means that it is event-driven, so it reduces latency and "blocking code," which is to say that you no longer have to worry about a certain process taking so long that it blocks another piece of code.

Why JavaScript and Hardware?

With the advent of Node.js, JavaScript no longer just controls the functionality of the web on the user end of things, but also resides on the server, or back end. It doesn't take too much mental strain to extend that logic to small single-board computers and being able to control their inputs and outputs.

The real strength of using JavaScript with hardware falls under the idea that a developer no longer needs to jump from the language of the web to a hardware language such as C or Arduino and make the two talk to one another (not an easy task). If a developer can stay in a single language and even in the same file the whole time, development becomes faster and more streamlined, and the barrier to entry for applications around IoT becomes lower. In fact, the file that you would use to control your hardware and serve a web interface is the same! This guide will highlight this strength. In each experiment there is an Exploring Node.js section where we will extend the experiment with a module that incorporates a higher degree of connectivity and functionality.

The time to Awesome is much, much shorter!