We can share functionality
Existing libraries, plugins, and APIs
Rather than needing to build a range of new libraries and plugins for some of this basic stuff, we can reuse and further develop existing solutions in use around the web today for entirely new implementations.
Node has the “event loop.” While it’s not really in the scope of this article to explain this in detail, it allows us to execute a number of tasks without needing to wait for each task to be finished before we move to the next one. We can receive and respond to events, then wait for a callback from each event that notifies us once it is complete. This means we can respond to events as they happen, juggling many tasks simultaneously as they come in. Multiple devices can also respond to the same events. This works nicely in the Internet of Things.
Let’s imagine you’ve got an Internet enabled home with a smart hot tub that’s filling up with water as you walk home. It’s a rather random example, but lets go with it! Your phone signals that you’re about five minutes away from arriving home. The tub sees this event and starts filling with water automatically. You feel like catching up on the latest episodes of Gotham too, so you open up a mobile app and select to download and play the latest episodes from the season on a big display above your bathroom’s hot tub when you arrive. Yes – this is a pretty fancy hot tub. The tub receives this event and starts to look up what episodes of the show you’ve watched.
Suddenly, you realize you forgot to pick up some milk on the way home. As with all joyous technological breakthroughs, your to-do app is still prone to user error. You had set the reminder to get milk for tomorrow by accident and have had to rely on that primitive human brain at the last minute! You turn back around to head to the nearest supermarket.
Your phone notices the change in direction and signals that you are no longer on your way home. The tub sees this event and stops filling up with water for now. Rather than waiting until it has retrieved the latest Gotham episode list for you before responding to this change, the tub can instantly deal with this request and stop filling up with water. Once the list of unseen episodes has been found, the tub then sees that we’ve got that list and downloads the next episode as you journey for some milk. Once you’re on your way back home again, your phone signals this once more. The tub sees this event and turns the water back on while still finishing its download. You get home with a hot tub ready and Gotham playing the moment you step into the bathroom.
Every language has its idiosyncrasies and working with different languages on different devices means dealing with these. Often you’ve got to convert the data into formats that the other languages require, then back again if passing it in the opposite direction. Some languages handle this better than others and there are usually documented ways to pass data across, so it’s not impossible to do. However wouldn’t it be nice if you didn’t need to worry too much about this? Imagine all of your devices understanding data types in the same way.
An incredible community
It has already begun
These are all my own opinions, but I’d love to hear your thoughts too in the comments. Are there advantages I’ve missed? Things I could have said better? Have you had any experience with JS and the IoT so far that you’d like to share?
Thanks to Phill Farrugia and Jeremy Brown for their thoughts when I put out the question on Twitter.