Oh, wow. I've been using CoffeeScript for about a year for the usual front-end crap, not long ago I re-evaluated Coffee for the second time before starting a full-JS project and certainly won't use it. While I'm a fan of bracketless whitespace significant langs (Python, Sass, Haml) CS's is just bonkers and you never know when a single space will bite you by compiling to a completely different code you had in mind. The ecosystem is weak not to say non-existent comparing to JS, and every JS solution and example out there from minor jquery stuff through SPA frameworks to mobile UI builders is in, well, JS (duh!), so public code reusability becomes a ridiculous task of converting to CS, only to compile it to JS once again. I still use CoffeeScript for small front-end work, meanwhile for any bigger work I find CS an obstacle over JS, and an unnecessary step between my idea and working code; especially when the JS ecosystem has grown a lot of tools to help you deal with what pisses you off (underscore/lodash as an example come to mind).
And from the slide:
> And as of July 2013, it's also the tenth most popular language on GitHub! That's more than Objective-C, ActionScript, C#, Clojure, Go, Groovy, Scala
Yay github charts as evidence of industry value.
Knee-jerk, fallacies, resistance? Call it what you want and good luck. Meanwhile, I will use coffee to keep me awake, not to write apps with.
//edit: care to explain the downvote?
(This is backend node.js work which emphasized tests and code review. I don't know what it's like outside that.)
Not all rejection is knee-jerk. "Usually" is the operative word here. I would have loved knowledgeable, reasoned critique. I personally assembled as many reasoned critiques as I could, to demonstrate my respect for reasoned, fair decisionmaking. I am continuously disappointed by the low standards of discourse, in programming culture.
(The first random misbegotten idea which pops into my lizard brain to confirm my prejudices, is not a sufficient "reason".)
Eventually, most realize CoffeeScript's sheer maintainability can far outweigh CoffeeScript's (real) flaws; some former detractors become downright zealots. Sure, some still dislike it; but they tend to be ignored because it's really not that bad. Nothing compared to the real problems that a team encounters.
A very simple scenario where hell is a keystroke away:
hello =
woot: 1
yay: 2
funfunfun: (x) -> x + 1
hello2 =
woot: 1
yay: 2
nowthatsfun: (x) -> x + 1
Other: y1 = (x) ->
x + 1
z1: (x) ->
x + 1
y2 = (x) ->
x + 1
z2 = (x) ->
x + 1
http://js2coffee.org/#coffee2jsThose are fairly visible here, not so much on a huge codebase (not to mention with some callback hell attached). You can write perfectly legal code that just doesn't work as expected.
//edit:
worth a read, with more trap examples http://ruoyusun.com/2013/03/17/my-take-on-coffeescript.html
When I heared about Coffeescript I thought about Scala, too. Not because it reminded me about Scala, but who it took to make Scala and then out of the blue some guy comes along with some new lang, which should ease some problems.
CS is to JS what PHP is to Perl.
It's great that you tried CoffeeScript and prefer JS. Your opinion is well-formed.
With my statement, I was referring to the many developers I've encountered who haven't tried it, yet actively dislike it and argue against it. Hence the (subjective) "most" in my first sentence that you quote.
Cheers.
You're right that people should try out stuff before criticising, and in general I support the notion; yet I fully understand people who don't want to jump ship onto very new things because leaving a well-established environment for an immature/unstable one can (but doesn't have to) be a risk. At least Coffee is relatively easy to leave - just take your compiled code and get rid of the source.
I'd also like to add for the rest: what convinced me to try Coffee was @jsjabber podcast with the author http://javascriptjabber.com/017-jsj-coffeescript-with-jeremy... - I think it explains the concepts pretty well (I recommend the whole podcast btw, it's great) and I encourage to listen to it if somebody is curious and wants to try out.
I originally found it very appealing because I wasn't well acquainted with Javascript or its prototype class system, and so I didn't have that life-saving knee-jerk reaction about CS at all. I dove right in and used it extensively. After getting used to both JS and CS, I've realized that Coffeescript is at best a Javascript obfuscator.
I understand the use of some layers on web tech. SASS is great. It introduces constructs that you legitimately can't get in CSS, like functions and variables. Coffeescript on the other hand is just a toy for the Python devs that are too lazy to properly learn Javascript.
In what circumstance is it appropriate to consider the CoffeeScript ecosystem to be distinct from the JavaScript ecosystem?
> [...] and every JS solution and example out there
It seems impractical to regularly code in CoffeeScript without being fluent in JavaScript.
FWIW I agree with you about CoffeeScript being a little finicky about the syntax. There's the bit a seemingly unimportant (non -leading) space char generating dramatically different results, and also things like:
if foo and bar is x
not grouping the way you'd (or at least I) expect.Example code, debugging tools, message forums, developer teams.
This is a mildly insulting, as is the invocation of Blub.
CoffeeScript doesn't have a ton of exotic features. String interpolation, list comprehensions, and class definitions (!) are all familiar to programmers from other languages.
I'm guessing that a lot of people have weighed CoffeeScript's feature set against its overhead and decided the trade just isn't worth it.
Not only that, but it's JavaScript. It's JavaScript with some different tokens and shortcuts for a number of things that are missing from (some) JS runtimes and features people are used to from other languages, but it's JavaScript semantics nonetheless.
The author apparently knows this on at least a superficial level, since he pays lip service to it in his slides, but I'm not sure someone who invokes Blub in a comparison between languages that have the same semantics understands the point of the essay from which it comes.
I used to have a similar opinion but was forced to use CoffeeScript on a project and haven't looked back.
The overhead of tooling, extra dependencies, debugging complexities and new syntactic constructs.
If you're going to pay for all that, why not bite the bullet and use a language which actually improves the states of things and adds useful semantics?
I don't mean to suggest CoffeeScript is without value. I just don't think it has hit the requisite "escape velocity" to make me want to integrate it to my tool chain.
We've been using CoffeeScript for a bit over a year now and never looked back. All of our front end code is written in CS and I can't imagine writing JS again. It's just objectively better. Less code to write, easier to read, minimal cruft, and a joy to use.
The only hiccup was getting the compilation integrated into the build process. We handle it with direct loading of the CS files while working locally with coffescript.js loaded as well. That way code changes are available as soon as you refresh the page. Our build script for the app (when packaging it up for staging/prod) pre compiles the CS files so there's no compilation lag in prod.
I've been experimenting with node.js for a side project and its pretty easy to setup a project entirely in CS. There's a pretty good template with CoffeeScript/Express/Mongoose to use as a template here: https://github.com/olafurnielsen/form5-node-express-mongoose...
I don't know what your stack is, but FYI on Node we use Connect/Express middleware that automatically compiles CoffeeScript files to JS -- and in production, caches the results -- before serving them. No manual building/compiling/packaging needed at any point. You might find something similar for your stack if you haven't already looked:
https://github.com/jashkenas/coffee-script/wiki/Web-framewor...
The node.js side project is a RESTful API so all the CS is server code (no front end CS or JS). It all builds automatically and no special config there. I started if off using a stripped down version of the template I linked to above (though removing mongoose and using node-postgres async instead).
The custom build process is for out main app JackDB[1]. It's written in Java and it's a combination of taglibs and a build script. We have a check in there for dev/prod to decide whether to serve precompiled JS files or the original CS files (if its local dev). We did it this way so it fits into our nginx caching setup which marks all static assets as permanently cached (max-age + public). The build process also prefixes the resources with the git revision so each new build forces the client to get the latest and greatest.
coffee -cwo js cs &
echo "alert 'x'" > cs/x.coffee
echo "<script src='js/x.js'></script>" > x.html
open x.html
echo "alert 'x2'" > cs/x.coffee
refresh x.html
This sounds a bit like the bi-polar LISP programmer. Belief that he groks things much better than most programmers grok things? Check. Belief that most people are behaving irrationally? Check. Belief that it's foolish to make an obvious choice? Check.
http://www.lambdassociates.org/blog/bipolar.htm
JavaScript is now a moving target. It's what the examples for new "HTML5" features and libraries are written in. It's what an open source library should be written in if you want it to get traction, and to attract other developers. While it may be a good choice for quickly modifying code on a single project, it isn't as good of a choice for something to get great in as JavaScript is.
There's the saying that you need to know JavaScript in order to write CoffeeScript, but you really only need to be able to read JavaScript in order to write CoffeeScript. My guess is that a lot of developers who mostly write CoffeeScript would trip over simple things for a while if they tried switching to JavaScript. This might keep them from seizing opportunities for JavaScript developers such as contributing to an existing JavaScript project or an open source library that's implemented in JavaScript.
While CS supports some features with different syntax than JS, it really isn't THAT hard to pick up, and for the most part I don't care too much. I've mostly written JS, but have used CS for certain bits.. I find the syntax much more pleasant in unit testing, and for grunt tasks in particular (though will likely be using gulp in the future over grunt).
This presentation did show a lot of the niceties with dealing in Classes with CoffeeScript, a lot of which I wasn't aware of... I do tend to keep my objects a bit differently than many though.. I tend to treat my objects as either libraries or effective structures, rarely do I add "smart" methods to my entities.
Will it get me to switch everything, no.. however, multiline strings are nearly enough to get me to strongly consider .coffee for a lot of cases, often I will even mix into .js projects in node.
The big thing for me with Node.js was you could have whole application in one language. Apparently it's not possible anymore because you have to deal with CoffeScript.
To make a different point, and one which can easily get missed -- the other unsatisfactory argument I hear somewhat often is: "I love the idea of CoffeeScript, except for X feature, which is terrible, so I won't try it." Where X can stand for scoping, classes, optional parentheses, and the like...
One of the big goals with the CoffeeScript compiler -- despite all of it's flaws and imperfections -- was to annotate and make accessible the source code, and to keep it tiny (I think still somewhere ~< 2,000 LOC), so that if there's one particular thing you don't like, you're free to change it. So if you're intrigued, but dislike X, feel free to fix X before using it, and send your patch along as a pull request. Open source, right?
http://coffeescript.org/documentation/docs/grammar.html#sect...
Too much focus placed on how those who dislike it haven't given it a proper shot. This could be true, but six paragraphs is overkill. You make a few points: A) they aren't being open-minded enough, B) they are the typical blub programmer, and C) they shouldn't feel bad because it's perfectly understandable to do something so mundane. Had I been someone who had spent a few hours toying with CS and left unconvinced, you'd have lost me pretty quickly.
You mention that you hated it too, at first, but not early enough. I'd submit that you're far more likely to lose readership than to open eyes with this method.
Also, as someone who isn't particularly set against CS, I didn't enjoy reading so much about how I shouldn't feel bad for hating CS at first sight. I didn't.
It's a telling sign about a language when the language advocates have to employed negative psychological ploys to convince people (or convince themselves) to use the language.
If CS is actually terrible, why don't we talk about what actually makes it terrible? I can't comprehend the notion that evaluating the advocates of X will demonstrate anything concrete about X.
I didn't intend to come across as so preachy in my post. I was just writing freely without (too) much worry.
Live and learn. =)
var newArray = _.map(_.filter(array, function(item) {
return item % 2;
}), function(item) {
return item + 1;
});
vs newArray = (item + 1 for item in array when item % 2)
Uh huh. var newArray = _.chain(array).filter(function(item) {
return item % 2;
}).map(function(item) {
return item + 1;
}).value();
I often use CoffeeScript + UnderscoreMy experience was exactly the opposite. When I first saw CoffeeScript, I loved it, I started using it in my projects, it was really nice. But once I learned to use it, I stepped into all the annoyances caused by a bad use of significant whitespace, the many ways of doing the same thing, the tooling overhead, and the lack of readability.
In the end, I realised that there was a negative balance of good and bad things introduced by CoffeeScipt. It wasn't worth it. JS wasn't a bad language after all, and the improvements of CS were minimal if you know JS well.
However, TypeScript is perhaps the better long run alternative to plain, boilerplate laden JavaScript. Bringing type safety into the mix is pretty compelling, going to check out TS at some point.
There will have to be CS2 that introduces new semantics and old apps will have to be migrated.
I'm sure there will be a new version of CS when ES6 becomes widespread, but why would old apps need migrating? CS produces regular JS, and thus will be 100% compatible with ES6.
https://github.com/Sage/streamlinejs
I'd love to talk on or write about Streamline at some point too.
It's quite useful outside of rails in that sense I'd say. It could have just as easily been done in JavaScript but I'm not a fan of the syntax(fuck curly braces)
I'd maintain that just about anything out there can be used outside of the context you think of it in.
Asking if coffeescript is useful outside of rails is similar to asking is perl is useful outside of scripting, it's a poor and misguided conception that languages can only be used in a certain way or with a certain tool.
I'd say that's true much more often than not that if you know a language well you can build complex applications with it.
Also, yes, plenty of people outside of the Rails community use CoffeeScript (I'm one of them)
CoffeeScript is no more of a "hack" than any compiler. Compilers take one language and turn it into another.
I think you mean Ruby syntax, not semantics. CoffeeScript's semantics are much closer to JavaScript than Ruby in almost every way.
It may have it's roots in the Ruby world, but I'd wager more non-Rubyists use CS at this point than Rubyists. I'm one of them.
arr = new Array 3
arr.push 4
( alert el for el in arr )
arr.forEach alertIt's an inherent phenomenon that DSLs will change and come and go at an incredibly fast rate. I just don't find it worthwhile to write code that is dependant on the DSL du jour and pigeonhole myself and whatever unlucky sole has to maintain the legacy code in the future. Imagine being dumped on a mountain of ColdFusion legacy code.
I just find it kind of absurd is all.