Live data from Hacker News

List of languages that compile to JS

github.com

41–50 of 57 posts

Re: List of languages that compile to JS

#42
post #20

Am I the only one who just plain doesn't understand the value these tools provide? From my perspective, why not just _write_ javascript? Seems ridiculous. I mean, they're fun and all, but no one sets out to do a project of meaning or scale and chooses these tools, do they?

I've switched over to CoffeeScript for all projects where I get to choose. It's an all around better language than js if you tend towards the functional side.

Iteration/comprehensions work like they should[1], destructuring simplifies extraction, there's a prototype binding construct in the language, less line noise, and everything is an expression. I also happen to like indent-significant languages and think it's a great DSL language.

I could certainly produce the same code writing in JS, but what would the advantage be? I'm already doing a build step for combo/minification and if not, a --watch compile gives roughly the same workflow as raw JS. I have to search for a snippet of text rather than going to a line number when I'm debugging, but I think the coding gains/cleanliness is worth the slightly increased debugging effort.

[1] With one gripe, `y = x + 1 for x in 0...10` got changed in August to match up with `z = x if x % 2` and friends (it was special cased) so y is now 10 instead of the array 1..10 and you have to wrap the comprehension in parens.

Re: List of languages that compile to JS

#43
post #38
post #18

Earlier quoted context omitted.

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.

Re: List of languages that compile to JS

#44
post #20

Am I the only one who just plain doesn't understand the value these tools provide? From my perspective, why not just _write_ javascript? Seems ridiculous. I mean, they're fun and all, but no one sets out to do a project of meaning or scale and chooses these tools, do they?

Most projects do just use straight JavaScript which is a big problem. JavaScript does all the wrong things by default. "for in" loops and "==" comparisons are a couple big offenders, that often appear to do the right thing (but fail later in unexpected ways). Any of these compilers worth their salt will limit their output to properly formed loops and comparisons and otherwise cross-browser compatible code, etc, saving you from a great deal of pain.

Re: List of languages that compile to JS

#45
post #12
post #10

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.

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.

Re: List of languages that compile to JS

#46
post #20

Am I the only one who just plain doesn't understand the value these tools provide? From my perspective, why not just _write_ javascript? Seems ridiculous. I mean, they're fun and all, but no one sets out to do a project of meaning or scale and chooses these tools, do they?

Are you serious? GWT is used in a lot of large, commercial projects. And of course by Google itself which also isn't exactly small-scale :)

Re: List of languages that compile to JS

#47
post #40
post #14

How about a list of languages that compile to PHP? haXe is the only mature one I know about.

I just so happen to have this list. http://haxe.org/doc http://github.com/scriptor/pharen http://www.mathgladiator.com/projects/kira/ http://www.scriptol.net/ http://sunra.nachtkabarett.com/ http://users.xelent.net/mlewis/tellpdf.php?seid=12457c30afd9... http://ialexi.com/portfolio/original-works/components/quirk/ And a somewhat related list: https://github.com/ryantenney/php7 Hacking the PHP compiler and standard li…

Hey, creator of Pharen here. I've been procrastinating on another release for a while but still developing it. If anyone wants to check it out there is a better site over at http://scriptor.github.com/pharen.

Re: List of languages that compile to JS

#48

Any tools that work in the opposite direction? ( e.g., JS -> C )

Rhino does JS -> Java bytecode internally but I don't think you can grab those classes and execute them outside Rhino.

A full compiler would of course always have the problem of dynamically generated JS, i.e eval().

Re: List of languages that compile to JS

#49
post #12
post #10

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.

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.

"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.

Re: List of languages that compile to JS

#50
For those that think JavaScript makes a good VM format for the web, I've written a couple blog posts recently on this topic:

http://chadaustin.me/2011/01/native-client-is-widely-misunde...

http://chadaustin.me/2011/01/digging-into-javascript-perform...

Basically, we need another 10x to 30x in performance for JavaScript to match native code performance...

Post reply on HN