CoffeeScript 1.1.0 released
jashkenas.github.com
jashkenas.github.com
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-in...
* Output in the REPL is now colorized, like Node's is.
* All text/coffeescript tags should now execute in the order they're included.
* Function calls can be used as default values for parameters.
* Splatted parameters are declared local to the function.
* 0 == '' is true, really? what about 0 == '0', also true!
* What is 'this'? Well it depends on where you are and there is a long article someone posted somewhere. To figure it all out...
* Brace block != new scope.
* No nested namespaces -- all is in a global scope.
And there are others. Again. Not hard just kind of unpleasant, therefore CS.
Its a legitimate question, I don't get the downvotes.
>Function calls can be used as default values for parameters.
What can I do in 1.1.0 that I couldn't do in 1.0.1? In 1.0.1, I just did the following:
coffee> x = 0
0
coffee> f = (g=(do -> x++), h=(do -> x++)) -> [g, h]
# (compiled JS)
coffee> f()
0,1> Thanks for mentioning it -- the fix was actually to correct a regression from a previous commit, not a true bugfix versus 1.0.1. I've removed that line from the changelog.
What the world needs is less syntax, not more. Perl, Ruby, and Haskell—the inspirations for CoffeeScript, as near as I can tell—are, as a recently-linked entry called Perl, programming languages that you have to constantly use to keep your programming skills.
For all its problems, as long as you can remember to use === and friends instead of ==, JavaScript's syntax is relatively obvious, if unweildly, to anyone who grew up in a C dominated world.
Fargo, the recently-linked Scheme in JavaScript, is something I an get behind personally, though sadly Clojure is becoming the default Lisp my mind thinks in.
We need to declare a moratorium on new syntax. With Lisp, C, Python, and a couple other languages (maybe), we have all the syntax we need. Novelty is not innovation. New is not better.
We live in a world where utility players, i.e. everyone in a startup, already have to think in terms of too many different languages.
But complaining about novelty reeks of telling us kids to get off your lawn. Some syntaxes are better than others. We haven't found the best one. Innovation is still possible. Hackers innovate. Get used to it.
http://en.wikipedia.org/wiki/Innovation
I think that hackers invent, not innovate. Innovation is too risky to be taken by one or even little group. It is something between an act of changing values (or axioms) of system and the process of that system change.
I also think that innovation is too pompous term in the discussion of programming languages syntax.
http://en.wikipedia.org/wiki/Invention
Invention is much lesser term and much more nimble. And it could provoke innovation, of course. But for innovation we need semantics more than syntax, I think.
What exactly is tripping you up?
To me, CoffeeScript is pretty much to Python as Clojure is to Common Lisp, as far as syntax is concerned. It's similar enough for syntax not tripping anybody up.
One of the problems with JavaScript's C-like syntax, IMO, is that it makes people think in a C-like way. CoffeeScript's syntax brings out the functional qualities of JavaScript in a nice way. Writing CoffeeScript makes me a better JavaScript programmer.
Further, if you're working on a Node stack there are a few levels where CoffeeScript and JavaScript can interact. Different modules can be written in either language. You can expose a http.Server interface in your application. If you're on Connect/Express, you can mount routes to apps written in either language, or even Zappa.
And if you want a moratorium on new syntax, I suggest you stop learning new syntax. I look forward to a future where syntax moves further into the background.
That is why CoffeeScript is ultimately uninteresting if perhaps useful to people who don't understand or are not in a position to use lisp.
In my experience, JavaScript's syntax has never encouraged people to think in a C-like way. In a Java-like way, perhaps, but not really even then. People seem to get, if they're remotely clueful, that JavaScript programming calls for a lispy approach. It's all the damn parens and (optional) semicolons and braces and no-win indenting scenarios that frustrate people who try to exploit JavaScript to its fullest.
Yes, CoffeeScript solves these problems and others, but through the introduction, as I said before, of yet a new set of rules that result in whitespace-sensitive line noise code that requires frequent contact to stay familiar with. And again, I'm a busy person: a new language wastes my time because I already need to write shell scripts, Clojure, and Python in a daily basis. I know JavaScript, even if I dislike it.
And if you're going to learn a language that doesn't help your resume with The Man, you may as well learn a language that can change your life. Like a lisp.
Think of the analog of writing a desktop application: there are many object-oriented desktop app frameworks where you can write pretty rich apps exclusively by instantiating existing classes, and this is possible because some domain experts designed a framework for writing desktop apps.
Macros—which I've been using as a shorthand for "syntactic innovation"—are the same way. Someone writes e.g. a web application framework that consists of some macros, perhaps of deep skankiness, that let you write clean, obvious code that solves whatever problem in the web application domain that you're currently confronted with.
That said, I think the various lisps out there have plenty of user—and by that I mean programmer—success stories. My favorite right now is Cascalog. It's an amazing, life changing tool for anyone who needs to analyze data sets using Hadoop. It makes something that would otherwise be too difficult (given the time I have) to even try to do into something that is fun. Nathan Marz, Cascalog's author, should be considered for a MacArthur genius grant.
Cascalog, incidentally, would not be nearly so amazing if not for the relatively few macros that tie everything together.
I don't think this stuff, while brilliant and clever and useful, qualifies for a MacArthur grant when one is standing on the shoulders of N CS giants reimplementing their ideas with few truly novel improvements.
MaCarthy, Kernigan, Thompson, Richie, McIlroy etc are those giants.
I think a lot of people would still balk at the syntax though, and prefer something with similar functionality and more comfortable syntax, even if it was a lot more work to implement such a thing.
syntactic innovation at the language parser level is a
waste of time
We are all language parsers. CoffeScript makes that easier to do. It may make very little difference what to parse to the computer, but it may be big for us, humans. learn a language that can change your life. Like a lisp.
Whoa. The language that changed my life (a bit) was English.
And by the way, do you literally mean lisp, or just functional paradigm?I literally meant a lisp. I'm a big fan of mostly-functional programming, but a functional tendency is just one of the features that hang together—along with the absence of syntax and lexical scoping and macros and maybe something I've forgotten—that make lisp what it is.
My natural style is polemical. My thoughts tend to the nuanced. That's often a bad combination.
I wish there were better examples of creating cakefiles though. Little documentation on this. I think it assumes that everyone has a ruby background. I'd like a cakefile with a task to compile all of my .coffee files. Seems like that should be easy, but I don't see an example of how to do it.
It'll be a boon for straight-up minified JS as well.
Might be more interesting if V8 would support CS as an input language to compile natively in addition to JS -- this would have CS "natively" in Chrome and Node.
But then, things work fine as they are. Compiling CS to JS is not a huge performance hit and it's either part of your build chain or a one-off hit at your apps startup.