Some of the interesting recent features include executable class bodies, extended regular expressions, functions with default arguments, and YAML-style object literals.
Thanks for all the great suggestions and patches (almost a thousand Github issues, with many thousands of comments). The language has been very much a community driven project, and hopefully it reflects some significant part of the hard-earned wisdom of JavaScripters.
Good to see new languages improving upon syntax, readability is key and a great way to gain adoption. As Norvig said, it is easier for him to explain an algorithm in python than any other language. Well, now CoffeeScript has just passed that test too.
Brendan Eich is also adapting many good things from CoffeeScript to JS.next, validating the point that coffee, in its short life, has been able to influence other great language designers.
And that says a lot about CoffeeScript and its potential.
I agree. If nothing else, CoffeeScript will be a success if some of its ideas find their way into a future version of JavaScript. It's been very gratifying to see folks like Crockford and Eich giving it a serious look:
The page says, "Objects may be created using indentation instead of explicit braces, similar to YAML. "
Similar to YAML? What exactly does that mean? Is there someplace that explains the specific indentation rules?
The indentation rules of YAML are massively borked; it's not enough that something be indented, it has to be indented a very specific number of spaces. As opposed to, say, Haskell's more sane off-side rules.
CoffeeScript isn't particular about the specific number of spaces, as long as you're consistent. For example:
book.save
title: "The Book of the Thousand Nights and One Night"
length: 45
chapters:
"The Fisherman and the Jinni": 1
"The Tale Of The Ensorceled Prince": 13
"The First Kalandar's Tale": 27
Compiles into this JavaScript:
book.save({
title: "The Book of the Thousand Nights and One Night",
length: 45,
chapters: {
"The Fisherman and the Jinni": 1,
"The Tale Of The Ensorceled Prince": 13,
"The First Kalandar's Tale": 27
}
});
I'm afraid that's not correct. You can use arbitrary number of spaces to indent a block in YAML[1]. It does't matter if it's 2 of 4 or 17.
The only limitations are that it must be greater than the indentation of the parent node (obviously), that all siblings must have the same indentation and that tabs are not allowed.
Are you sure you're not mistaking this with HAML? It's a bit stricter with the indentation requirements.
CoffeeScript has been and will continue to be a tremendously powerful catalyst for change in the JavaScript community.
CoffeeScript has successfully: advanced our organisations attitude towards JavaScript on both the server and client; rendered working with complex systems -- such as node.js and WebGL -- a breeze and allowed us to focus solely on the real problems at hand rather than quirks in a language.
Everyone who has contributed in any way whatsoever, or even only just toyed with CoffeeScript should feel privileged to be part of the fantastic community surrounding the language.
Thankyou for the great gift that is CoffeeScript 1.0 this Christmas.
Has anyone written a reverse CoffeeScript compiler that compiles legacy js into cs? Seems like it would be a great tool for starting off refactoring of big js files, or if you simply wanted to adopt cs as your standard.
It is not without its cavets, though, with a little work it could be brilliant.
Alot of things that are in CoffeeScript simply are not possible in JavaScript; given there is no 1-1 relationship between CoffeeScript and JavaScript constructs.
i made this a couple of months ago as an experiment on someone's suggestion and ended up getting REALLY far. only current caveats are that some hacks are used (of course).. and CoffeeScript 1.0 is not supported. I have been busy and I don't know what kind of updates that will take right now. I have been meaning to get around to it of course, but for the mean time I put the demo up there. The source is of course open, it's written in JavaScript. Have a look in App.js. It's a recursive AST walker. If you do manage to patch it you can send me a pull request on github. The code is relatively clean and easy to read. It should also serve well as a learning tool to see what the symbols of CoffeeScript are.
For the last week I've been using CoffeeScript along with Backbone.js & Underscore.js (all backed by jashkenas) and it's given me a much greater appreciation for the power of javascript.
It's amazing how much more I like Javascript under the guise of CoffeeScript. JS got a lot right, and when you get rid of (most) of the wrong, it really shines.
Newbie question: How is CoffeeScript typically used? On a web server running node.js? In the browser after including CoffeeScript the way you might include jQuery? Either? Some other way?
Anywhere you might use JavaScript. For building web sites, working with canvas, doing servers with Node.js, or scripting the JVM with Rhino ... for example:
Since CoffeeScript itself is written in CoffeeScript it was quite easy for the team to create a distribution of the compiler that runs in the browser.
You can find it in the extras folder of the source code repository.
Usually though, people opt to pre-compile their CoffeeScript on the server, pack, optimise and minify it before serving it to clients.
At Feisty, we write CoffeeScript that is intended to be executed on both the server and client.
To achieve this, we wrote "requisition" - https://github.com/feisty/requisition - a server-side packager and client-side loader - via require() - for CommonJS Modules written in CoffeeScript.
I'll endeavor to equip the projects without meaningful READMEs proper introductions over the next week. For the moment you can learn a little more about the projects at http://github.com/feisty/cortex/wiki
Please direct any questions/feedback/correspondance to "pyrotechnick" on the social network of your choice.
Congrats to the team! I've been using CoffeeScript together with underscore.js, backbone.js and of course jQuery. Together they make functional style programming and building MVC pattern so much easier. Thanks for building such an expressive language.
Thanks for this Jeremy and everyone who contributed. I've held off really coming to grips with javascript because I found it ugly and full of too many gotchas. But Coffeescript has got rid of all those excuses!
Satoshi Murakami deserves a large portion of the credit for the changes leading up to 1.0 -- his Coco dialect of CoffeeScript has been a strong influence on the features and optimizations that happened this fall.
I thought I have a pretty good handle on CoffeeScript, but Coco's README confused me. Can someone explain the reasoning behind Coco's features? Can't seem to discern their purpose.
Been holding this one back for awhile, but: Are there any talks, plans or otherwise on incorporating other languages for client-side scripting? I'd really just like to get away from JS in general :(
IMHO it will never happen in the sense you imagine it but we'll see.
In the meantime you may want to check out emscripten (http://code.google.com/p/emscripten/). It is a JavaScript backend for LLVM which ultimately leads to the same functionality as having other languages on the client.
Who was responsible for that rad new CoffeScript logo / when was it added to the site? Coffee-cup and typography look awesome! (Also, love the language).
Would people be interested in a Ruby-oriented project like this? Say, tiny.rb ported to use Javascript? (Some Googler already has a Lua-esque VM for tiny.rb as her 20% project.)
I'm afraid that Ruby semantics don't align too well with JavaScript semantics. Things as basic as numbers, method dispatch, and variable scoping don't work the same way. Either you end up with perfectly valid code written in one that doesn't run on the other, or you have an extremely slow Ruby interpreter implemented on top of JavaScript.
This is the main reason why CoffeeScript tries to stick as close to JavaScript as possible.
Perfectly valid code that runs in one and not the other is fine, so long as context switching can be minimized between browser and server. (It's still a switch, but smaller.)
Thanks Jeremy! I think CoffeeScript is a wonderful replacement for JavaScript, it made client side code so much nicer to write for me. Been using it since 0.7 (?).
http://news.ycombinator.com/item?id=1014080
Some of the interesting recent features include executable class bodies, extended regular expressions, functions with default arguments, and YAML-style object literals.
Thanks for all the great suggestions and patches (almost a thousand Github issues, with many thousands of comments). The language has been very much a community driven project, and hopefully it reflects some significant part of the hard-earned wisdom of JavaScripters.