The elk project develops a compact JavaScript engine for microcontrollers

A new release of the elk 2.0.9 JavaScript engine is available, aimed at use in systems with limited resources, such as microcontrollers, including ESP32 and Arduino Nano boards with 2 KB of RAM and 30 KB of Flash. The provided virtual machine requires 100 bytes of memory and 20 KB of storage space. The project code is written in C language and distributed under the GPLv2 license. To build the project, a C compiler is enough - no additional dependencies are used. The project is being developed by the developers of the Mongoose OS operating system for IoT devices, the mJS JavaScript engine, and the Mongoose embedded web server (used in products from companies such as Siemens, Schneider Electric, Broadcom, Bosch, Google, Samsung, and Qualcomm).

The main purpose of Elk is to create firmware for microcontrollers in JavaScript that perform various automation tasks. The engine is also suitable for embedding JavaScript handlers in C/C++ applications. To use the engine in your code, just place the elk.c file in the source tree, include the elk.h header file, and use the js_eval call. It is allowed to call functions defined in C/C++ code from JavaScript scripts, and vice versa. JavaScript code is executed in an environment that is protected and isolated from the main code using an interpreter that does not generate bytecode and does not use dynamic memory allocation.

Elk implements a small but sufficient subset of the Ecmascript 6 specification, but sufficient for creating working scenarios. In particular, it supports a basic set of operators and types, but does not support arrays, prototypes, this, new and delete expressions. Instead of var and const, it is proposed to use let, and instead of do, switch and for - while. No standard library provided, ie. there are no such Date, Regexp, Function, String and Number objects.

Source: opennet.ru

Add a comment