August 21, 2015

JavaScript: The Perfect Language for the Internet of Things (IoT)

by Jscrambler


JavaScript: Love it or hate it, it’s a popular programming language for many, mainly because it’s so incredibly easy to learn. And if you’re a web developer, it’s almost a requirement of the job to have a working knowledge of JavaScript.

Speaking of the web, JavaScript’s reputation for providing users with beautiful, interactive websites isn’t where its usefulness ends. Nowadays, it’s also used to create mobile applications, cross-platform desktop software, and thanks to Node.js, it’s even capable of creating and running servers and databases!

Given JavaScript’s ubiquitous nature [1], it’s only natural that it would be considered as a fit language in this new “Internet of Things” or IoT [2], a term coined in 1999 by British entrepreneur Kevin Ashton.

Let’s take a look at what the IoT is, and let’s look at the role JavaScript will play in it, if any.

What is the Internet of Things?

Up until recently, most of the information in “the cloud” was human-consumable; the information it contained has been accessed by, and been about, people.

The goal of the IoT is to create a network of “things” — electronic devices, sensors, and even people themselves — that not only has access to this wealth of information, but is also capable of communicating with it and each other.

Supporters of this movement often cite many benefits, a few of which include improved automation in nearly every industrial field, improved economy, lower pollution, and so on. In other words, the main goal is an improved quality of life for all.

What is JavaScript’s Role in the Internet of Things?

You don’t have to be a die-hard JavaScript fanatic to appreciate the many benefits that JavaScript has to offer developers when it comes to the IoT.

JavaScript is easy to learn. JavaScript is an incredibly easy programming language to learn, so it’s easy to get started quickly with minimal knowledge. In fact, if you’re tech-savvy, it’s conceivable to pick up the basics over the weekend.

Plus, there’s also virtually no start-up. If you have a web browser, you have what you need to begin learning JavaScript. The ease of startup means that entry-level developers can get instant feedback while they’re programming, really helpful for those who learn by doing.

JavaScript is already a common language across the Internet. JavaScript is already a common language across the Internet, so it only makes sense to include this language in devices that will become part of it.

There is a huge community of developers. JavaScript already has a huge community of developers who contribute to the language. And there are literally thousands of resources — YouTube videos, articles, tutorials, and even entire websites — devoted to improving people’s understanding of the language.

Its event-driven architecture fits perfectly with how the world operates. We live in an event-driven world. We act and react to different events in our daily lives, and interestingly, this is how JavaScript operates. This event-driven modality is also more efficient when it comes to sensors — and for battery life and CPU usage.

JavaScript Versus C for Embedded Systems

Regardless of the obvious benefits, there is still, understandably, some debate as to whether JavaScript is really up to the task. Let’s take a look at a comparison between JavaScript, the language of the Internet, and C, the standard go-to language for embedded systems programming.

JavaScript: JavaScript is a high-level language. While this usually means that it’s more human-readable and therefore more user-friendly, the downside is that this can also make it somewhat slower. Being slower definitely means that it may not be suitable for situations where timing and speed are critical.
With that said, however, if speed is a requirement, Peter Hoddie [3] says that using a JIT (Just-In-Time) compiler or using asm.js, which is an optimized subset of JavaScript, may help get that performance boost you need. While this does require additional memory on the microcontroller itself, new lines of microcontroller boards are coming out that are actually designed with this in mind, giving developers the best of both worlds.
JavaScript’s event-driven architecture is also perfect for listening and reacting to input and output events like button presses and information received from sensors. Another huge benefit is the drastically decreased power consumption and CPU usage, an extremely important facet considering the small size of microcontrollers these days.

C: Typically, C is the go-to language for embedded systems programming. The main reason is that C is a low-level language, meaning that, although it’s still in a human-readable from, it’s much closer to machine language than, say, JavaScript. This proximity to machine language makes it extremely fast, efficient and reliable. There are some disadvantages, though. The learning curve is steeper; it’s not as easy of a language to learn as JavaScript. This may not be a huge block to avid developers, but for hobbyists, it can play a huge role in whether or not a project gets completed.

The Internet of Things is Already Here

If you’ve been wanting to start tinkering with some user-friendly electronics — and if you don’t feel like learning a complicated language to do so — you’re in luck! Here are some of the more popular JavaScript-enabled development boards to help get you started.

Espruino [4]

The Espruino is a small microcontroller that runs JavaScript. It has very little power draw, boasting a battery life of up to a year. It doesn’t require a complicated IDE; all you really need is a terminal. The best part is that, depending on the needs of your device, you can even compile your JavaScript code into C! Unfortunately, there is only limited support for that at the moment.

Tessel 2 [5]

The Tessel 2 is a development board that comes with integrated wi-fi, an ethernet port, two USB ports, and two Tessel module ports. Each Tessel module has a companion source library downloadable via the Node Package Manager, and there are plenty of tutorials and instructions available online to get you up and running quickly.

Kinoma Create [6]

The Kinoma Create, dubbed the “JavaScript powered Internet of Things construction kit,” is a full-featured prototyping tool with tons of plug-and-play capabilities — all right out of the box! Some of the more attractive features include a touch screen, wi-fi and bluetooth connectivity, and a micro-SD slot.

Time to Get Started

JavaScript for embedded systems is still in its infancy, but we suspect that some major advancements are on the horizon. If you’re a hobbyist or if you’re looking to build out that awesome prototype you’ve been dreaming of, JavaScript is a great way to get your feet wet, learn a thing or two — and have some fun doing it!


  1. Why JavaScript is the Future of Programming
  2. The internet of things is revolutionising our lives, but standards are a must
  3. JavaScript for embedded devices
  4. Espruino
  5. Tessel
  6. Kinoma