Re:List of languages that compile to JS
by msy on Thursday January 06, 2011 @09:39AM
(#2075421)
I note that doesn't read 'good JS' or 'fast JS'. You can put me in a tutu but I won't be a prima ballerina.
[ Parent
| on HN ]
I'm not sure about all of them but CoffeeScript emits good, portable, fast JS.
CoffeeScript is largely an alternate syntax to JS with a couple of macros added on. That's more like the prima ballerina changing from her pajamas into a tutu.
Indeed, they don't go as far as some of the other ones, but it's still a language that compiles down to JS. It's nice that it's a strict superset of JS (iirc anyway) but that alone doesn't mean that it's impossible to produce slow or bloated JS.
Of course any language that does a lot more than CS is going to be slower, e.g. Objective-J's object system providing method-missing functionality and a whack of other features not found natively in JS.
Coffeescript I'm familiar with and yes, is very nice indeed. It's some of the others I'd be more concerned about.
Re:List of languages that compile to JS
by stcredzero on Thursday January 06, 2011 @12:35PM
(#2076231)
If we can enable source pointers for debugging, then "good" matters less -- about as much as how "good" x86 ISA is.
Define good in this context. I'm inclined to say that if it doesn't have cross-browser bugs and it's fast, then it's good. The output being readable to human programmers probably shouldn't be a goal when JS is being used as a compiler target.
Agreed in principle, but readability still matters a great deal for debugging. There's vastly more browser tool support for JS (e.g. Firebug) than for languages targeting JS. These tools get harder to take advantage of as one's compiled JS gets less readable.
Sometimes I think the holy grail for what we do would be a Slime-like REPL in the web browser that speaks Parenscript, maps to source code, and had full debugging support. In the meantime, though, things like Firebug are indispensable.
"The output being readable to human programmers probably shouldn't be a goal when JS is being used as a compiler target."
Everyone says that until they have to debug the generated JavaScript in IE.
I'd define good as it takes full advantage of the javascript language and produces & can be used to create structures optimised for javascript, not the language it was written in.
Re:List of languages that compile to JS
by stcredzero on Thursday January 06, 2011 @12:36PM
(#2076241)
This is why I think it's better to reduce the context-switch between server and browser and not eliminate it. There's going to be a context-switch there no matter what you do, so there's no sense in paying such high prices to try to eliminate it.