JavaScript Engines

Google's V8

Mozilla's SpiderMonkey

Duktape

Duktape is an embeddable Javascript engine, with a focus on portability and compact footprint.

Duktape is easy to integrate into a C/C++ project: add duktape.c, duktape.h, and duk_config.h to your build, and use the Duktape API to call ECMAScript functions from C code and vice versa.

-- https://duktape.org/

tcl-duktape的示例代码,来自 https://wiki.tcl-lang.org/page/tcl-duktape

#!/usr/bin/env tclsh
package require duktape
package require duktape::oo

set duktapeObj [::duktape::oo::Duktape new]
$duktapeObj jsproc ::add {{a 0 number} {b 0 number}} {
    return a + b;
}
puts [add 1 2]
$duktapeObj jsmethod cos {{deg 0 number}} {
    return Math.cos(deg * Math.PI / 180);
}
puts [$duktapeObj cos 360]
$duktapeObj destroy

JSI - Javascript interpreter + embedded Web-server

SEE - Simple ECMAScript Engine