3 ms·
If you can say it in five words, why say it in five letters? That's the problem with a lot of old Unix/C stuff in particular. Consider atoi. If you're not
by partialrecall 7y ago
If you can say it in five words, why say it in five letters? That's the problem with a lot of old Unix/C stuff in particular. Consider atoi. If you're not already steeped in the arcane language of unix beards, how are you meant to divine that it means "a[rray] to i[nteger]"? It's simply unreasonable. By comparison, string->number seems pretty intuitive. (That ascii-art arrow may be straying from the code-as-prose ideal, but I think it's intuitive enough to make up for that.)
Of course, there is a sense in which lisp-like code can be dense while at the same time having verbose names for things. Consider this and an idiomatic C equivalent: (filter odd? '(1 2 3))
That is simultaneously intuitive and verbose. Would it be improved by changing `filter` to `fltr` or some nonsense like that? I don't think so. But even though it hasn't code-golf'd the names for things, it's doubtlessly shorter (denser) than the equivalent in idiomatic C using the mangled shortened identifiers that are par for the course in that language. Density through good abstractions is superior to density through short names and abbreviations.
Could you do both? Sure. But for what marginal gain?
- deleted 7y ago[deleted]
- Carpetsmoker 7y agoI never claimed atoi is a good name or that the least amount of characters is always better. But str_to_int() is better than, say, convert_string_to_integer(), while still being equally clear.
- partialrecall 7y agoFor each their own I suppose, but I think string->number looks nicer than either. Writing str instead of string is like writing ppl instead of people. Some people seem to prefer it (https://hn.algolia.com/?query=ppl&type=comment https://hn.algolia.com/?query=ppl&type=comment), but personally I find it almost intolerable.