Live data from Hacker News

Poll: Have you moved from JavaScript to CoffeeScript?

news.ycombinator.com

61–70 of 178 posts

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#61

This is going to be a very interesting poll result. Even 5 or 10% penetration is something remarkable, for a language as widely-used as JavaScript. If you feel like providing any more color beyond your vote, your impressions after using CoffeeScript in anger -- I'd love to hear 'em.

I've never done front end before (I just hate the JS syntax, so I've avoided it, besides a few jsonp requests) but with CoffeeScript I was persuaded to give it a try. Here is my problem. Nothing is Google-able. Even basic things that I get caught up on the answer on IRC is usually "look up how to do it in JS, and then reform it to CS". Maybe I'm starting on the wrong stuff, but even though the syntax is wonderful, ac…

> "actually using libraries is a pain"

Maybe that is your source of confusion.. when you write CS code, you can use any existing JS library. The syntax is just different for what you write.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#62
post #56

SyncPad switched its webclient from JS to CoffeeScript. In terms of human-readable code, we reduced the lines of code by ~30%. It's cleaner and more concise. I feel our code is more managable because of CoffeeScript. In terms of the generated JS, I really appreciate that CoffeeScript creates an abstraction that will implement JS best practices and consistency At this point, any JS work I do is done with CoffeeScript

My projects have been the same way; I spend less time writing "function" and more time making stuff happen.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#63
post #31

I don't like the Windows experience of CoffeScript. That's what's holding me back. I think I would use it if it had better Windows support. As far as I know CoffeScript requires node.js, npm and cygwin. Am I wrong?

You're fully wrong. The CoffeeScript compiler is written in CoffeeScript and you find it in the extras/coffee-script.js JavaScript file. If you can load that in some JS runtime environment, no need for Node/NPM.

Cygwin is the current way of "Node on Windows" but there will be much better / "more native" Node support for Windows coming in the next 4-20 months ;)) anyway, you don't need Node for Coffee. It only provides the Node integration pieces because the developer(s) do a lot of Node work themselves and it's a great way to write server-side code for Node for people coming from Python/Ruby etc.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#64

I think you guys obsess too much about programming languages. I doubt that anybody doing something useful cares about THAT "wohooo expressiveness". JS is alright, dammit. You don't need CS, you need to get your shit done.

I used to think like that. Then I found the next logical iteration from "just get it done" is "get more done faster with less code". Hence, CS works better than JS for getting that youknowwhat done.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#65

Earlier quoted context omitted.

jQuery generally abuses (or takes advantage of, depending on your perspective) the value of "this" in its callback functions, in places where it would really be better to have an explicit argument. For example: AccountView.prototype.render = function() { $(".account").click(function(e) { // `this` is now the same as `e.currentTarget` // But `e.target` is also useful. // And you what you really want is for `this` // t…

@jashkensas what you want though would break the way closures are handled in javascript. What you should do if you still want access to Accountview is to trap a variable with a reference to it in the closure. Using your jquery example: AccountView.prototype.render = function() { $(".account").click( { that: this }, function(e) { // 'that' now holds a reference to AccountView }); }; If you don't want to use (or you ar…

No, it's a jQueryism. How would it break the way closures are handled in JavaScript?

You realize you're replying to the author of CoffeeScript?

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#66

I have nothing against CoffeeScript, and I've used it on a few things, but in general I find JS to be an enjoyable language to work in. If I had more issues with the syntax or something, I might find the switch to CoffeeScript worthwhile.

Yes, and why would I want less of JavaScript's syntax in my life when it has so much overlap with other languages I use like PHP?

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#68

I think CoffeeScript looks quite cool, but I'm afraid introducing a compilation layer will complicate my life and lead to weird issues which will cancel out any productivity gains. And while Javascript may not be perfect, it's good enough to get the job done.

What's the problem with the extra compilation step? You can simple use coffeescript by adding "script type=text/coffeescript" tags to your code while developing, and when you are done, just compile and deploy. Or you can simply authomate the task (google for instructions).

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#70

This is going to be a very interesting poll result. Even 5 or 10% penetration is something remarkable, for a language as widely-used as JavaScript. If you feel like providing any more color beyond your vote, your impressions after using CoffeeScript in anger -- I'd love to hear 'em.

This is a lame reason not to have tried it yet, but I need to first skim a short tutorial that shows how to integrate with jQuery and ideally also shows simple uses of Backbone and Underscore in coffeescript. BTW I love Backbone and Underscore and thanks to them (and also node) JS is actually more fun than ever.

You won't be needing underscore.js in coffeescript. Most of the underscore.js provides sequence abstractions and coffeescript does them out of the box. Things which aren't provided by coffeescript(and there aren't many) can be easily done in coffeescript directly.
Post reply on HN