4 ms·
> The golden rule in making understandable code is making it as short as possible. Absolutely not true, in any way. And I fail to see a single reasonable argu
by DagAgren 7y ago
> The golden rule in making understandable code is making it as short as possible.
Absolutely not true, in any way.
And I fail to see a single reasonable argument for why writing "tk" should be better than writing "token". Just name things using real words. Cryptic abbreviation does not help anyone.
- JustSomeNobody 7y agoOnce you know “tk” means token, you don’t need it to be “token”.
- kick 7y agoAbsolutely true. C4 doesn't go far enough. The source of my favorite C compiler, on the other hand: http://www.kparc.com/b/ http://www.kparc.com/b/
- still_grokking 7y agoThis source would look beautiful as pattern on a t-shirt or socks. :-)
- userbinator 7y agoYou will mentally read "token" every time you see "tk" anyway. The same way you "grep", "ls" or "cd" --- it easily becomes as natural as any other language, unless you consciously try to stop yourself from learning.
- 0xffff2 7y agoI read "grep", "ls" and "cd" as "grep", "el ess" and "cee dee". I don't even know what grep and ls stand for.
- coolreader18 7y agols is a shortening of "list", i.e. list directory contents, and grep is apparently Global Regular Expression Print.
- bumby 7y agogrep comes from an amalgamation of commands for a global search applying a regular expression and printing the results I.e., “g/re/p” ls just simply stands for list
- a1369209993 7y agoNo, we won't; "token" is a function name, not a local variable name. If it was written "token", we'd have to substitute it back to "tok" every time we read it.
- DagAgren 7y agoNo, you won't. You'll read "tk", and then do a little mental substitution to "token". It's tiny, but it adds to your mental load. You could just not do that, and be happier. Why add the extra indirection?
- userbinator 7y agoThe first time you'll read "HN", and then do a little mental substitution to "Hacker News". Why do humans abbreviate?
- psychoslave 7y agoUnfortunately, it seems that most of the time it's because they are lazy sheeps who don't even have a clue of what means 90% of the abbreviations they use, but don't want to look like the sole ignorant in the room asking it, and won't take time to look at it by themselves later, even for the 10% they most often encounter.
- lifthrasiir 7y agoI do agree that `tk` is an unusual abbreviation, but `tok` for `token` is pretty common in language implementations. `ty` for `type` is also usual. The names are not only read but also being manipulated in your mind. You will see tons of `token`s and `type`s throughout the code and while you can read them fine you will have hard time dealing with them in your mind. For uncommon names that are usually read out of the context, longer names are preferred. For common names or local enough names, short mnemonics that evoke the original name really help. When it is not possible, people usually develop a specialized terminology for them.
- DagAgren 7y agoI don't have any problem holding properly named variables in my mind, so I don't see what the problem is here? The only issue is that if you are writing gigantic statements with lots of variables, it gets too long to see properly. And that is a sign that you are writing too large expressions, and need to start cutting them into smaller parts anyway.
- jfkebwjsbx 7y agoBad example. ls and friends are meant to be typed constantly and therefore need to be short.