4 ms·
It's not so much a reduced subset as a kernel language: the full ECMAScript Edition 5 language can be translated down to the kernel language, so in principle th
by dherman 14y ago
It's not so much a reduced subset as a kernel language: the full ECMAScript Edition 5 language can be translated down to the kernel language, so in principle they can actually model the behavior of any program that the language defined by the standard admits.
There have been a few attempts to formalize the semantics of JS, but the lambdaJS approach is the most practical: by factoring out the incidental details (the "syntactic sugar") as a translation ("desugaring") to a kernel language, any work you do on the formal semantics of the language only has to focus on the smaller kernel.
This is also a really practical way to approach building tools for JS, like static analysis: if you design a single desugaring pass as a translation, then you can build a whole bunch of tools on the kernel language. Same idea roughly as the standard compilers approach of translating to an IR.
- knowtheory 14y agoSure, I took it to be akin to the way that coffeescript maps down to JS, they're mapping JS down to LambdaJS. But that said, having read through their blog posts, I was under the impression that their interpreter doesn't in fact support all of the SpiderMonkey test suite, and so, as a practical matter is still only supporting a subset of JS. My attempts to get underscore working have been unsuccessful thus far (the debug info isn't terribly useful, not knowing their codebase).
- dherman 14y agoThat's at least partly because SpiderMonkey supports a superset of the ES5 language, including Mozilla-specific extensions and candidate features for future versions of the standard. Dave
- jpolitz 14y agoIt looks like the λJS has an issue parsing some of the escape sequences in underscore.js; it's a bug in WebBits parser that version uses. Another implementation of the core semantics + desugaring approach, dubbed S5 (https://github.com/brownplt/lambdas5 https://github.com/brownplt/lambdas5), is better engineered and actually uses SpiderMonkey's parser to handle more programs. S5 runs underscore.js without any issues. Do give it a shot if you're still interested in trying things out. Also, it's worth mentioning that S5 handles features of the new ECMAScript 5 specification, like strict mode, getters and setters, and new APIs, that the original λJS simply doesn't handle, so it's a much more complete account of JavaScript.
- knowtheory 14y agoThanks for the info :) I lament that HN has lost its way enough that this thread didn't make it anywhere near the top of the homepage.