Live data from Hacker News

Poll: Have you moved from JavaScript to CoffeeScript?

news.ycombinator.com

71–80 of 178 posts

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

#72
post #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?

Well, you do choose Javascript when you could have chosen PHP and had even more overlap. Presumably, because you believe it is better for the tasks. Similarly, Coffeescript authors believe that Coffeescript is better than Javascript -- even if there's less overlap.

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

#74

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.

Alright, I buy your argument. Now go and do everything in assembler, right now. Deadline is yesterday. What are you looking at?? Go!!!

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

#75
post #55

I have used Javascript exclusively on client and server since late 2008. First Rhino and then Node. Before that I used Rails. I can understand the syntax gripes that some people have towards Javascript but I think this has more to do with a Ruby notion of "elegance" coupled with a lack of familiarity with Javascript then it does with actual issues with Javascript. In fact, I prefer Javascript to Ruby. I have gone the…

You may have been misinformed -- the values of direct, raw, fast code are a big part of the reason why CoffeeScript works the way it does, and why many scripts can end up running faster after getting ported to CoffeeScript. The golden rule of CoffeeScript is to avoid adding any library code to the runtime, and to avoid introducing any special calls, to the greatest extent possible.

Many folks rely on a "forEach" (or "each") iterator for all of their loops over arrays, because it's convenient. Unfortunately, it's also a very slow way to write an inner loop. CoffeeScript's comprehensions expand into regular JS loops over arrays and objects, so you get native speed, without the hassle. This:

    for item in list
      sum += item.amount
Compiles into this JavaScript:

    var item, _i, _len;
    for (_i = 0, _len = list.length; _i 

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

#76
As a developer who really loves JS (not because of its syntax - which is fine - but because what I'm able to do with it) I just don't really get CS.

I wan't to be able to debug the code I'm writing in the code I'm writing. The extra layer of sugar seems sickly sweet, nice for a taste but overpowering in bulk.

I think I'm prone to wanting to go lower and seeing how things work in the layer beneath. I'm fascinated by C and assembly languages and how my JS ultimately sits on top of those. I think if CS was interpreted at the same level as JS I'd be more interested.

I guess it really depends on how much you use JS and whether CS makes your work easier. I'm always looking at what complexity I can throw away, I think CS may be just that.

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

#77

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 have pretty much moved to using CoffeeScript exclusively over JavaScript. One of the minor complaints I have (overall, it is magnificent) is that the looseness of the syntax sometimes leads me to doing a kind of guess-and-check style of programming where I write something, then try to compile it to see if it did what I expected. An example of this is when calling a function, you need a comment to continue the function arguments onto the next line, unless the argument on the next line is an object literal.

The only real problem is that debugging with CoffeeScript adds an extra layer of complexity. I know that this is more or less inevitable, but it is really the only major pain point that I encounter on a day-to-day basis.

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

#78

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…

Yes, functions in JavaScript have dynamic "this" instead of lexical "this" -- that's part of the point we're discussing. It helps when defining ad-hoc prototypes, but hurts when writing callback functions (or any nested function, really) ... and is an active point of concern for the ES committee.

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

#79

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.

Maybe this sounds nitpicky but I'm just not a fan of languages that use indentation to denote block structure. It turns trivial code manipulations into tedious line-by-line exercises. I don't like it in Python or Haskell either. Other than that I see a lot to like in CS though.

For some reason Python's indentation really bugs me, but I am totally ok with it in haml, sass, and yaml.

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

#80
post #7

CoffeeScript is amazing, I use it for everything including writing native iPhone apps (using titanium). Search for Album Plus in the app store. or visit http://www.albumpl.us/

I checked out your app, very interesting how native it feels. Would you recommend Titanium, in general?

Titanium is a mixed bag. For simple applications, it's great, but as soon as you need to do something a little bit complicated, the learning curve goes up quite a bit.

For example, in my app (http://iphone.albumpl.us) I had to write a couple of small custom objective-c modules to get some camera/image stuff to have sufficient performance. But overall being able to write most of it in CoffeeScript, is so much better (enjoyment-wise and speed-wise) than having to write everything in objective-c.

Post reply on HN