If you'd like to see the most complete explanation of why CoffeeScript is all about working with and embracing JavaScript -- not giving up on it -- the best resource is probably Brendan Eich's and my joint talk at this year's JSConf:
http://blip.tv/jsconf/jsconf2011-jeremy-ashkenas-5258082
But the other interesting thing here is how many of the comments point to the fact that most people who write posts about fears of CoffeeScript have never actually tried it. Having experienced a good deal of this myself, I have a pet theory about why this is the case...
First, the caveat that CoffeeScript is just a fun little thought experiment: I have no vested interest in whether you use it or avoid it for your project -- whatever suits you best.
Most esoteric programming languages are non-threatening. As a hypothetical programmer working on web applications, I can feel safe and comfortable in my ignorance of Haskell, Erlang, D, Io, Arc, and so on. They're far enough outside of the realm of possibility of adoption for my company that I can shrug them off with an "oh, that sounds interesting", and little more. Wanting to adopt one of them would require a whole new development and deployment stack, a new or ported codebase, and new integration costs with the rest of our system. You wouldn't expect to see an article talking about how people using Erlang are creating a "knowledge gap" for Java programmers.
CoffeeScript feels threatening precisely because it is so close to JavaScript, because the code can run with identical performance as hand-optimized JS anywhere that JavaScript can run, because any CoffeeScript library can interoperate seamlessly with any JavaScript library, and vice versa. It forces you, as a reasonable JavaScript programmer, to answer the harder question: Why haven't you tried it yet? Posts like these happen when folks try to rationalize an answer for themselves.
I have tried it, and I love it (same goes for Backbone and Underscore, by the way - you are the developer who's work has impacted me the most positively in the past year) but I haven't used it for anything serious yet, and here's why: the workflow is more complicated than "make change, refresh". Until very recently, my programming time was split about equally between the three major operating systems (I have since managed to phase out Windows almost entirely) and it's way more trouble than it's worth to set each of them to autocompile changes to .coffees. I know that I could import the compiler and use script type="text/coffeescript", I know about LiveReload for Mac (even though I couldn't get it working in the few minutes I tried it) but the bottom line is that I already know how to write Javascript, and it works great. Learning a new language is the sort of thing I like doing, but wasting time futzing around with build systems is not.
Anyway, I didn't mean to rant. I could easily love CoffeeScript - I don't feel threatened by it a bit. But there are some serious barriers to adoption, and Javascript isn't nearly painful enough for me to deal with them.
Also, I think your problem is very particular to front-end devs and designers-that-code. If you're already doing back-end in your framework of choice, adding CoffeeScript or any kind of precompilation into the mix is usually just a one-liner in a config file away.
Why does this mean they fail?
> learning CoffeeScript and its idiosyncrasies
Which idiosyncrasies?
> The problem is that many programmers are turned-off by the lax nature of JavaScript
Maybe true of Dart, not of CoffeeScript
> but I urge you to ask yourself whether a move to CoffeeScript is sign that you've given up on learning it properly?
It isn't.
> we rarely have problems caused by the very things that CoffeeScript aims to eliminate
CoffeeScript is generally more readable and concise than JavaScript. It's just more pleasant to work with. Does it solve any problems for a narrow definition of "problem"? Probably not, but who cares?
I've noticed that most people who don't like CoffeeScript simply have a negative gut feeling about it, but have never really tried it. Or are trying to prove that they're better at JavaScript than you are (see http://stdout.be/2011/08/23/macho-programming/). I don't mind that: everyone is free to choose his/her own tools, and if one of the hot new tools everybody else seems to be using just looks ugly or stupid to you, whatever. I probably make my own fair share of weird toolkit choices. But I don't try to rationalize them with arguments that don't make sense.
He rightly draws the analogy between jQuery and JS. I spend a lot of my time working on jQuery core, and we have definitely seen the phenomenon described in that blog. Five years ago when jQuery was created, just about every web developer knew JS quite well and understood the quirks of every browser and JS implementation. Now, they just assume that if something doesn't work consistently in IE6 then it must be a jQuery bug, because you know, jQuery is cross browser. People are now programming in jQuery and have given up on JavaScript.
If you're a CoffeeScript pioneer you don't see this. You already know the hard and ugly JS things that CS makes easy and beautiful, just like the early jQuery adopters. A few years from now if browsers haven't created native CS implementations but CS is popular, novice programmers will be dealing with the same jQuery-vs-JS dilemma. For example, programmers with weak JS skills will write CS and be baffled by the errors thrown from the bowels of the JS code they are forced to debug.
> "Five years ago when jQuery was created, just about every web developer knew JS quite well and understood the quirks of every browser and JS implementation."
False. Five years ago programs thought of JavaScript as a silly little non-language to add fantastic effects onto their serious back-end code. When Rails 0.6 added a way to do sort-in-place lists via ajax, and they worked every time, I remember feeling that this was surely some kind of dark magic, because who could write JavaScript that worked all the time with different back-ends?
What has actually happened is that the pool of people who used JavaScript five years ago, with in most cases an appropriate dash of fear, are now quite competent JavaScript programmers who can do fancy things. And newer programmers can get started with jQuery even without knowing browser quirks from the start, though eventually they have to learn them.
jQuery has lowered the barrier to entry, it hasn't made people stupider. It's made the prior intermediate-level js programmers into ninjas, and it's given newbies the power to do cool things and then complain when they find small problems.
CoffeeScript is the same. It lowers the barrier to entry for people who don't care to understand why the arguments array isn't a real array, or how functions definitions are hoisted if they don't come as part of a var statement.
Yes, this means that new users will complain because they don't understand the technologies underneath. And that's a challenge to us to be a welcoming and educational community that helps them learn.
Back-end programmers may have felt that way five years ago, but there were plenty of people who were using JavaScript to write highly functional and responsive web pages in 2005. Don't forget that the original XHR object was created by Microsoft with IE5 as a way for Outlook to refresh a web inbox view without a roundtrip to the server.
Promises of future solutions don't help fix the problems that exist today today.
Also, what is the desired end game here? Do we want software developers to have encyclopedic knowledge of browser quirks in 2021? How about 2026?
There are so many wrong saying in this statement.
First, understand that CoffeeScript is JavaScript - but without its idiosyncrasies. If you know JavaScript really well, learning coffeescript takes minutes. CoffeeScript embraces closures and prototype inheritence; it just makes it less cumbersome to use.
Second, who said that programming in CoffeeScript means you don't really know JavaScript? CoffeeScript let you write better code in less line. (By better I mean easier to maintain and read). Furthermore, CoffeeScript programmers tend to choose it because they enjoy coding in Javascript and want to keep using it. What is way more scary is maintaining codes of designers who use jQuery without understanding Javascript.
Third, I hate the "For the extra effort" part. It's like saying, either you learn Python or C++; you can't learn both so better spend the time learning C++. It's just totally wrong. Good programmers tend to enjoy learning new technologies and paradigms. I'd even go further by saying that learning CoffeeScript will make you a better JavaScript programmer.
You've stumbled onto a pet peeve of mine. I think it's rather that people who like learning new programming languages like labeling people like them as "good".
The flip side of the coin is that there's a huge intersecting set of attention-deficit afflicted dabblers who play with a large number of technologies and master none of them. I enjoyed learning programming languages when I was 14. I'm 31 now, and now I like solving actual problems. If I need to learn a new technology to do so, so be it, but there's rarely much joy in such.
I believe you'd find the opposite true if you surveyed more mature fields: master craftsmen tend to be stubborn about the tools they use, but know them inside out.
Conversely, the second worst projects I've worked on suffer from ADD: "Look, a shiney, new tech. We must embrace it!"
My philosophy is to continually learn new stuff for its own sake (I've focused on languages in the past, but I think it's time to switch to algorithms). I may never use something I've learned, but my tool chest is much more broad (and that Erlang tinkering is coming in handy now!).
I don't think I'm a better developer that a highly-focused compiler writer that knows YACC inside and out. We have different skills for different needs. But I still think the compiler writer would benefit from broadened education.
In my career, I've met all kind of programmers, and I'm sure you also have. Some are really passionate about their crafts while others do the minimum, go home and don't think about software until 9am the next morning. You are right that I can't say that good programmers enjoy learning new technologies. But I can assure you that the worst programmers I've worked with were never willing to learn more.
And, comparing software engineering with more mature fields is somewhat difficult as their tools do not change as fast as ours. Yes, craftman tend to know their tools inside-out; but they're not limited to only one. They're usually good with all of them and pick the right one for each situation.
...and a different syntax. That's my main objection to CS. I'm already working with 5 different syntaxes: Python, Javascript, Erlang, HTML, and CSS. Adding yet another one isn't appealing.
Perhaps if you're writing an app on top of the Node.js stack, you can use CoffeeScript everywhere. What I would've liked to see is CoffeeScript with a syntax as close to Javascript's as possible.
His basis of not having to learn CoffeeScript is that he uses structural js frameworks? Like somehow CoffeeScript prevents you from doing that?
I'm all for sound reasoning showing pitfalls of certain languages - which despite its wordiness, the article demonstrates a severe lack of. IMO the biggest reason not to use CoffeeScript is the lack of a good debugging experience. Although that's about to get better with soon being able to write source debug symbols in js for transpiled languages.
At the same time the JavaScript language is constantly improving (albeit slowly), which ideally would mitigate the need for CoffeeScript / Dart / etc. But that's not going to be available in mainstream client js programming for years to come. In the meantime feel free to use what language you feel more productive in - and stop trying to impose your personal taste onto others.
It would not be so bad if the underlying language was more direct -- after all, we mostly run on the x86 ABI which is also insane, but much less so. I don't use Javascript that much, but it appears to be a hacked-up version of Self that you need to include weird modules to do anything with?
It's like people living near Albany NY who are "so close to Boston, NYC, and Montreal!" Yeah you may be close to "there," but you aren't there. I can assure you the people living in Boston, NYC and Montreal are never excited to visit Albany.
I understand the point though, but for me it's about shipping, and really: CoffeeScript has made me write a lot more client-side code and make it with confidence, with fewer "wtf" moments.
I'm fairly sure at some point I'll need the help of someone who is really proficient with JS, but the benefits are still so obvious to me I'm really more than ok with it.
EDIT: someone on twitter asked what are recommended resources to learn CoffeeScript - I made a gist of what worked for me here: https://gist.github.com/1343059
So we have languages that compile to JS that let the language evolve. I use CoffeeScript sometimes and JS sometimes. I'm not going to waste the time in the write-compile CoffeeScript loop for 100 lines of JS that I can write correctly. However, I no longer have to work on a 2k LOC, complex JS app without all the niceties of CoffeeScript. Furthermore, if I'm doing something that benefits from the special expressivity of a Lisp, I'll use clojurescript. If I'm very adventurous (and I need to write, say, an H.264 decoder), I'll use emscripten after any language that compiles to LLVM first.
But these are all for different uses, often things you would never have used POJS for anyway. It's not a discussion of plain ol' JS versions of H.264 encoders vs those made originally with Emscripten. It's a discussion of them not existing at all before, and now having the ability to express them and compile to JS. It's not a question of the old enormous apps we built in JS to the new, simpler ones we express in CoffeeScript. It's a question of not being able to build/maintain 5k LOC in POJS across many developers (whereas this task is less substantial in CoffeeScript). Live and let live and everyone benefits.
Coffeescript just gives syntax to common patterns being used in js. For the most part, it feels like a bunch of really nice macros that encapsulate those patterns, making them less error-prone, easier to read, and easier to maintain. I'm not really sure what the concern here is, since most of the post seems to assert that people who use coffeescript don't know js, or that these shortcomings could be addressed equally as well by a large framework system. I can't imagine anyone actually believes the former, and while the latter may be true I don't know why that framework will be so much easier to learn, use, and maintain than the equivalent coffeescript.
You can't write a line of code in any language if you don't know, on some level, what it's doing in the machine (whether physical or virtual). Sure, you can, but you're not a programmer, you're a tinkerer. To really program, you need to know assembly.
But at some scale, your application becomes large enough that no one person, no matter how well they know the assembly it's compiled to, can hold the whole thing in their head at once. At that point, reliably adding a new feature isn't hard, it's impossible. There will be side effects you can't predict.
Abstraction isn't there for making hard things easy. It does, and that's nice, but that's not what we need it for. We need it to make impossible things possible.
The situation of CoffeeScript would be like C if the only way to debug C code was to debug it in assembly.
The key word here is "existing". This is about to change with CoffeScript support being worked on in Firefox (and some plugins like AceBug)
For details see: http://www.quora.com/CoffeeScript/Is-there-a-CoffeeScript-de...
That's just an absurdly untrue statement.
maybe the problem is not know some assembly or at least some C when you write Objective-C or C++ you can write some really bad, inefficient code if you don't know the work the language underneath has to do. the same goes for the DOM and Javascript our assembly on the web.
When I wrote the PragProg book on CoffeeScript (http://pragprog.com/book/tbcoffee/coffeescript), my aim from the start was to fill common gaps in JavaScripters' knowledge while introducing them to the new language. Brendan Eich himself said in his blurb for the book: "It helps readers become better JavaScripters in the process of learning CoffeeScript."
Far from distracting people from learning JavaScript properly, CoffeeScript is a terrific learning tool.
More then anything CoffeeScript shows us what Javascript might look like someday.
We get to actually try out new idioms and see if they work for us. If they don't we have ample time to voice concerns. This is a huge departure from the past.
If anything CoffeeScript will make Javascript better.
It absolutely does not.
There is one good point from this article :
"Anyone who uses a Javascript library should know Javascript well or they will run into problems with large applications"
The rest of the post is an attempt at instilling a granny-state fear for the Javascript scene.
There will always be people using technology they don't understand. Why are you so concerned about it?
"C means giving up on x86 assembly."
"If we're already willing to learn both languages and then spend time reading and debugging assembly code, why not just write good assembly code from the start? For the extra effort you'll make learning C and its and its compiler's idiosyncrasies, why not put it towards really learning assembly?"
I'll tell you why. Because while the initial cost of learning CoffeeScript (or my own preference, ClojureScript) may be high, once that barrier is passed the benefits of those languages mean at minimum that you're writing more-likely-to-be-correct code faster. A master C programmer beats a master assembly programmer.
One nice thing about ClojureScript is it lets you hook up a REPL with a browser window which is great for many debugging needs, you can't do that in JS without something like Firebug (which has its own quirks). The interesting note there is that ClojureScript, and I imagine CoffeeScript, are marching steadily toward the place where you don't need to know JS anymore, and learning it is something you only do if you want to.
At one point you did need to know at least some assembly to really do C, especially because you'd have to help the compiler out when it generated stupid code. That age is long gone (except in the microcontroller world but Arduino is making headway on that), many programmers learn C and never learn any assembly. (Not to mention the matter of which assembly.) You might have to learn a bit about computers like the concept of memory and pointers to do C, but those aren't fundamentally assembly features, just like needing to learn about the DOM and browser events in ClojureScript/CoffeeScript isn't a fundamental JavaScript feature. (As anyone who has done anything with RhinoJS knows.)
If you can write Coffeescript faster and better than you can write Javascript, why wouldn't you write Coffeescript?
Article: http://paulbjensen.co.uk/blog/2011/11/06/my-response-to-coff... HN Link: http://news.ycombinator.com/item?id=3203181
I "learned" CoffeeScript in, like, half an hour and I'm not even a good programmer.
So while the syntax of CoffeeScript may mean giving up on the syntax of JavaScript, it's brought me closer to vanilla JavaScript and made me more aware of it, without being in the context of a framework like jQuery or Prototype.
Just my two cents...
The only useful (as in, I would actually use it) project I've come across in this realm is parenscript (http://common-lisp.net/project/parenscript/) which compiles a variant of lisp into javascript. It seems to me the best way to go from language X to JS is to make sure X is actually a better language. From my (admittedly small) experience with CoffeeScript, I haven't really seen much of the benefit, and I tend to NOT like CS syntax. Also, javascript is a superbly powerful language in my experience, and trying to replace it would take some real thought and work.
It seems to me that taking an extremely powerful (and terse) language and compiling it to javascript would be more useful than switching out JS' syntax and adding a few easily-replicable features. Then again, maybe I'm just ignorant.
I don't really see what's to replace, though. JS ain't that bad.
While many of you will probably disagree with me, I find the trend towards writing in languages that compile to machine language somewhat alarming. The most notable of these languages C, and it's one that has gained a good degree of traction over the last year or so.
While I like and applaud the intention of these languages, I question their necessity and worry about the knowledge gap they create. More importantly, they all fail by requiring that you be an expert in two languages. Let's face it, you can't just program C without knowing machine language, unless you're willing to defer debugging to someone who does. If we're already willing to learn both languages and then spend time reading and debugging compiled C, why not just write good machine language from the start? For the extra effort you'll make learning C and its idiosyncrasies, why not put it towards really learning machine language?
Hmm?
I've been spending a lot of time writing Boo and reading C#. My intention was to put off learning C# for awhile, at least until after I ship my current project. I'm working on finishing my first game with Unity3D (and quickly developed an aversion to UnityScript).
Boo is an absolute joy to use, btw.
The funny thing is that I'm kind of learning C# by accident, by reading it (and the BCL docs) and writing Boo.
Will I at some point switch to C#? I strongly doubt it. Boo allows me to move much faster, produces cleaner, nicer-looking code, and compiles to equivalent CIL. It's all win, as I see it.
whenever i think in coffeescript i think the same thoughts like i would think in javascript, but in a much cleaner, straightforward, more beautiful, less forward/backward jumping way.
coffeescript is just javascript.
JavaScript is just an 'ok' language. It has serious warts and it might have been great in 1998, but not now. But we are stuck with it. There are JIT compilers for it, it is on every browser out there so.