Compatibility

This section discussed Duktape compatibility with Ecmascript dialects, extensions, frameworks, and test suites.

Ecmascript E5 / E5.1

The main compatibility goal of Duktape is to be Ecmascript E5/E5.1 compatible. Current level of compatibility should be quite high.

Ecmascript E6

Duktape borrows a few features from the current Ecmascript E6 draft, but generally there is no compatibility with E6 yet.

Ecmascript E3

There is no effort to maintain Ecmascript E3 compatibility, other than required by the E5/E5.1 specification.

CoffeeScript

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);

Coco

Like CoffeeScript, Coco compiles to Javascript. There are no known issues.

LiveScript

Like CoffeeScript, LiveScript compiles to Javascript. There are no known issues.

Underscore.js

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

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

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. Also, because there is not typed array support yet, no "heap object" can be provided.

Emscripten

Emscripten compiles C/C++ into Javascript. Duktape is currently Emscripten compatible except for:

Performance is somewhat limited as Duktape is an interpreted engine. Lack of typed array support also forces Emscripten to use a much slower model for emulating application memory. Large programs may fail due to Duktape compiler running out of virtual registers. See emscripten-status.rst for current compatibility status.

Duktape itself compiles with Emscripten, and it is possible to run Duktape inside a web page for instance, see Dukweb REPL.

Lua.js

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

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 = {};