// the find
cesanta/mjs
Embedded JavaScript engine for C/C++
mJS is a minimal JavaScript engine written in C, designed to run on microcontrollers with as little as 50KB flash and 1KB RAM. It implements a strict ES6 subset and is the scripting layer inside MongooseOS. If you want user-configurable logic on an ESP32 without recompiling firmware, this is the kind of thing you reach for.
The FFI story is genuinely good — calling an existing C function requires no glue code, just a string like `ffi('void foo(int)')`, and the symbol resolver pattern means you can control exactly which symbols are exposed. The single-file amalgam (`mjs.c` + `mjs.h`) makes integration trivial: drop two files into your project and compile. The byte-string model for strings is the right call for embedded — you can shove raw binary data through without encoding overhead. The `s2o` struct-to-object helper with field descriptors is a practical solution to the usually-painful problem of surfacing C structs to a scripting layer.
The GPLv2 license is the elephant in the room — any commercial firmware that ships with mJS has to either open-source everything or buy a commercial license from Cesanta, which is a real cost that projects discover late. The FFI trampoline caps out at 6 32-bit or 2 64-bit arguments and has no support for struct-by-value arguments, so anything non-trivial needs a C wrapper anyway. The project is effectively unmaintained outside of MongooseOS — the last meaningful commits are years old, issues pile up unanswered, and the `src/common` directory is clearly a snapshot of a larger Cesanta monorepo rather than code maintained for this project specifically. No closures, no promises, no arrow functions, and no standard library means you're writing JS that looks nothing like JS — developers expecting to reuse npm-style patterns will be confused.