Why I moved away from CoffeeScript
Recently I’ve published a blog post about CoffeeScript where I’ve explained how you can use CoffeeScript as a transpiled language to write more expressive JavaScript code.
In this blog post I’ll discuss why I moved away from CoffeeScript and started to love JavaScript.
Why I used CoffeeScript
After a bunch of years as a Ruby on Rails developer I came to Meteor when Version 0.6.5 was released. I’ve heard and read about Meteor as early as 2012 but was not convinced enough to give it a try.
Sitting in my room with some spare time late in the evening I thought “well just give it a shot and see how far they’ve come”. And I was blown away. After finishing the example application in under two hours I was absolutely sure that this is the future of web development.
The only problem was that I had absolutely no idea what all that code I had copied and pasted into my text editor was actually doing.
As a Rails developer I was used to expressive and “good looking” code which reads often as simple as plain English. With JavaScript I was just confused. I was not that into JavaScript development, although I could select and manipulate DOM elements with the help of jQuery (:-D).
CoffeeScript made it easy for me to do some simple DOM manipulations while keeping the code as expressive as my Ruby code.
I tinkered around a found out that CoffeeScript was available as a meteor code package.
“That is awesome. Let’s install it!”
Not knowing what goes on
I started my brand new Meteor application by copying and pasting the JavaScript code of the Meteor tutorial into the Js2Coffee converter to get a starting point. The code looked really awesome and was very concise although I had no idea what was actually going on under the hood.
After a few hours I got a complete code base in CoffeeScript which would act as a go to resource for copy and pasting code for other Meteor apps I would start later on.
But as soon as I got to a point where I had to write my own code with callbacks, objects and anonymous functions I got stuck. So I started to look at other code and tried to implement it in CoffeeScript. Always converting it back to JavaScript to see if I got it right.
Compile time
A few months later I had a good understanding what code I needed to write in order to accomplish certain tasks.
I read a lot about callbacks, functional programming, prototypes and all the other concepts which go alongside JavaScript. I started to thin if I should transition to JavaScript but I still thought that CoffeeScript would be a great choice because it deals with edge cases and takes care of certain JavaScript pitfalls.
So it was no surprise that we chose CoffeeScript again when we started working on a new Meteor project which has grown into one of the largest Meteor applications I’ve ever contributed to.
Because of the huge codebase it takes the CoffeeScript compiler ~10–20 seconds to build the whole application. So you need to get rid of that “CTRL + S everything” habit if you don’t want to wait “forever” to see your change reflected on the screen or a loud surrounding because of your MacBooks fans who try to cool your machine down during reoccurring compilation time.
A break in the development flow
As a Meteor developer you often use your browsers development tools to e.g. check the contents of your collection or play around with your code.
You maybe also use the Mongo or Meteor shell to debug your code or test something out.
What code do you have to write? Yes, it’s JavaScript.
One language for everything which is one of the big advantages of Meteor doesn’t hold anymore. You have to switch between CoffeeScript and JavaScript back and forth during development which slows you down.
JavaScript to the rescue
With the release of ES6 I thought that I should dive deeper into JavaScript.
I read through a bunch of books and attended online courses to learn JavaScript from the ground up.
And what should I say. I was blown away at what you can do with this language. It maybe has some quirks, but the available resources for the language are nearly endless and developers have developed concepts to work around that downsides (e.g. IIFE to encapsulate your code).
JavaScript is everywhere today and one of the most used languages out there.
I’ve transitioned to JavaScript (ES6) and don’t want to go back anymore!
No more “How would this look in CoffeeScript?” “How do I indent the code so that I get the JS object I want?”.
Conclusion
Don’t get me wrong. CoffeeScript is a great language and a nice tool if you want to write concise and good looking code which compiles to JavaScript!
But for me as a Meteor developer it was maybe just “too fancy”. I’m glad that I made the transition to JavaScript and learned it from the ground up so I can now read other peoples code (even if it’s not a Meteor project) and understand how Meteor works behind the scenes.