Hacker News new | ask | show | jobs
by notjoeflynn 5535 days ago
CoffeeScript doesn't generate JavaScript in the same way GWT does, it's more a thin layer of syntax for Javascript that compiles one-to-one to Javascript. It's an abstraction layer, rather than a library that provides functionality like jQuery.

For reference: http://jashkenas.github.com/coffee-script/

1 comments

So in 3.1, if you were to write frontend code, are you supposed to write it in CoffeeScript, or jQuery?
You can do both, or neither and choose something else you are more familiar with. Just because Rail's opinion is to use X does not mean you do not have the ability to use Y.

CoffeeScript is much like HAML or SASS, where the end result is actual Javascript that can be parsed by the browser. It's only designed to make it easier to write the code, not to replace the code. When I write HAML in my Rails app, the app parses it and send the browser actual HTML. CS will do the same.

You can write CoffeeScript that uses jQuery, so that it compiles down to Javascript that uses jQuery.

You can also use Javascript and jQuery directly.

Or you can write CoffeeScript without using jQuery at all.

My concern is that those combinations can significantly reduce Rails apps' maintainability. I wonder if jQuery is that good, can it be rewritten in CoffeeScript? Such that we can settle down at CoffeeScript, which looks like a better language anyway, and get rid of the Javascript fragmentation issue all at once.
You really can't write coffeescript without knowing javascript. Really, the /only/ documentation for the language is showing what the compiled javascript looks like, plus maybe handling inheritance a bit better.