TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Intro to CoffeeScript

121 pointsby aseemkalmost 12 years ago

16 comments

zalewalmost 12 years ago
&gt; <i>What I find sad, though, is that most people who dislike CoffeeScript don’t truly know it. They haven’t taken the time to really learn it, or even try it. Their reactions are usually knee-jerk, or based on fallacies. [...] The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know. </i><p>Oh, wow. I&#x27;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&#x27;t use it. While I&#x27;m a fan of bracketless whitespace significant langs (Python, Sass, Haml) CS&#x27;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&#x2F;lodash as an example come to mind).<p>And from the slide:<p>&gt; <i>And as of July 2013, it&#x27;s also the tenth most popular language on GitHub! That&#x27;s more than Objective-C, ActionScript, C#, Clojure, Go, Groovy, Scala</i><p>Yay github charts as evidence of industry value.<p>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.<p>&#x2F;&#x2F;edit: care to explain the downvote?
评论 #6159108 未加载
评论 #6159092 未加载
评论 #6158641 未加载
评论 #6158377 未加载
评论 #6159907 未加载
评论 #6160279 未加载
sdevlinalmost 12 years ago
&gt; The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know.<p>This is a mildly insulting, as is the invocation of Blub.<p>CoffeeScript doesn&#x27;t have a ton of exotic features. String interpolation, list comprehensions, and class definitions (!) are all familiar to programmers from other languages.<p>I&#x27;m guessing that a lot of people have weighed CoffeeScript&#x27;s feature set against its overhead and decided the trade just isn&#x27;t worth it.
评论 #6158639 未加载
评论 #6158299 未加载
评论 #6158512 未加载
评论 #6158563 未加载
sehropealmost 12 years ago
This is a fantastic slide deck. The per slide comments below are great too. Particularly on an iPhone as you read them simultaneously.<p>We&#x27;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&#x27;t imagine writing JS again. It&#x27;s just <i>objectively</i> better. Less code to write, easier to read, minimal cruft, and a joy to use.<p>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&#x2F;prod) pre compiles the CS files so there&#x27;s no compilation lag in prod.<p>I&#x27;ve been experimenting with node.js for a side project and its pretty easy to setup a project entirely in CS. There&#x27;s a pretty good template with CoffeeScript&#x2F;Express&#x2F;Mongoose to use as a template here: <a href="https://github.com/olafurnielsen/form5-node-express-mongoose-coffeescript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;olafurnielsen&#x2F;form5-node-express-mongoose...</a>
评论 #6158369 未加载
评论 #6158742 未加载
benatkinalmost 12 years ago
&gt; What I find sad, though, is that most people who dislike CoffeeScript don’t truly know it. They haven’t taken the time to really learn it, or even try it. Their reactions are usually knee-jerk, or based on fallacies.<p>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&#x27;s foolish to make an obvious choice? Check.<p><a href="http://www.lambdassociates.org/blog/bipolar.htm" rel="nofollow">http:&#x2F;&#x2F;www.lambdassociates.org&#x2F;blog&#x2F;bipolar.htm</a><p>JavaScript is now a moving target. It&#x27;s what the examples for new &quot;HTML5&quot; features and libraries are written in. It&#x27;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&#x27;t as good of a choice for something to get great in as JavaScript is.<p>There&#x27;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&#x27;s implemented in JavaScript.
评论 #6158801 未加载
jashkenasalmost 12 years ago
It&#x27;s funny to see some of the comments on this thread (or the comments on any thread about CoffeeScript), demonstrating <i>exactly</i> what Aseem is writing in his post. Delicious irony, that.<p>To make a different point, and one which can easily get missed -- the other unsatisfactory argument I hear somewhat often is: &quot;I love the idea of CoffeeScript, except for X feature, which is terrible, so I won&#x27;t try it.&quot; Where X can stand for scoping, classes, optional parentheses, and the like...<p>One of the big goals with the CoffeeScript compiler -- despite all of it&#x27;s flaws and imperfections -- was to annotate and make accessible the source code, and to keep it tiny (I think still somewhere ~&lt; 2,000 LOC), so that if there&#x27;s one particular thing you don&#x27;t like, you&#x27;re free to change it. So if you&#x27;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?<p><a href="http://coffeescript.org/documentation/docs/grammar.html#section-16" rel="nofollow">http:&#x2F;&#x2F;coffeescript.org&#x2F;documentation&#x2F;docs&#x2F;grammar.html#sect...</a>
nsmarttalmost 12 years ago
I mostly enjoyed the slides, and I&#x27;m interested in CoffeeScript, especially since I&#x27;m going to be working a little in Node in the near future. This post is a critique on the blog post, rather than on the slide content, which was more or less fine.<p>Too much focus placed on how those who dislike it haven&#x27;t given it a proper shot. This could be true, but six paragraphs is overkill. You make a few points: A) they aren&#x27;t being open-minded enough, B) they are the typical blub programmer, and C) they shouldn&#x27;t feel bad because it&#x27;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&#x27;d have lost me pretty quickly.<p>You mention that you hated it too, at first, but not early enough. I&#x27;d submit that you&#x27;re far more likely to lose readership than to open eyes with this method.<p>Also, as someone who isn&#x27;t particularly set against CS, I didn&#x27;t enjoy reading so much about how I shouldn&#x27;t feel bad for hating CS at first sight. I didn&#x27;t.
评论 #6158734 未加载
评论 #6158395 未加载
bentlegenalmost 12 years ago
Why does everybody compare CoffeeScript against vanilla JavaScript? I find using underscore makes my code sufficiently elegant that I&#x27;ve never felt the need to switch to CoffeeScript.
评论 #6159196 未加载
评论 #6158232 未加载
ceronmanalmost 12 years ago
&gt; Indeed, I, too, dismissed CoffeeScript when I first saw it. But now that I’ve actually learned it and used it, I see how wrong I was: CoffeeScript truly is more powerful than JavaScript.<p>My 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.<p>In the end, I realised that there was a negative balance of good and bad things introduced by CoffeeScipt. It wasn&#x27;t worth it. JS wasn&#x27;t a bad language after all, and the improvements of CS were minimal if you know JS well.
virtualwhysalmost 12 years ago
I&#x27;m all for CS, use it daily, love it. It&#x27;s absurd how much less code you have to write compared to the generated JavaScript. Huge win for this alone.<p>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.
chadhietalaalmost 12 years ago
I stopped using CS because it&#x27;s going to have some issues when ES6 becomes more of a real thing. For instance, how is CS going to handle for&#x2F;of loops when ES6 has it&#x27;s own for&#x2F;of loops that is slightly different. The same goes for class and super.<p>There will have to be CS2 that introduces new semantics and old apps will have to be migrated.
评论 #6158202 未加载
评论 #6158322 未加载
fordialmost 12 years ago
It would have been great if he had mentioned IcedCoffeeScript at some point too. Coffeescript by itself is &#x27;ok&#x27; but IcedCoffeScript - at least on the serverside - is fantastic.
评论 #6158425 未加载
sergiotapiaalmost 12 years ago
Is CoffeeScript used much outside of Rails? If not, wouldn&#x27;t it be a better idea to focus on mastering javascript so it applies globally?
评论 #6158164 未加载
评论 #6158118 未加载
评论 #6159156 未加载
评论 #6158186 未加载
评论 #6158618 未加载
评论 #6158167 未加载
评论 #6159116 未加载
评论 #6158296 未加载
评论 #6158108 未加载
评论 #6160180 未加载
评论 #6158199 未加载
agilebytealmost 12 years ago
I would just say that there are big differences between a JS `for` loop (`for in` in CS) and an ES5 `forEach`. The fact that you are creating a new function scope and are not returning all elements as you <i>might</i> expect:<p><pre><code> arr = new Array 3 arr.push 4 ( alert el for el in arr ) arr.forEach alert</code></pre>
pspeter3almost 12 years ago
My biggest issue is that the language can be ambiguous and I&#x27;m not sure how to check what I&#x27;m compiling to without running the short cut all the time in Sublime Text 2
评论 #6158830 未加载
itsbitsalmost 12 years ago
for me its upto the developer to choose between JS or CS. I used CS for some time and i liked it. But still i preferred to switch back to JS only to not to waste my time in correcting CS syntax issues and play with JS.
consonantsalmost 12 years ago
Yes, let me learn this domain specific language for a domain specific language so that I can learn another domain specific language whenever this one stops trending.
评论 #6159107 未加载