Why I won't use CoffeeScript (sadly)
Update: I might change my mind now. Why? I just discovered a js2coffee converter. Furthermore Denis Knauf told me about a
tl;dr: I would have loved to program client side using a Ruby-like syntax. But in the end, CoffeScript raised more disavantages than advantages.
- Verbose Java-like syntax,
- Strange and insanely Verbose Object Oriented Programming,
- No easy way to refer to current instance of a class (
thisdoesn’t work really well),
It was so annoying at a point, I had thinked about creating my own CoffeeScript.
Here is my experience:
- I had to install
npmjust to use CoffeeScript. It wasn’t a big deal but it wasn’t as straightfoward as I expected either.
--watchoption of coffee was also really helpful to help in the translation. But I had to write my own shell script in order to follow an entire directory tree.
- Verbosity: I gained 14% line, 22% words, 14% characters
- Added another compilation step to see how my code behave on the website.
- I have to learn another Ruby-like language,
- meta-programming become a poor experience,
- I must convince people working with me to:
- remember to launch a script at each code session,
- learn and use another ruby-like language
The last two point were definitively really problematic for me.
But even if I’ll have to work alone, I certainly won’t use CoffeeScript either. CoffeeScript is a third party and any of their update can break my code. I experienced this kind of situation many times, and it is very annoying. Far more than coding with a bad syntax.
ruby2js script for example2. But I believe it would be a really hard task just to simulate the access of current class for example.
@x translate into
this.x. But the following code will not do what I should expect. Call the foo function of the current class.
-> class MyClass foo: -> alert('ok') bar: -> $('#content').load( '/content.html', ( -> @foo(x) ) ) # That won't call MyClass.foo
The only way to handle this is to make the following code:
-> class MyClass foo: -> alert('ok') bar: -> self=this $('#content').load( '/content.html', ( -> self.foo(x) ) )
@ notation lose most of its interrest for me.