The Case for JavaScript in Embedded Devices

An embedded device is a type of ‘thing’ that has just enough memory to do its job. Smart embedded devices are often referred to as the internet of things (IoT). Dumb embedded devices such as washing machines are not usually connected to the internet. Smart and dumb embedded devices alike tend only run a single application.

Many developers argue that, from a programming perspective, native code is much more suitable to embedded devices. Native Code such as C or C++ generally runs much faster and smaller on embedded devices. Also known as managed code, native code controls the resources needed for your device to run. You can easily allocate memory (RAM, ROM) by running such tasks as ‘garbage collection’. Developers argue that JavaScript, is not, appropriate for embedded devices because it is not native code. I would like to make a case for why IoT companies should strongly consider relying on JavaScript.

  • The community. Many developers and hobbyists know JavaScript already.
  • Write once, deploy everywhere. Reuse the same JS code on desktop, cloud, and mobile environments, along with IoT devices.
  • Everyone loves JSON. JavaScript Object Notation, JSON, is a common format used to exchange data. between these systems, which reduces the overhead of marshaling boilerplate.
  • Browser heaven. Save time and money by simulating device behaviour in your browser with JavaScript. Their ashell feature allows you to upload new JavaScript to run in development mode — without flashing.
  • And finally, the Zephyr project!!! It’s as easy as pie. Just compile the Zephyr OS with your application and flash it to the device. The folks at Zephyr are also developing a browser-based integrated development environment (IDE). A JS IDE for embedded devices would allow us to develop entirely in the browser with a simulator. Zephyr’s kernel requires only 8 kilobytes of RAM. The core supports IPv4, IPv6, Bluetooth 4, Bluetooth Low Energy (BLE), IEEE 802.15.4 , 6LoWPAN, CoAP, and DTLS. The drivers exists for GPIO, serial buses I 2 C and SPI.

Here are a few caveats about JavaScript, to be fair:

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.