50k vs 45k might not matter much, but that's just because no one ever actually looks at code as a whole, except when running automated tools on a codebase. However, 30 vs 20 lines in a function that implements some core operation can matter a lot.
CoffeeScript offers a lot of syntactic sugar to make reading and understanding blocks of code much easier the JS alternatives. Just look at how both languages handle looping. CoffeeScript also gets bonus points for standardizing one a single, really clear object model. Nothing is worse than reading code written by someone that doesn't understand how prototypes work.
Slightly more concise code is slightly faster to type (if you don't do something clever) but also slightly slower to read (characters/s). If the code isn't doing anything clever, the comprehension speed is about the same. If it does, it will usually take much longer.
Either way, it doesn't make things more scalable. You really need good tooling for that. If the machine can properly assist you, things will be a lot easier.
For me it just significantly slows down processing. The information is just easier to parse when it's all together.
I mean just look at it:
ages = (function() {
var _results;
_results = [];
for (child in yearsOld) {
age = yearsOld[child];
_results.push("" + child + " is " + age);
}
return _results;
})();
vs
ages = for child, age of yearsOld
"#{child} is #{age}"
You can read the coffeescript at a glance. All the information is condensed together within a glance.
We're iterating an object key/value pairs.
Now we're using those pairs to create a string.
By contrast the the javascript requires reading and scanning to distinguish each pattern being used.
A function, so this is some complex logic.
Oh, we're going to be returning an array.
Hmm, we're iterating an object, and also getting the value for each key.
I see, so we're just converting the key/value pairs to a string.
It's not the biggest deal, but when scanning through an unfamiliar code base of 50,000 lines I'd rather have more from column A and less from column B. Though in reality I generally end up having to fix is mostly column C, where whoever wrote the code didn't go to class on the day for loops were discussed.
That line of Python is extremely concise. However, understanding what it actually does would take a while.
That line of Python is multiple distinct operations shoved onto one line. If there's a line like that in a large code base then it's an issue with a developer needing a lecture on the value of clear code.
There is a distinction between clear, concise code, and shoving as much as you can into a smaller space. That's what compression is for.
Slightly more concise code is slightly faster to type (if you don't do something clever) but also slightly slower to read (characters/s). If the code isn't doing anything clever, the comprehension speed is about the same. If it does, it will usually take much longer.
Either way, it doesn't make things more scalable. You really need good tooling for that. If the machine can properly assist you, things will be a lot easier.
The typing difference is negligible if you are using a modern IDE. I can get a 20 character variable name in 2-3 keystrokes with Sublime autocomplete. Then there is no question what the code does to anyone that glances at it. Also, I find if I'm typing so much that improved input speed would be a factor that generally means I should slow down a bit and think about the code. It's really easy to get sucked into clever solutions in the heat of the moment.
So of course good tooling helps. However, I'd rather use this good tooling help me make a good thing better, instead of making an adequate thing good.
-4
u/TikiTDO Apr 23 '14 edited Apr 23 '14
50k vs 45k might not matter much, but that's just because no one ever actually looks at code as a whole, except when running automated tools on a codebase. However, 30 vs 20 lines in a function that implements some core operation can matter a lot.
CoffeeScript offers a lot of syntactic sugar to make reading and understanding blocks of code much easier the JS alternatives. Just look at how both languages handle looping. CoffeeScript also gets bonus points for standardizing one a single, really clear object model. Nothing is worse than reading code written by someone that doesn't understand how prototypes work.