Convention: does it provide and enforce conventions for writing and organizing my code? Are these conventions clear, easy to pick up, and easy to work with?
Abstraction: does it isolate me from details and platform quirks I don’t care about? Is working with the abstraction layer usually more expressive and convenient than the alternative? Does it allow you to work at a more consistent level of abstraction?
Sugar: does it make it fast and pretty for me to write the code I need to write? Does it offer helpers that make common problems less irritating?
Coffeescript is probably the best example of a tool I wish I’d applied these axes to. I had a bad introduction to coffeescript, watching rubyists try to make it work like ruby on an older application where only a suite of flaky Jasmine tests was in coffeescript and trying to find the source line-number of a failing test was a perennial nuisance. But I think the bigger problem was that I had the wrong expectations for how coffeescript was going to help me. If I’d just asked about these three different aspects, I would have figured it out a lot sooner.
First, coffeescript discourages the use of globals by wrapping every file in an immediately-executing function. While nothing prevents you from adding variables to the global scope, the small barrier of needing to explicitly make a variable global is enough to encourage me to find better ways to share state between features.
Encourage a single way to do “classes”
example: this common case where you decide whether to use the
? operator based
on whether you want to ask if a value is falsy or whether it’s null-like.
1 2 3 4 5
I’m glad to have the flexibility to do both, but coffeescript doesn’t change the fact that I need to understand the difference.
This is the other place where coffeescript shines, of course. I think of
layer on top of it, but now that I have it, I’m pleased about all those minutes
I save not typing
The loop comprehension feature, while easy to abuse, is a particularly pleasing example:
1 2 3 4 5 6 7 8 9
1 2 3 4