5 ms·
This is great news. The only thing that kept me from using a "higher level Javascript language" was this. I predict a massive surge in CoffeeScript usage over
by fragsworth 15y ago
This is great news. The only thing that kept me from using a "higher level Javascript language" was this.
I predict a massive surge in CoffeeScript usage over the next couple years.
- DanielRibeiro 15y agoOn coffeescript's behalf, I've never felt it was a big shortcoming for coffeescript. It really helps to have the actual coffeescript lines, but coffeescript compiles to such a clean javascript, that it is not hard to find the which lines are which. Emacs mode[1] from Github co-founder Defunkt also makes it really easy to compile a single method/function, so you can easy get the hang of how the compiler works. But this is great news for production js, which is usually minified, and for other languages, that may not compile down to such a clean js. [1] https://github.com/defunkt/coffee-mode https://github.com/defunkt/coffee-mode
- wisty 15y agoI agree. Have a look at hallo (a really basic inline editor). The coffeescript (https://github.com/bergie/hallo/blob/master/examples/hallo.js https://github.com/bergie/hallo/blob/master/examples/hallo.j...) is 236 lines, including about 60 lines of comments. The javascript is 208 lines, with no comments, and extremely clean (https://github.com/bergie/hallo/blob/master/examples/hallo.js https://github.com/bergie/hallo/blob/master/examples/hallo.j...). I think the big advantage of coffeescript is it gets rid of the whole "implicit global variable" thing. It's not a completely new language (like pyjamas - a python-js converter) just bit of syntactic sugar, which happens to make mistakes a little harder.
- bergie 15y agoHi, author of Hallo here. Thanks for the mention! Major reason for the way Hallo is commented is because I'm using Docco for API docs: http://bergie.github.com/hallo/docs/hallo.html http://bergie.github.com/hallo/docs/hallo.html
- ori_b 15y agoI just wish that browsers would allow some bytecode format with linemap/registermap/... data for debugging, and entirely forget about directly supporting languages directly.
- j-ashkenas 15y agoThat's kinda exactly what this is ... JavaScript is the "bytecode format", and you provide a line-and-column map for debugging.
- ori_b 15y agoJavascript is a rather terrible bytecode format. It's got all sorts of arcane requirements. (For example, the original text of the function must be preserved), and semantics that make optimization of many constructs quite hard. All numbers are doubles, ffs. It would be hard to do worse as an intermediate language.
- rpearl 15y ago"All numbers are doubles" is not something that any self-respecting JIT will emit. All numbers must behave like doubles, but what actually happens is code is agressively type-specialized. So, integer math is emitted, and overflow of 31-bit tagged integers is guarded. If (and rarely) overflow actually happens, then doubles are used. Yeah, a sane intermediate language may work better, but there is a lot of thrust behind js optimization; the overhead of using JS as an intermediate language, assuming you understand what sort of type-specialization is going on behind the scenes, is really not bad at all.
- kingkilr 15y agoJS has other fundamental limitations that make it a terrible IR (not being able to choose floating point vs. integer arithmatic is only one of them), there's also the lack of a distinction between hash tables and objects.