tinyscript and Duktape

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.

Skip to the verdictCompare every engine

What Duktape does well

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.

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

Where tinyscript differs

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.

QuestionDuktapetinyscript
LanguageES5.1, parts of ES2015 and ES2016Modern JavaScript; 62.9% of test262
Footprint27 to 78 kB for hello worldAbout 166 KB of stacks per realm
Bounding a callA coarse timeout that throwsExact fuel; the call continues
Untrusted codeNot a complete solution, by its own guideDesigned for it

Which one to choose

Most readers need one answer: which engine to try first.

  • Use Duktape whenyour device has kilobytes of RAM, your scripts are ES5 and you trust them.
  • Use tinyscript whenyou run modern JavaScript or TypeScript from people you don't trust, and need exact bounds.

Visit DuktapeCompare every engine