This section discussed Duktape compatibility with ECMAScript dialects, extensions, frameworks, and test suites.
The main compatibility goal of Duktape is to be ECMAScript E5/E5.1 compatible. However, ES5 feature semantics are updated to ES2015 (or later) where incompatible changes have been made in newer specification versions. Current level of compatibility should be quite high.
Duktape implements some features from ECMAScript 2015 (E6), but generally there is no compatibility with E6 yet.
Duktape implements some features from ECMAScript 2016 (E7), but generally there is no compatibility with E7 yet.
There is no effort to maintain ECMAScript E3 compatibility, other than required by the E5/E5.1 specification.
CoffeeScript compiles to JavaScript which should be compatible with Duktape. There are no known compatibility issues.
Some CoffeeScript examples are included in the distributable. Simply
run make
in examples/coffee/
. For instance,
hello.coffee
:
print 'Hello world!' print 'version: ' + Duktape.version
compiles to:
(function() { print('Hello world!'); print('version: ' + Duktape.version); }).call(this);
Like CoffeeScript, Coco compiles to Javascript. There are no known issues.
Like CoffeeScript, LiveScript compiles to Javascript. There are no known issues.
TypeScript compiles to Javascript. There are no known issues with compiling TypeScript using the Microsoft TypeScript compiler (in the ES5/CommonJS mode) and running the resulting Javascript using Duktape. It's also possible to run the TypeScript compiler with Duktape.
Underscore.js provides a lot of useful utilities to plain ECMAScript. Duktape passes almost all of Underscore's test cases, see underscore-status.rst for current compatibility status.
test262 is a test suite for testing E5.1 compatibility, although it includes also tests outside of standard E5.1. Duktape passes almost all of test262 cases, see test262-status.rst for current compatibility status.
asm.js is a
"strict subset of JavaScript that can be used as a low-level, efficient
target language for compilers". As a subset of JavaScript, functions using
asm.js type annotations should be fully compatible with Duktape. However,
Duktape has no specific support for asm.js and won't optimize asm.js code.
In fact, asm.js code will generate unnecessary bytecode and execute slower
than normal ECMAScript code. The "use asm"
directive specified
by asm.js is ignored by Duktape.
Emscripten compiles C/C++ into Javascript. Duktape is currently (as of Duktape 1.5.0) Emscripten compatible and supports ES2015 TypedArray which allows Emscripten fastcomp to be used.
Large programs may fail due to Duktape compiler running out of virtual registers, and performance is somewhat limited as Duktape is an interpreted engine. See emscripten-status.rst for current compatibility status.
Because Duktape itself compiles with Emscripten, it is possible to run Duktape inside a web page for instance, see Dukweb REPL.
lua.js translates Lua
code to Javascript. There are no known issues in running the generated
Javascript, except that Duktape doesn't provide console.log
which lua.js expects. This is easy to remedy, e.g. by prepending the
following:
console = { log: function() { print(Array.prototype.join.call(arguments, ' ')); } };
JS-Interpreter
interprets Javascript in Javascript. JS-Interpreter works with Duktape,
except that Duktape doesn't provide window
which JS-Interpreter
expects. This can be fixed by prepending:
window = {};