Re:A programming language in 450 lines of JavaScript
by marijn on Tuesday November 04, 2014 @05:11AM
(#8555827)
Mine's only 157 lines: http://eloquentjavascript.net/11_language.html
[ Parent
| on HN ]
Re:A programming language in 450 lines of JavaScript
by breuleux on Tuesday November 04, 2014 @12:43PM
(#8557868)
That'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.
Re:A programming language in 450 lines of JavaScript
by Aissen on Tuesday November 04, 2014 @05:49AM
(#8555935)
Yours 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).
Re:A programming language in 450 lines of JavaScript
by V-2 on Tuesday November 04, 2014 @09:04AM
(#8556506)
Still very interesting
Re:A programming language in 450 lines of JavaScript
by Aissen on Tuesday November 04, 2014 @10:00AM
(#8556767)
It's even more interesting because it's part of book. Just setting the expectations, because it's not an apple-to-apple comparison.
Re:A programming language in 450 lines of JavaScript
by breuleux on Tuesday November 04, 2014 @12:49PM
(#8557914)
The 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.
Re:A programming language in 450 lines of JavaScript
by seivadmas on Tuesday November 04, 2014 @02:19PM
(#8558474)
How about 49 lines?
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.