7 ms·
Mozilla, WebKit To Support Debugging CoffeeScript and other JS Languages
- fragsworth 15y agoThis 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.
- jjm 15y agoThis is awesome! It will be nice to see what kind of debug tools we can come up with.
- Judson 15y agofyi, I may be late to the party, but if you want to debug minified js in firefox and prefer not to wait until its integrated, I have been using this add-on[0] with success. [0]: https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/ https://addons.mozilla.org/en-US/firefox/addon/javascript-de...
- masklinn 15y agoThis feature is also available built-in in Safari and Chrome (in the dev tools, Script pane, look at the bottom buttons bar, its rightmost button is a pair of braces `{ }`. Click on that, it will reformat your source to allow for debugging, the reformatting lasts until you reload the page so it's very handy to try and debug SPA)
- pkulak 15y agoIt would also be nice to get this support in Node for those of us using JS server side.
- InclinedPlane 15y agoOnly a matter of time before coffeescript is natively supported by the progressive browsers, I think.
- mnemonik 15y agoI'm not so sure about that because CoffeeScript is a very fast moving language (one of its benefits) and it doesn't make sense to slow down the iteration cycle by integrating it with browsers directly. Then you would have to worry about which CoffeeScript features you could take advantage of, instead of just compiling to the lowest common denominator of JS, so to speak.
- MBlume 15y agoCoffeeScript needs to be a fast moving language because it's still being developed. I imagine that, like most languages, it will eventually settle into a fairly stable, mature language spec.
- starwed 15y ago(This is exactly the reason Brendan Eich has said he prefers the "compile to JS" approach to incorporating other languages of a VM into browsers.)
- starwed 15y agoShould read or a VM -- I still don't entirely understand how HN determines when you can still edit a post, pretty sure I've edited posts this old before.
- drivingmenuts 15y agoI missed the "JS" the first read-thru and was hoping the title alluded to maybe Python somehow being used in the browser. Oh well. I guess that's just hoping a bit too much.
- mikemaccana 15y agoThis would apply to Pyjamas (Python that compiles to JS) too. That said, Coffeescript is very similar to Python.
- MBlume 15y agoI actually think Coffeescript has one up on Python in some places. Splat assignment, for example, and a slightly simpler idiom for iterating through objects.