3 ms·
Just counting the tokens in the codetree is not an acceptable measure of brevity, because it implies that adding primitives to a language always makes it more p
by mdemare 19y ago
Just counting the tokens in the codetree is not an acceptable measure of brevity, because it implies that adding primitives to a language always makes it more powerful as long it makes your application shorter just once.
But adding primitives has a cost too. You could just have let, or you could have a let for one value, one for more values, one for more values initialized as nil, or as 0, or as an empty string, etc.
In Ruby I write expressions like this a lot:
condition ? string : ""
I'd like to say:
condition &&? string
This would make my applications shorter, but, I claim, less readable and no more powerful.
To measure power, it is not enough to look at succinctness - you must hold something else constant too.
- pg 19y agoSure. There are lots of pathological counterexamples to the length test. I took that as understood.
- derefr 19y agoJust as an aside about your Ruby example: (condition && string).to_s (string if condition).to_s both work (though the first fails when passed false instead of nil.) I use something similar in quick-and-dirty Ruby shell scripts: n_to_generate = (ARGV.shift || "0").to_i