Those of you who have read Wikipedia cover to cover will remember the definition of hybrid vigor. For the rest of you:
Heterosis, hybrid vigor, oroutbreeding enhancementis the improved or increased function of any biological quality in a hybrid offspring. An offspring is heterotic if its traits are enhanced as a result of mixing the genetic contributions of its parents.
Wikipedia, page 69105
The practical upshot of this is that if you take separate, inbred strains of, say, corn and breed them together, you get a great big vigorous plant, hence the name hybrid vigor.
The Moddable SDK, as described in this book, represents the hybrid vigor between embedded and JavaScript development. Using Moddable is a short path to very large amounts of corn.
If youre an embedded developer, you delight in the ability to get close to the metal, to program on tiny, inexpensive devices without the affordances offered by development on large systems. Writing in C/C++ and/or assembly language gives you a great deal of control, but you often struggle with shoehorning functionality into these small devices, wrestle brittle development and debugging environments, and build ad hoc device-specific ways of updating code and managing resources. If the embedded device has a display or is capable of wireless communications, you need to track down the right tools to build, simulate, and test a wide variety of functionality in the absence of a rich underlying OS. A great deal of your energy goes into managing the constraints of these small systems rather than into the applications themselves.
If youre a JavaScript developer, you delight in its productivity, versatility, and ubiquity. The language is forgiving to a novice yet extremely powerful in the hands of a master. Its versatile enough to be used in front-end development as well as back-end infrastructure. Its huge community continually enriches the language and libraries and makes it arguably the most popular language ever. All this versatility and power comes with a price; until now a robust version of JavaScript has not scaled down to the point where it will fit on a small embedded device.
Moddable takes the best of these two strains and blends them together on an emerging class of powerful new microcontrollers. Embedded developers no longer have to regard JavaScript with envious eyes. They now have access to a versatile high-level language that still allows them to stay close to the metal and maintain tight control. JavaScript developers can reach ridiculously inexpensive devices with none of the friction of traditional embedded development, yet still work with affordances present on much larger systems.
Its embarrassingly easy to be productive in the Moddable environment, with its rich SDK for managing secure web connectivity, Wi-Fi, Bluetooth, sound, graphics, user interfaces, and more; its elegant, full-featured debugging; and a wide variety of target hardware that ranges from inexpensive to nearly free.
My day job is investing in technology startups, and as such it pains me to see companies attempting embedded development with blunt tools. Moddable can save developers time and money and produce beautifully polished embedded applications. As an investor, I love tools that reduce risk and make companies more capital-efficient. As an avid maker, I love tools that make making even more fun.
If you develop embedded products, or if youre a hobbyist or even just someone who loves writing code, Moddables hybrid vigor changes the game. Go grow some corn.
Peter Barrett
Introduction
This book is a hands-on guide to writing the software for IoT products. Each chapter is filled with compact, focused examples for you to learn from, study, run, and modify. When you finish this book, youll know the fundamentals of building sophisticated IoT products on low-cost hardware using modern JavaScript.
IoT products differ from traditional products in two ways: they have the ability to run software and they have the ability to communicate. Their communication is often over the internet, but it may be more localfor example, between products on your home Wi-Fi network or with your phone over a Bluetooth connection.
IoT products are often created by adding a microcontroller with Wi-Fi or Bluetooth capabilities to a traditional product. The cost of adding a microcontroller with communication capabilities is about one dollar today and continues to fall. At that price, nearly every product is going to be an IoT productnot just televisions and thermostats but also light bulbs, light switches, electric wall plugs, door locks, window shades, garage door openers, ceiling fans, rice cookers, refrigerators, and more.
The code in this book runs on the ESP32 and ESP8266 microcontrollers from Espressif, which offer remarkable power at an unprecedented cost. Unsurprisingly, theyre widely deployed in IoT products and extremely popular with makers and hobbyists. What youll learn in this book isnt limited to these microcontrollers, however; it can be applied to a growing number of microcontrollers from manufacturers including Nordic, Qualcomm, and Silicon Labs.