// the find
haileys/twostroke
A Javascript implementation in Ruby!
Twostroke is a JavaScript interpreter written in pure Ruby. It has a hand-written parser, a compiler to its own bytecode format (TSASM), and a VM that runs that bytecode. It is most useful to people who want to see how a JS engine fits together, not to anyone who needs fast or complete JavaScript execution.
- The pipeline is split into distinct stages: lexer, parser, one AST class per node type, a TSASM compiler, then a VM. Each stage can be read and tested on its own, which is clearer than the usual toy interpreter that mixes parsing and evaluation.
- It runs Underscore.js's own test suite unmodified (minus the DOM cases) and parts of MooTools' suite. Passing a real library's tests is a much better signal than a hand-picked set of snippets.
- Some of the built-in library (array.js, object.js, number.js, etc.js) is written in JavaScript instead of Ruby, so those methods go through the same interpreter path as user code.
- The last push was July 2015. Nothing in the README suggests ES2015+ syntax (let, classes, arrow functions) is handled, and the Ruby versions it targeted are long out of support, so expect to fix the build before running it.
- The README is a demo: a REPL GIF and a test-run screenshot. There are no benchmarks, no list of unsupported features, and no conformance numbers, so it is hard to tell how much of the language actually works.
- A bytecode VM written in Ruby will be slow, and the README says nothing about performance. The standard library is described as minimal, so anything the Underscore and MooTools suites do not exercise is probably missing or partial.