Small enough for a microcontroller
Start-up RAM for hello world on x86 is 78 kB by default and 27 kB in low-memory builds.
Source:Duktape, home page
Duktape is the classic embeddable JavaScript engine in C: three files, a stack API and a footprint that fits a microcontroller. tinyscript is embedded from C too. Here is where they part.
A device with kilobytes of RAM still wants a scripting language its users already know.
Duktape is portable C focused on a small footprint. It runs on devices with 160 kB of flash and 64 kB of RAM, and a low-memory build says hello in 27 kB.
Its last release, 2.7.0, came in 2022, and its master branch is moving to 3.x. For ES5 on small hardware, it is still the reference.
Start-up RAM for hello world on x86 is 78 kB by default and 27 kB in low-memory builds.
Source:Duktape, home page
A timeout checked every few hundred thousand instructions is not a bound on hostile code.
Duktape's own sandboxing guide says its execution timeout is not reliable against deliberately malicious code, and is not checked inside built-ins. It calls its sandboxing not yet a complete solution.
tinyscript counts exact fuel, built-ins included, and a call that runs out continues later. It targets modern JavaScript with TypeScript hints, where Duktape stops near ES5.
| Question | Duktape | tinyscript |
|---|---|---|
| Language | ES5.1, parts of ES2015 and ES2016 | Modern JavaScript; 62.9% of test262 |
| Footprint | 27 to 78 kB for hello world | About 166 KB of stacks per realm |
| Bounding a call | A coarse timeout that throws | Exact fuel; the call continues |
| Untrusted code | Not a complete solution, by its own guide | Designed for it |
Most readers need one answer: which engine to try first.