- Inconsistent, forced type safe equality
Coffeescript forces ALL explicit equality to be type safe, all
==are transformed into
if test then something()is evaluating the truthyness of test -
test == true.
- Automatic return from functions
- All functions are anonymous
Its not possible to declare a named function, which prevents certain possible weirdness with hoisting, but makes it difficult to test and profile the code you write.
- Somehow-Even-More-Confusing Scoping
Because scoping is not declarative in Coffeescript, its very easy to make major errors and not see them. To understand, have a look at this example.
The console.log at the end prints
[2, 4, 6, ..., 24]when run. This weird problem is totally non-obvious from looking at the CoffeeScript. Essentially, you can't shadow a variable in a sub scope in CoffeeScript... which can lead to really difficult-to-debug problems.
There are a variety of small, opinion based things that annoy me about CoffeeScript. Since I'm writing a blog post about it, I might as well list them out.
- Significant Whitespace
This is a debatable one, I know - I personally don't like significant whitespace. I'll leave it at that.
Functions as Parameters are Difficult to Read
When passing functions as parameters to other functions, the lack of deliminators makes things really confusing - for example:
$http.get('/info').then (response)-> doSomething(response); if response.thisThing somethingElse() else showWeirdResponseMessage() , (err)-> showErrorMessage()
I personally find this very difficult to read and understand and its very easy to make mistakes. Wrapping each function in parenthesis can make things slightly better, but not having a nice way to pass functions as parameters in a callback driven, asynchronous world is a major oversight.
Longer Ternary Syntax
This is a really minor one, but I just think its silly that a syntax that is all about shortening the syntax removed the ternary operator. Instead we're forced to do
if something then 1 else 2.
Finally, this quote from the creator, Jeremy Ashkenas, says the rest:
I can't justify using it for the main DocumentCloud development. Imagine trying to hire someone. "You'll have to learn to use a new language that we made up..."- ReadWriteWeb