JerryScript & IoT.js: Javascript for the IoT by Samsung

The Internet of Things is growing rapidly and analyst firms fairly regularly revise their forecasts on investments in this area in Western Europe. IDC has just delivered a correction and now anticipates spending of 145 billion dollars for the year 2016. These investments include equipment, software, services and connectivity. A success that is undeniable for the next few years, in the next 4 years, the research firm is considering investments close to 290 billion dollars.
The general public is not forgotten with expected spending of $17,6 billion. The use cases most concerned relate to home automation, with sensors for heat, humidity, energy and water consumption.
jerryscript
Signed Samsung, JerryScript is a compact and portable JavaScript interpreter dedicated to microcontrollers. An open-source solution.
JavaScript was popularized on web pages, before investing in new markets, going so far as to find a place on servers, via Node.js.
Samsung now offers a version dedicated to connected objects from the IoT (Internet of Things / Internet of Objects) movement. JerryScript is a JavaScript interpreter capable of running on microcontrollers with few physical resources.
Light
Less than 200 KB will thus be sufficient to store this tool (160 KB in ARM Thumb-2 mode), the RAM requirements being less than 64 KB.
This solution uses bytecode and a virtual machine capable of running it. A classic technique on machines with little RAM, the transformation of JavaScript code into bytecode saves storage space and greatly simplifies the work of the interpreter.
jerryscriptdesign
Portable
Written in C99, JerryScript is particularly portable and can be used in other sectors. For example as an embedded interpreter within a more massive third-party application.
STM32F4 microcontrollers are supported, as well as machines running Linux. Samsung should however soon offer JerryScript on its Artik modules dedicated to the Internet of Things, as well as for other IoT platforms.
 
The goal of the two Samsung projects is obviously to allow JavaScript developers to create applications for the Internet of Things. IoT devices have severe CPU and memory performance constraints. This is what prompted Samsung to design the JerryScript engine to run in less than 64KB of RAM and all of the code can fit in less than 200KB of ROM. Running JavaScript code on JerryScript looks like this:

{
 jerry_init (JERRY_FLAG_ENABLE_LOG);
 char script[] = "print('Hello, World!');"; jerry_parse(script, strlen(script)); jerry_run(); jerry_cleanup(); }

iot.js
The IoT.js platform uses JerryScript to execute JavaScript code and libuv for asynchronous I/O, and allows developers to create IoT services that communicate with each other and with the outside world. IoT.js currently runs on Linux and NuttX – a real-time operating system – and targets Raspberry Pi 2 and an ST board, with plans for other microcontrollers and IoT devices. The API provides functionality for buffers, console, events, GPIO, streams, timers, among others.
The following diagrams show the internal architecture of JavaScript applications that run on IoT.js / JerryScript. And a comparison in case you move the same app into Node.js.
iotjs-arch
iotjs-node
sources:
http://www.silicon.fr/jerryscript-javascript-internet-des-objets-154291.html#hSreWIfFqoi3lIJ9.99
http://www.silicon.fr/145-milliards-de-dollars-dinvestissements-dans-liot-en-2016-151701.html#TxytPR12OSWuwwHP.99
https://www.infoq.com/news/2015/08/iotjs-jerryscript-samsung
Sébastien Berten – President Co-founder @ JS-Republic
[separator type=”” size=”” icon=”star”] [actionbox color=”default” title=”” description=”JS-REPUBLIC is a service company specializing in JavaScript development. We are an approved training center. Find all our technical training on our partner site dedicated to Training” btn_label=”Our training” btn_link=”http://training.ux-republic.com” btn_color=”primary” btn_size=”big” btn_icon=”star” btn_external =”1″]