February 23rd, 2016

How JavaScript Came To Rule The Internet Of Things

Mobile App Testing Learn tips, techniques and trends for launching great mobile apps Get It Now
Like what you're reading? Subscribe to the weekly newsletter. Subscribe For Free

“To do parallel programming in C, you have to be a stud … And here is this JavaScript thing, it is kind of a built-in feature.”

JavaScript first invaded the Web, the lynchpin to what made browsers functional. Next JavaScript came for the server, installing Node.js on the backend. Later JavaScript arrived on for the apps with React Native building across platforms.

JavaScript is now coming for your things. All of your Internet of Things.

Which seems crazy. Even though it is by far the most-used programming language, most trained computer scientists and software engineers hate JavaScript. Its syntax is funny and it can be overly simple, in an obtusely complex kind of way.

And yet, JavaScript continues to grow. Like the scar tissues that connects two torn joints.

The reason that JavaScript works for the Web is the same reason that it works on the server and will eventually work for the Internet of Things: its prime feature allows for parallel programming, letting certain features run while not inhibiting others. On the server, Node.js is event-driven, which makes it perfect for running fairly simple devices that send data to a Web client and a server.

See also: JavaScript Dominates As The No. 1 Programming Language

JavaScript was built to make Web pages dynamic. To allow websites to gather information or produce dialogue boxes or run ads, scripts or pictures while the rest of the website continued to function. It is this same feature that makes it good on the server and eventually good for the Internet of Things.

“I think that the most encouraging thing from an application point of view that I have seen is the emergence of JavaScript as a programming environment for IoT,” said Michael Richmond, executive director of standards group Open Connectivity Foundation, in an interview with ARC. “Which is, if you are really, really, really thinking about it, is the weirdest thing you can think of.”

Mobile Beta Management Learn the benefits, best practices and toolkits for mobile beta management Get It Now

Everybody Is Using JavaScript For The Internet Of Things

A growing variety of projects have cropped up over the last several years to combine JavaScript and Node.js to the Internet of Things. Node-RED is a visual tool for wiring the Internet of Things built by members of the IBM Technology Services team. The Things System is a system of components and protocols running Node.js. Noduino is a JavaScript and Node.js framework for Arduino controls that also uses HTML5 Web applications and DeviceJS from WigWag is built on top of Google’s V8 JavaScript engine with a real-time JSOn database. Cylon.js is built to control robots and things with JavaScript. The list goes on and on.


Cylon.js mascot.

“If you talk to any professional programmer and say JavaScript, they will go ‘ahh, if you took the keys off my laptop and there them at the wall, that is valid JavaScript syntax. Who would ever program in that crap? It’s not for real programmers, real programmers don’t use JavaScript,’” Richmond said.

Even OCF is using JavaScript protocols in IoTivity. Samsung (another premier member of OCF) uses JavaScript with SmartThings.

See also: What Peace Between Intel And Qualcomm Means For The Internet Of Things

“Javascript was invented to do one particular thing which is [when] you’ve got a webpage and somebody is typing in input and you don’t want the rest of the page to freeze,” Richmond said. “So it has this semantic where you can write something in JavaScript and the rest of the page goes off and does its thing and when that input happens, you’re code gets called back automatically. So there is this event/callback model. That does not exist in old programming languages … they don’t have that.”

Richmond worked at Intel for more than 30 years before becoming the first full-time chairman for the Open Internet Consortium (now OCF) in May 2015. He speaks of software development tactics like an old programmer that has seen many a standards war play out on his watch and has led Intel’s Open Source Technology Center when it first started embracing HTML5 in 2011. If someone like Richmond gets excited about JavaScript in an emerging technology like the Internet of Things, then there is plenty of truth to the trend.

To hear Richmond say it, JavaScript makes the Internet of Things easy:

To do parallel programming in C, you have to be a stud. You have to know what you’re doing. And here is this JavaScript thing, it is kind of a built-in feature. Then you link that with an I/O subsystem where I/O does not black. Now you have a language that matches that semantic. That is what Node.js is. Now any 12-year-old can do parallel programming. It’s like, yeah, of course you are going to use it for IoT. It got mostly used on the server side. But now you have these people from the IT department using Node.js on the server side and you have industrial people using it on the device said.

And you say, you know, what I really want to know is how many times my robot calls over and keep track of that on the server. You can have one guy do that on both ends in JavaScript. All of a sudden all of your integration problems go down. It’s a new way of working.

The Internet of Things is, of course, not easy. Not yet at least. Otherwise things like IoTivity, HomeKit, Google’s suite of IoT tools like Weave, Brillo and Eddystone would not exist.

The Internet of Things is evolving just like the Internet itself did for the last two decades. It’s a little messy and often difficult to see progress as it happens. Standards battles are fought, won or lost and then forgotten when something new comes along. But it appears, for the time being, that JavaScript is going to be central to the growth of the Internet of Things, just like it was with the Web before it.

  • davidjmcclelland

    Good article. Yes JS being asynchronous and lexical is key to its adoption in the areas mentioned. You meant *”does not block” in quote.

  • rwaldron

    Interesting that Noduino was mentioned, despite it being unmaintained and unupdated in over two years. Johnny-Five has a vibrant and _very_ active community of developers—but no mention?

    • DanRowinski

      I was going to put a note on here somewhere along the lines of: “you’re favorite framework or service may not be mentioned, don’t take it personally.”

    • I thought the same thing, Johnny-Five is one of the largest JavaScript Robotics frameworks out there, strange to not get a mention.

  • An0nym0usC0ward

    I think JS’s ascension is caused by something not mentioned in the article: it is one of the few languages providing 80% of all that you need for programming in both structured, OO and functional styles, and the only one doing so while still using a familiar syntax. Sure, it has its quirks, but they’re cheaper to deal with than dealing with languages with a less familiar syntax, for people coming from other mainstream languages, such as Java or C or C++.

  • Ian Zhang

    Asynchronous computing is not parallel computing.