Farewell CoffeeScript
github.com
github.com
The author makes some odd assumptions about CoffeeScript's intentions, ie language reduction and protecting against "evil code". All of this ignores the real main benefit, which is cleaner syntax, which means less finger typing and easier comprehension of a large and complex code base.
There was a time when JavaScript was the only real choice for browser-based web development. There were compilation tools like GWT, but they were heavyweight and generated the JavaScript equivalent of binary, completely detached from the source code. Now that the JavaScript++ languages are here (CoffeeScript, TypeScript) and well-supported in the browser thanks to source maps, I find it hard to imagine why people continue using raw JavaScript with all the bloated keywords, curly braces, etc (apart from legacy code bases). Usually it's because they haven't used anything else, and are content to focus on the negative of Coffee etc and stick to what they already know.
I was originally very intrigued by it, and used it heavily in one of my projects, but after working with it for a year I went back to JS for the next project. I still want something better than JS but coffeescript definitely isn't the answer.
If I already need to be a JavaScript expert to make my code run properly across all target browsers, I don't see a value adding another layer to debug.
Then I found that after working that way for a number of months I no longer needed it. I picked up enough JavaScript along the way that I could I drop the training wheels and I am not looking back.
The constraints are minor, the gains of coffeescript quite clear. There is no important gains in sight that justify moving to js. So why changing ?
Changing for the sake of change, is silly and something all of us do. A successful project needs as much technical stability as feature stability.
As someone who has been writing JavaScript for 15 years and has never felt like writing it is a struggle I would ask... are they?
I don't know what it solves. Writing a language designed to be written by hand in another language and then transpiled to the first language you have to know in the first place to be any good at it has always seemed like a horrible non-solution. You don't know what you've actually written at that point.
Syntax, variable niceties are great too, of course, but do not define CS alone.
For me, it is the gray area, I am a language geek so the semantics of js are quite clear but js bytes me sometimes. In coffeescript, The syntax is better and the semantics are better exposed , so it may be a net win.
For a guy who is already familiar with coffeescript, the change will be likely negative. Familiarity with coffeescript is likely to generate bugs in javascript. You're moving from one language to another after all. The impact won't be huge as the two are quite close, but there is no reason to change in the first place.
Also, JS switch/case statements follow the good-old maldesign from C where each body has to end with break or it falls through.
Variable hoisting?
Getting rid of a dubious build step that doesn't get any real advantage in this project, but makes it slightly more obscure for people unfamiliar with CoffeeScript (and a lot of new developers don't bother to learn it now that ES6 is quite tolerable)?
It's a battle of philosophies. I value efficiency and just getting things built, so I love CoffeeScript. It's a breeze to read and write. OP wants control and customization, more 'freedom.'
If I was working on a team with OP and he instituted this, I would quit on the spot.
- JS produced by the CS compiler isn't that great, to be honest.
- Plain JS is easier to debug than CS, even though you have source maps.
- Source map chains don't always work. So using CoffeeScript together with another tool which produces its own source maps could be a problem.
- Build time could go down without CS
- Way more devs understand JS than CS
- I might have considered sticking with CoffeeScript if it had plans to evolve, perhaps add more functional features. But jashkenas considers CoffeeScript mostly done. As michaelficarra mentions in https://github.com/jashkenas/coffeescript/issues/3073, "CoffeeScript needs to evolve or die"
- When ES6 gets implemented, just get rid of the ES6/ES7 transpiler and you have plain JS
I haven't read the article, but if you ask me CoffeeScript is dying.
I've found that coffeescript prevents whole classes of bugs, and makes lots of javascript warts nicer to live with.
For example, you don't seem to run into scope issues, and it's a lot easier to bind this to what you expect.
5% more code (if it really amounts to that) is still more code, too! No code is like no code.
From the README: "The architecture is a simple MVC heavily dependent on RxJS" and that's exactly how it looks, just linking different components together without hardly any glue code.
If all his code looks like this, he certainly doesn't need it to be in CoffeeScript.
So will "use strict";
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Deleted comment
Sorry for the misunderstanding.
I'm just waiting for ReSharper the Vim plugin!
I disagree with this sentence.
Anyone use coffeescript only to reduce the code verbosity, maybe wrong.
It's a simple evolution of thejavascript language that currently has an old syntax. Do not confuse old syntax with popularity and power of the language itself.
Many programmers have figured out that readability and clarity code are a good stuff, especially looking forward if the project will become big and much complex.
It's why Swift or Rust were created, not why their code is less verbose of Objective-c or C, but because they have a clear syntax, and it helps programmers in their productivity.
However when you get to building non-trivial systems with javascript you need to pick a style and stick with it. In that regard you can do much worse than CoffeeScript.
But I can't. JS is everywhere and I don't have time to learn several programming languages.
CoffeeScript was a way to make JS more enjoyable to me. You can say that CoffeeScript is still another language to learn but once that is related to JS, you learn both simultaneously, killing two birds with one stone.
Even more perplexingly, there are methods like `merge` in examples.coffee/js which, in the Javascript version, are effectively compiled Coffeescript, and which are less concise than they should be; why does the Javascript version call `Array.prototype.slice.call(arguments)` when arguments is never treated as an array outside of length and subscripting, both of which the arguments object already supports? Coffeescript does it specifically so that using arguments as an array is transparent to the user. Why is it necessary in the Javascript version, when the only effect is the creation of an additional object?
It's somewhat silly to argue for Javascript on the basis of it offering finer control over the code, and then not using that control. If you just don't like Coffeescript, fine, but let that be your argument.
In my case I never considered CoffeScript because of the indentation/semantic spaces thing. I had to work with those languages sometimes and the troubles I had when moving blocks of code around and copy/pasting examples from the net have been enough to undo any gains from a cleaner syntax (assuming it is cleaner). No Python either here, obviously, nor HAML or SLIM for templating. Irony: they've been invented in the Ruby community which somewhat prides itself of using a language with a better syntax than Python (I second that, Python looks too much like a C with defs which is maybe the reason for its success: familiarity.)
Also, not to mention (maybe my editor lacks this feature) I like using ^M to jump from end to beginning braces of blocks, and I can't seem to do that in CS.
However, all of these arguments just boil down to "this is my personal preference"
I rather use the real thing without any extra layers.
But then again, that's the same way C (and many other languages) was invented (as far as I understand), to replace assembly, for example, and it's still alive and kickin'.
I guess there is a subtle difference in here somewhere.
Back when portability didn't matter to me and languages like Pascal and C only had compilers that produced blooty slow as molasses code.
The thing is, JavaScript is portable.
But nothing more. Bad (or neutral) practice is still possible in coffeescript. Mixing coffeescript and javascript files is easy. Classes can be defined any way you please (if you don't mind using something other than the "class" keyword).
I think the only reason for me to switch to something else from coffeescript is if some similar language where to get a nicer type system exactly right. I'm not holding my breath though.