Feb. 17th, 2011

jducoeur: (Default)
Stumbled across in the context of a scala-debate discussion, I find the CoffeeScript language. This one's not quite as take-over-the-world high-concept as most of the ones I enthuse about, but looks unusually pragmatic. As it describes itself, it is "a little language that compiles into JavaScript".

Really, it's not so little -- it's a fairly high-level language with a lot of good concepts -- but it's not trying to be all things to all people. Mostly it's adding a bunch of common concepts and a lot of syntactic sugar to provide a less painful way to write serious Javascript. It is very explicit about being a layer on top of JS: indeed, all of the CoffeeScript examples show precisely what JS they compile into. That said, the language looks in many ways more pleasant and easy-to-use than JS.

It has its quirks, some of which aren't *my* quirks: for example, it picks up Python's fondness for using line breaks and indentation to express code structure, rather than hard delimiters, and Perl's fondness for postfix conditionals. And in some cases I'm not certain I like their decisions -- for example, they talk a lot about having comprehensions, but it's not obvious that they have a way to distinguish lazy vs. eager ones. (The examples all appear to be eagerly evaluated.)

That said, those complaints are relatively minor: in general, this just plain feels like a more modern language than JavaScript. And I love the fact that you not only can compile it into Javascript offline, you can even just write it into your page source and compile it on-the-fly in the browser if you don't mind a bit of overhead. (The reference page actually does this: the page's code is in CoffeeScript, and is compiled when you load the page. That's quite neat -- I didn't even know you could define new script languages on-the-fly like that.)

I haven't done anything with it yet, but this seems well worthwhile for anyone who is facing a complex JavaScript problem. In general, this looks likely to produce cleaner, more concise and more maintainable page code than plain JavaScript would...
jducoeur: (Default)
Stumbled across in the context of a scala-debate discussion, I find the CoffeeScript language. This one's not quite as take-over-the-world high-concept as most of the ones I enthuse about, but looks unusually pragmatic. As it describes itself, it is "a little language that compiles into JavaScript".

Really, it's not so little -- it's a fairly high-level language with a lot of good concepts -- but it's not trying to be all things to all people. Mostly it's adding a bunch of common concepts and a lot of syntactic sugar to provide a less painful way to write serious Javascript. It is very explicit about being a layer on top of JS: indeed, all of the CoffeeScript examples show precisely what JS they compile into. That said, the language looks in many ways more pleasant and easy-to-use than JS.

It has its quirks, some of which aren't *my* quirks: for example, it picks up Python's fondness for using line breaks and indentation to express code structure, rather than hard delimiters, and Perl's fondness for postfix conditionals. And in some cases I'm not certain I like their decisions -- for example, they talk a lot about having comprehensions, but it's not obvious that they have a way to distinguish lazy vs. eager ones. (The examples all appear to be eagerly evaluated.)

That said, those complaints are relatively minor: in general, this just plain feels like a more modern language than JavaScript. And I love the fact that you not only can compile it into Javascript offline, you can even just write it into your page source and compile it on-the-fly in the browser if you don't mind a bit of overhead. (The reference page actually does this: the page's code is in CoffeeScript, and is compiled when you load the page. That's quite neat -- I didn't even know you could define new script languages on-the-fly like that.)

I haven't done anything with it yet, but this seems well worthwhile for anyone who is facing a complex JavaScript problem. In general, this looks likely to produce cleaner, more concise and more maintainable page code than plain JavaScript would...

Profile

jducoeur: (Default)
jducoeur

June 2025

S M T W T F S
12 34567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags