Live data from Hacker News

Why CoffeeScript Isn't the Answer

walkercoderanger.com

61–70 of 148 posts

Re: Why CoffeeScript Isn't the Answer

#61

This article proves not that CoffeeScript is flawed but that Jeff Walker doesn't understand how to use it. For instance, his first example is: # BROKEN func 5, { event: (e) -> if e.something 36 else 45, val: 10} Anyone with more than a day's experience with CoffeeScript knows that it's much better to express this with the simpler: # far better func 5, event: (e) -> if e.something 36 else 45 val: 10 Note how just drop…

The argument that "you just don't understand" can excuse any flaw in anything.

If someone can reasonably choose to formulate something, and for that formulation to pass static verification but do something totally unexpected, the language is at fault, not the author.

Re: Why CoffeeScript Isn't the Answer

#62
post #59

Disclosure: I have never used CoffeeScript. However, based on the article, the death-knell against CoffeeScript for me was the variable scoping rules. With no variable declaration keyword (a la var, my, local, private), adding a variable assignment anywhere could radically change the variable scoping. I'm done, this isn't suitable for prime-time, time to go somewhere else. I spent too many years in the 80s working wi…

> With no variable declaration keyword (a la var, my, local, private), adding a variable assignment anywhere could radically change the variable scoping. > I'm done, this isn't suitable for prime-time, time to go somewhere else. So does that mean Python and Ruby are out the window too? It's really never been an issue in either of the three languages.

The problem in Python and Ruby is less obvious because you rarely have big, nested closures. In JavaScript those are pretty common (module pattern, mocha test suites, etc.).

Re: Why CoffeeScript Isn't the Answer

#63

Disclosure: I have never used CoffeeScript. However, based on the article, the death-knell against CoffeeScript for me was the variable scoping rules. With no variable declaration keyword (a la var, my, local, private), adding a variable assignment anywhere could radically change the variable scoping. I'm done, this isn't suitable for prime-time, time to go somewhere else. I spent too many years in the 80s working wi…

The scoping issue is real, but it's very easy to mitigate. I think the real issue is to make sure you just don't ever use (file) global variables. You should enforce scope with the "do" operator:

  changeValue = do ->
    value = 42
    lastValue = null
    (newValue) ->
      lastValue = value
      value = newValue
That hides the new variables in a closure and they no longer leak to the the enclosing scope. This is cleaner code overall since you no longer have some variables at the top level where you can't be sure of how many functions are using them without searching.

Re: Why CoffeeScript Isn't the Answer

#65

Sometimes I think that most CoffeeScript, ClojureScript, etc. programmers are people who were advanced in other languages before they learned JavaScript. There are quite a few programmers who have no issues with these "bad parts" or "really bad parts" because they cut their teeth on them, and these numbers are growing: Most people now learn JavaScript as their first language. JavaScript already won, and things like C…

Exactly this. I used CoffeeScript when I had hard time understanding JavaScript. Once you truly gasp JavaScript, anything else will just look like a waste of time.

Re: Why CoffeeScript Isn't the Answer

#66
post #39

I do have some frustrations with CoffeeScript as outlined here - I find the unless keyword infuriating because it forces me to read backwards: a = 123 unless b == 2 "OK, so a is set to 123. Oh, unless b is 2. That's annoying" That said, my answer is to just not use the unless keyword. If you don't like CoffeeScript classes, you don't have to use them. IMO you could write CoffeeScript using only the kind of functional…

I really like that syntax, I think it reads well.

Of course, I've known Perl for 20 years, so that might have something to do with it. :-)

Re: Why CoffeeScript Isn't the Answer

#67
post #42
post #34

CLOJURESCRIPT IS THE ANSWER! no question about it

The problem I have with clojurescript is i couldnt find any closurescript tutorial that did not involve java. Let's say i want to start using closurescript,like coffeescript. i want to do npm install -g closurescript then closurescript compile myscript or closurescript myscript. How do I do that? If closurescript folks want their language to be popular with javascripters i need to be able to do that. Right now,search…

clojurescript's compiler is written in java. I think there are a few obstacles that keep clojurescript from basing clojurescript purley on javascript.

Nevertheless, if this is all that keeps you away from clojurescript -- too bad. Because it is a great alternative to pure javascript.

Re: Why CoffeeScript Isn't the Answer

#68

This article proves not that CoffeeScript is flawed but that Jeff Walker doesn't understand how to use it. For instance, his first example is: # BROKEN func 5, { event: (e) -> if e.something 36 else 45, val: 10} Anyone with more than a day's experience with CoffeeScript knows that it's much better to express this with the simpler: # far better func 5, event: (e) -> if e.something 36 else 45 val: 10 Note how just drop…

All you did was remove the curly braces and take out a comma that probably didn't compile in the first place though. I don't get what's far better about it.

Technically, Coffeescript should know better than to balk at the braces that is abstracting out when they're explicitly declared. And any compiler is going to groan when it gets to that dangling comma.

Re: Why CoffeeScript Isn't the Answer

#69
post #8
post #5

Answer to what? What's wrong with Javascript in the first place?

For me, coffeescript was the answer to the question "How can I write javascript with python-esque whitespace block formating?" I suspect the author was asking something like "what can replace javascript?"

I also quite like coffeescript for its "everything is an expression" mentality—it makes functional programming very nice.

The absence of this feature is why me and Python don't get along.

Re: Why CoffeeScript Isn't the Answer

#70

This article only proves that when doing it wrong, CoffeeScript causes problems. No parenthesis make nested calls unreadable? Simple add parenthesis for the inner calls. Like in any other language with optional parenthesis (Ruby) too. Too long statements are unreadable? Don't write them. Maintaining an 80 or 100 character line limit is good coding practice anyways.

That's kind of the point of the article: If it's easy to get it wrong in CoffeeScript, i.e. CoffeeScript has its own bad parts, then you're better off just learning to deal with the bad parts in JavaScript directly.
Post reply on HN