Hacker News new | past | comments | ask | show | jobs | submit login
CoffeeScript: Accelerated JavaScript Development (pragprog.com)
76 points by shawndumas on April 29, 2011 | hide | past | favorite | 46 comments



Trevor, Let me know if your book will include a simple CRUD app written in CoffeeScript using Node.js. That alone would gain you a few more sales.


Hmm, I'm afraid it's a bit late to add another project to the book (there is a Node project, but it doesn't use persistence), so how about if I write this and post it somewhere else? Would you prefer MySQL or MongoDB?


Thank you! For the widest possible appeal I would choose MySQL.


I'm the author.

I was planning to post this link later, when the book becomes available. I can't share any details yet, but look for an announcement next week. I run @coffeescript on Twitter, so you'll definitely stay updated if you follow me there.


Get the "add to wish-list" button working on the pragprog.com page. Please and thanks!


Thanks, I've let the PragProg folks know. There are a few other updates pending to that page as well.

Incidentally, you could add it to your wish list on Amazon: http://www.amazon.com/CoffeeScript-Accelerated-Development-T...


What experience do people have with other tools for generating javascript?

https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

I'm wondering how they compare, and what people have to say.


Many of those tools (including Coco, a CoffeeScript fork which is, objectively, more feature-rich) provide features to help manage asynchronous control flow (that is, to make callbacks look more like linear code). These proposals were rejected in CoffeeScript (see https://github.com/jashkenas/coffee-script/issues/350) because they take the language too far away from the underlying JavaScript—in particular, CoffeeScript code would no longer necessarily have the same order as the JavaScript output.

For heavily async code, those other tools are well worth looking at.


We use Parenscript heavily. It's great. The full power of Lisp macros on top of efficient JS.


For those unfamiliar with CoffeeScript: http://jashkenas.github.com/coffee-script/


So here's a related question. If someone wanted to snag a developer that really understood coffeescript and js development, where should they be looking?


Someone who really understands js can pick up coffeescript in a few hours, so don't pass on a good js developer just because they haven't yet made the jump.


I don't completely agree -- I feel like CoffeeScript shares as much in common with Ruby and Python as it does with JS. I'd say a good developer would be the best fit for a CS position; depending on your deployment platform, I can almost see a case where being an embedded JS programmer might actually cause issues. If all you understand is EcmaScript, all you'll write is EcmaScript. Despite its tagline being "It's just JavaScript", it's actually much more.


I knew Python and Ruby before I started with CoffeeScript, so perhaps that colored my experience. CoffeeScript is basically a minimalized blend of js, Ruby, and Python syntax-wise. But I still think someone who understands js will pretty much automatically get CoffeeScript concept-wise, at least to the level they get js concept-wise, because the central concepts of programming in CoffeeScript aren't different than js, just the syntax.


The "Who's hiring" thread will be created on Sunday. I'd try posting there.


Go to jsconf and nodeconf in Portland next week.


Could try jobs.github.com. Coffee script will also be a semi-default in Rails 3.1. A Ruby and good JS person should be able to pickup CoffeeScript in a few hours though.


Hacker News sounds like a pretty good place. Start an Ask HN.



Hang out in IRC and you will be able to determine who's worth their value. freenode #nodejs #coffeescript


This is really great to see -- correct me if I'm wrong, but Trevor must be one of the biggest contributors to CoffeeScript. It's great to have someone so intimately familiar with the project author one of its first books.


I'll correct you. :)

Code-wise, I'm only a minor contributor to CoffeeScript. I wouldn't be the right person to write a book on how the CoffeeScript compiler works. (Thankfully, some of those people agreed to be technical reviewers for the book.) But I have been an active participant in the language's community from early on.


I think I mostly recognize you from CoffeeScript's #issues on Github, where your comments are cogent and insightful.


Hmm, no beta. Love to see a sample chapter.


Agreed; but with an availability date of 2011-06-20 we should see something soon.


The book's page has just been updated with a few excerpts: http://pragprog.com/titles/tbcoffee/coffeescript

Criticisms welcome. We're aware of some technical issues (most notably, there's no syntax highlighting for the CoffeeScript snippets), which will be fixed shortly.


Just bought the combo - looking forward to going through the beta! Thanks!


Just a a question: is there any project trying to wrap the Lua with some ruby-like sugar just like what CoffeeScript do to javascript?

I think that will be fun since Lua's syntax is ... not so sweet i think.


Can't wait for beginner programmer books in CoffeeScript.


Unfortunately, it isn't really possible to understand CoffeeScript without understanding JavaScript, so it's not a very good choice of first language. JavaScript is. So, the book assumes at least a beginner-level understanding of JavaScript.


I have to disagree with you there. As there is a 1-to-1 mapping between CoffeeScript and JavaScript, I'd say that they are equally hairy first languages but the former has nicer syntax. The beginner documentation and workflow just isn't there with CoffeeScript yet. I'm actually not totally sure why you say that it isn't possible to understand CS without knowing JS. Is it because CS compiles to JS? If that's the case, I'd point out that you definitely don't have to know bytecode to learn Java.


Well, the "JavaScript is the new bytecode" analogy only goes so far. JVM bytecode puts few limits on what your language can do efficiently—Java, Scala, and Clojure, for example, all have great performance, despite having very different idioms. CoffeeScript, on the other hand, was clearly designed around what you can do with JavaScript. Or more precisely, what you can do while 1) producing predictable, readable, 1:1 output, and 2) getting good performance. So I think CoffeeScript is best understood in light of those limitations.

Plus, learning CoffeeScript wouldn't be much use if the docs for every JS library read as gobbledygook, right?


Yeah, I guess I was overreaching with my argument about bytecode. But, we can probably agree that it's more enjoyable to focus on writing good CoffeeScript than on writing CoffeeScript which will compile to good Javascript. Regarding the libraries, couldn't the same be said about learning Clojure without knowing Java (something which I think would currently be pretty acceptable)?

All I'm getting at is that I'd like to see CS eventually become a language in its own right rather than an extra tool for JS developers. I think this is completely feasible if we start treating it that way and create the tools and documentation to that end. I think it is a serious improvement over JS and could eventually replace JS for the common programmer.

By the way, thanks for all your work, I'll definitely be picking up the book.


> All I'm getting at is that I'd like to see CS eventually become a language in its own right rather than an extra tool for JS developers.

Yeah, totes. Brendan Eich himself has assured me that the Mozilla folks are dedicated to adding debug support for CoffeeScript (and other compiled JS languages) to Firefox. So the underlying JS will be less and less of a concern as the tools get better.

At the same time, though, that'll probably lead to languages that go further than CoffeeScript taking hold, just as Clojure is rockin' it on the JVM despite being really far removed from Java. I like CoffeeScript a lot, but when JavaScript really does become bytecode, people will want to code in something less JavaScript-like. (Or CoffeeScript may become the new C... "assembly with syntax," in pg's words.)



I still don't understand why I would want to use CoffeeScript when I can just use JavaScript.


Assembler and C.

Java and Scala.

Erb and Haml.

CSS and Less/Sass.

Edit: Walking and driving.


Asm/C and Java/scala are unfair comparisons, since they're totally different languages with different structures and idioms.

I just started using CoffeeScript for a project of mine and while it did clean up the messy look of the Javascript, it doesn't improve much upon Javascript feature-wise. I felt like I was still writing Javascript, it just looked a little better.


I've been writing CoffeScript daily for about 4 weeks now. On the first day, it seemed pretty minor. About three days in I was a believer. Now, when I write the occasional few lines of Javascript in my browser's console, it just feels so arduous to type. Whenever I pop open a Javascript library to read it, I feel like there is an assault on my eyes. I'm never going back.


It does have some nice shorthand, but there is a lot to be said for having nice-looking code for its own sake.


It looks a LOT better, it requires a LOT less typing, and it saves you a LOT of stupid syntax errors and typos compared to brace-semicolon-comma-parentheses stew.


> CSS and Less/Sass

This is the only comparison on your list that is remotely appropriate. In no meaningful way is it true that

  CoffeeScript:Javascript :: C:Assembler 
Javascript is not a low-level language resembling a primitive machine interface, and CoffeeScript mostly provides syntactic sugar, not new semantics or a different paradigm.


Javascript is not a low-level language resembling a primitive machine interface, and CoffeeScript mostly provides syntactic sugar, not new semantics or a different paradigm.

In order for A:B :: C:D it is not the case that A and C need to be similar, nor B and D.


I think you've misunderstood the comment.

The comparisons made in the GP have very little in common. The Java:Scala distinction is not similar to that of ASM:C, and neither has a similar relationship to that of HAML:Erb. So there are many objections that can be made to the analogy, especially that the analogous relationships provided are not even analogous to each other!

The sentence you quoted makes some assumptions of the reader's knowledge, namely that the reader understands "syntactic sugar" to be a process of trivial, linear transformation. The basis of the objection is not that Javascript is unlike ASM; the objection is that the relationship between Javascript and CoffeeScript is between a high-level scripting language and a trivial transformation layer of that language.

On the other hand, ASM is a low-level interface and C is a paradigmatic shift (comparatively) in programming that introduces semantics which are divorced (to an extent) from their machine implementations.

That relationship is not analogous to Javascript:CoffeeScript, as it is not nearly as significant.


-1 post it when it's ready, not when you're ready to start promoting it.


I, the OP, am not the author. I posted because I was excited.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: