List of Languages that Compile to JS
github.com
github.com
I was searching like mad for a coffeescript + operator overloading and classes with private/protected methods. In my desperate search I started to make a list with languages that compile to JS. Then - an idea came to me. How about I put this in the coffeescript wiki, post it on Hacker News then people will crowdsource it. It worked like mad, in an instant people were adding projects and I was organizing it.
Now I see people making sites/communities out of it. Small world. I guess it's a topic of interest.
PS
Crowd-sourcing is an amazing experience.
1. commit 8a0bae391e5711bce233ccac756d2b80070868da in CS wiki
2. Previous discussion in my original thread http://news.ycombinator.com/item?id=2075111I'm particularly eager to learn how IcedCoffeeScript has changes since then. I'm starting a rather big CoffeeScript/Node.js project and I can't decide whether to go with IcedCoffeeScript (I love its simplicity), or go the 'async.js' way... If anyone has used both Iced and async, I'd be more than thankful if they could share their experience (I Would've asked this question on StackOverflow, but I'm sure it'll be closed within 5 minutes as not a real question or something like that).
It might also be worth looking into Common Node (https://github.com/olegp/common-node) that I'm working on which provides a higher level abstraction: https://gist.github.com/1447709
One thing I forgot to mention about async.js: It's downright disgusting when you try to use it with CoffeeScript, so even though it's a mature, well-architectured piece of framework, I don't like to use it with CoffeeScript...
async.waterfall [
(callback) ->
callback null, "one", "two"
(arg1, arg2, callback) ->
callback null, "three"
(arg1, callback) ->
callback null, "done"
]
just doesn't make much sense to me. I just don't like the way it looks.(code snippet from https://groups.google.com/group/coffeescript/browse_thread/t... )
We wanted to create a cross platform development that could target iOS, Android and other mobile platforms. We started the project about 2 years ago, and saw a few key developments in the JavaScript space.
1. HTML5: the extensions did a lot to move it from a web scripting language to something that could be used for real applications. The Cache Manifest allowed the developer to specify a list of files to be stored on the device, so the app could run offline, with no access to a server.
2. Home Screen: The mobile platforms added the ability to pin web apps to the Home screen with their own icon, making it possible to start them much like native apps.
3. Performance: Work by the browser folks on the internals of the JavaScript engine resulted in huge boosts in performance. The results are in this table: http://www.nsbasic.com/speedtest.htm. You can see the transition from early BlackBerrys being able to run a few hundred JS loops per second to the Motorola Xoom at 718,000. The benchmark is simplistic, but the message is clear: JavaScript on mobile device is 1000 times faster than a few years ago.
It turned out that it was fairly straight forward to write the Translator. Yes, there were enough weird edge cases to question anyone's sanity to do this again, but the result works well. All the control structures translated one to one, so there was little or no drop in performance.
We then built a Visual Studio style IDE around it, with support for frameworks like jQuery Mobile, jqWidgets and Sencha to build a complete dev environment. It's been a lot of fun.
(and yes, you can use JavaScript instead of BASIC if you want!)
It's worth wondering why this is, and I don't really have an answer. In JS's infancy, Java was meant to be the Language of the Web and JS was its asthmatic younger brother. There are probably purely aesthetic problems which led to Java being overtaken by Flash, but I don't know. I sometimes like to say that Java looked consistent in every browser -- but consistently ugly. But Java is not necessarily fun to develop in either, and getting people to install Java always seemed like it was more pain than getting them to install the Flash plugin.
You can treat it as a black box, of course: even to this day, for lots of people, Java on the web just plain doesn't work. But I think you're asking why it doesn't work, and that's much more subtle. You know who would be an interesting person to ask? An advertiser. You see flash ads, you see JS ads, you see flat image ads -- but you never see Java ads.
In any case, I think JS won because it gave immediate gratification: you took the image that you had already placed on the page and, onmouseover, you replaced it with an animated GIF which you'd already loaded and cached. It was event-driven design with a GUI language that you already needed to know when you were making a web app in the first place -- you didn't have to learn AWT and Swing and such before you could make and place a drop-down menu; you just placed a SELECT with OPTIONs, the same as for a form.
When CSS replaced FONT tags and ECMA partly solved the problem of Microsoft trying to kill Javascript in favor of JScript, it became clear to me that JS was indeed the Language of the Web, and that HTML and CSS were just very smart declarative domain-specific languages for its GUIs. If you want a single lesson, there it is: make sure your language allows for declarative programming, and make sure your GUI language is declarative and event-driven.
Its other strengths would not necessarily have been strengths elsewhere. It's an asynchronous language with no race conditions. That's perfect for a responsive GUI, but it's probably wrong for anything which needs lots of processing power. It's got light objects and first-class functions, which is beautiful when you want to package data and write jQuery, but the cool stuff you can do with the Haskell type checker is pretty much not allowed by this model.
But those are the reasons why you might still prefer JS, even when other middle languages exist.
Perhaps not so wrong? http://news.ycombinator.com/item?id=3902319
As far as why JS, source-map for debugging is a big deal here. This makes it a very good host language because it enables source debugging even when used as a compiler target.
Well, to begin with, a typical Java applet take around 30 seconds to one minute just to load and start execution, usually suspending the whole page. There's nothing more annoying on the Internet for me than encountering an unexpected embedded Java applet. Hitting "back" and killing the Java process is almost subconscious reaction to me now. Java Web Start was actually something nice and I used it to launch programs and play games written in Java. It at least asks before hunging your browser up.
And then again, Java applets are consistently ugly. Maybe it has something to do with default GUI libraries, which look bad and break UI conventions. Only today I had to deal with a Java program that reinvented tree view, so that you couldn't rename elements without killing and reinserting them.
So yeah. Execution sucked then and still does now.
The only other way I can think of is baking it up with the browser. Like Google is doing with Dart. But even they are making Dart compile to JavaScript to make sure you don't lose compatibility between different browsers who opt to not cook Dart in. I remember an interview with one of the Dart developers where he said that having it as a requirement that Dart compiles to JS was greatly limiting the potential of what they can do with Dart. But they can't opt out of it, because compatibility with other browsers is too important.
In short, they're using JS as a middle language because there's no other way to do it. JS is a terrible language, but because of how the web historically developed, we're forced to use it.
Like any language, some people like it and some people hate it. I love it. If you stay away from the bad parts, it's a cool, flexible dynamic language. And it is pretty good to compile to, benchmarks of C compiled to JS for example are quite good.
I would repeat the exact same argument for using SASS or LESS instead of CSS. There is no good reason to torture yourself with CSS instead of these better languages. It's very clear that there is such thing as one language that is much better than another in every practical sense.
[1] http://www.flickr.com/photos/raindrift/sets/7215762949290803...
[2] http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockfor...
I would never suggest using most of the languages on that list over JavaScript. In fact, the only ones I recommend are Lisp, Ocaml and Haskell. Maybe something like Ur/Web as well. Coffeescript is good too, but it's basically lightly improved JavaScript. I find JavaScript simpler, more expressive and generally nicer than most of the other languages listed (ignoring the ones I've never seen or used).
Ultimately, JavaScript is a nice language with some warts. But, for whatever reason, the warts are blown out of proportion compared to other languages--in my experience (out of the languages I've used significantly) Python, Perl and Java all have more significant shortcomings. I think the main reason is that JavaScript position in the browser forced a lot of people to use it against their will, which leads to more complaining.
Ofcourse, my problem is I'm so used to javascript's duck typing that I now feel horribly constrained by a strictly typed environment.
A lot of people, myself included, would rather not do any Javascript at all. Particularly those of us who dealt with it early on, since the 90s. It's a pain, a moving target of practices, compatibility and libraries, and quite simply, we hate it. There is massive demand for anything that successfully abstracts as much JS as possible out of the picture. Libraries like Jquery, Prototype, Mootools, ... and whole substitutive systems like Coffeescript, Clojurescript and those others listed.
Happens to Java too. These languages are intensely disliked by many people who have to deal with them because they are infrastructural in their environments. Their architecture is often forced on people who'd much rather program in something else.
Do you expect that any of your additions will get merged into mainline Coco/CoffeeScript?
Update. Nice picture to illustrate what compiling to JS feels like http://im4-tub-ua.yandex.net/i?id=140745948-54-72&n=17
Still an eye-opening read, though.
[..]
Family (share genes with CoffeeScript)[citation required]
And now you have to find a tertiary source (not even a secondary, or god forbid first-hand, like for example coffeescript.com) that proves that they share genes.I'm not trying to be funny or sarcastic, so don't downvote me! That's what Wikipedia is, for better or for worse.