Tuesday, November 25, 2014

Why JavaScript and the Internet of Things?

JavaScript has proven itself worthy on both the client and server side world of web applications, but why does it have potential in the ever expanding Internet of Things (IoT)?


Over the past two years, I've covered the growing amount of technology that JavaScript developers can get involved with in my JavaScript Beyond the Web and JavaScript Beyond the Web in 2014 articles here at SitePoint, as well as in various presentations at conferences and meetups. There is a huge level of enthusiasm for JavaScript and the IoT which is great (nice to know I'm not alone in this passion), but many developers ask one very reasonable question - why JavaScript? What are the advantages of using JavaScript with the Internet of Things? I decided it'd be useful to explore this topic in a bit more detail and put a lot of my thoughts down in writing.


Much of the Internet already speaks JavaScript


The whole idea of the Internet of Things is a simple one. We want to connect a range of new devices to the Internet so they can speak to servers and devices around the world. While the next big IoT device that changes the world is likely to be something we don't see coming (that's just the nature of technology right?), we know the technology pillars that it is likely to stand upon - connecting devices to web APIs in new and unexpected ways to (hopefully) benefit society. What language can our web pages and web apps speak right now? JavaScript. It makes sense to extend the same standard platform to the Internet of Things, communicating to a larger range of devices using that same language.


We can share functionality


JavaScript's ability to be everywhere is huge. When connecting up a network of devices to your server, having them all speak the same language makes life easier. If you've got a large number of different connected devices that all understand JavaScript and you've got a server running Node.js, you've reduced complexity and can share functions that do the similar functions across different devices. Say you have business logic in your app which you need to reuse for different devices and server responses. With JavaScript, you can reuse the same functions for calls to different devices with ease - build once and reuse.


Existing libraries, plugins, and APIs


JavaScript has a range of existing libraries, plugins, and APIs, many of which can be utilized in the Internet of Things. While the jQuery plugins of old aren't the most reusable for non-client side code, there is an evolving world of npm modules in JavaScript that are reusable for a multitude of solutions on the client, server, and beyond.


JavaScript utility libraries like Underscore.js, lodash, traverse and Async can be perfect to use in a range of common situations across different devices. There are some very powerful functions in the above modules that would be useful to IoT projects.


Another example of a great JavaScript module that is perfect for IoT is Socket.io - a module providing real time event based communication across multiple devices.


Continue reading %Why JavaScript and the Internet of Things?%




by Patrick Catanzariti via SitePoint

No comments:

Post a Comment