jducoeur: (Default)
[personal profile] jducoeur
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...

(no subject)

Date: 2011-02-17 08:17 pm (UTC)
From: [identity profile] metageek.livejournal.com
Interesting—same basic tactic as my Adder, but for JS instead of Python.

But, yeah, the postfix conditionals are nasty. Python has them for conditional expressions ("x if x<5 else 7"), and I dislike them almost enough to stick with conditoinal statements.

And I really don't care for their object constructor syntax. For some reason, I'm OK with significant indentation in code (see Python), but not in data; a compound data value should have delimiters.

(no subject)

Date: 2011-02-17 10:13 pm (UTC)
laurion: (Default)
From: [personal profile] laurion
I found it a few months ago, and said 'neat, if I ever want to do javascript work, I'll come back to this'. Overall, from my brief examination, it just -felt- cleaner than JS.

Profile

jducoeur: (Default)
jducoeur

July 2025

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27 28293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags