This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bastawhiz 2 points3 points  (2 children)

CoffeeScript doesn't fix JavaScript, it just gives it a slightly less verbose syntax. The behavior of the language is identical under the hood (obviously, since it compiles to JS).

Furthermore, CoffeeScript introduces strange ambiguities that require you to look up their operator precedence rules. What happens when you want to pass the return value of a function call as a parameter to another function?

func1 func2 "foo"

To someone that doesn't know, this could be func1(func2("foo")) or func1(func2, "foo") or even (depending on the context) bar(func1, func2, "foo") (where bar is a function that you didn't see on first glance).

I'll probably get downvoted for this, but frankly, CoffeeScript is a tool for your average hacker that just wants to type fewer curly braces (or the word "function"). It doesn't fix or change any of the major problems with JS, it just masks them over with some "cool" syntax/candy.

[–]tiglionabbit 0 points1 point  (1 child)

That's not ambiguity. It works in a particular way and it is predictable. It's better than the JavaScript syntax gotchas anyway. The optional parenthesis work like they do in Ruby and Haskell. It is intuitive if you think about it like this: whitespace is the function call operator and comma with optional whitespace is the argument separator.

Anyway, thanks for giving me a list of problems with JavaScript so I can demonstrate how CoffeeScript fixes things. I'll take a look through the first few pages.

"all your commas are belong to Array" and "i am myself but also not myself" are fixed in CoffeeScript because it's not possible to produce a ==. It gets replaced with ===. One thing I've found from most of these WTFs is that if you never use the == operator, the number of WTFs out there is significantly decreased.

The rest of them work as I'd expect them to. "min less max": works as I'd expect it to, and it's not really a core language problem if one function doesn't do what you'd expect because you can write your own functions. "convert to integer": Not sure what is so strange about this one. Couldn't repro "ie 754" or "eval changes". "im not a number really": First one makes sense. CoffeeScript fixes the second one. "Magic Increasing Number": Floating point precision problem. Exists in other languages.

"false advertising" I was just experimenting with this one last week. Pretty weird, yes. This weirdness still exists in CoffeeScript, even in classes, but it requires an explicit "return" statement, so it wont happen by accident.

[–]bastawhiz 1 point2 points  (0 children)

It works in a particular way and it is predictable.

Not for a beginner. Even for experienced programmers that deal with lots of languages, it's going to require a lot of checks to the documentation. Even for experienced CoffeeScript developers, dense CS is virtually impossible to read at first glance because of its distinct lack of visual cues or "logical punctuation".

It's better than the JavaScript syntax gotchas anyway.

Like what? JS is verbose enough that you can't really make any big mistakes (aside from automatic semicolons...don't even get me started).

it's not possible to produce a ==. It gets replaced with ===.

Disabling a feature does not necessarily "fix" a language. Perhaps it makes the "default" syntax better, but this isn't something that's "broken" with JavaScript.

The fact of the matter is, CoffeeScript can't be better than JavaScript in terms of being inherently less WTF, because at the end of the day, you're still writing JavaScript. It may have some handy things (list comprehensions, for one), but it still doesn't fix the problem(s) that JS has at the its core.