4 ms·
Mine's only 157 lines: http://eloquentjavascript.net/11_language.html http://eloquentjavascript.net/11_language.html
by marijn 12y ago
Mine's only 157 lines: http://eloquentjavascript.net/11_language.html http://eloquentjavascript.net/11_language.html
- Aissen 12y agoYours is a lisp-like, so much easier to parse; and it doesn't have the nice in-dom ast viewer nor nearly the same number of comments (I compared with http://eloquentjavascript.net/code/chapter/11_language.js http://eloquentjavascript.net/code/chapter/11_language.js).
- V-2 12y agoStill very interesting
- Aissen 12y agoIt's even more interesting because it's part of book. Just setting the expectations, because it's not an apple-to-apple comparison.
- breuleux 12y agoThe AST viewer is not included in the 450 lines, although the comments are. Most of the difference is due to the more sophisticated parser and some extra features like arrays.
- breuleux 12y agoThat's pretty cool :) To be fair, though, the 450 lines include about 120 lines of comments, a configurable full operator precedence parser, syntax for array creation and indexing, range and looping operators, short-circuit logical operators... Most minimal language implementations skimp on syntax because it is irrelevant to a language's expressive power. The point of this exercise, though, was to make one that didn't.
- seivadmas 12y agoHow about 49 lines? https://github.com/samphilipd/the-little-schemer/blob/master/scheme.js https://github.com/samphilipd/the-little-schemer/blob/master... I wrote an implementation of Scheme in Javascript to use as I work through the excellent book 'The Little Schemer'. Turns out you can implement a basic version of the language in just 7 functions. It's Turing complete and you can use the base methods to build any function you need.