4 ms·
but how can we keep the code readable even for people who haven’t encountered time.sleep before? Contrarian opinion: You don't. You make people look up and int
by userbinator 5y ago
but how can we keep the code readable even for people who haven’t encountered time.sleep before?
Contrarian opinion: You don't. You make people look up and internalise such information; that way they'll actually learn, as otherwise they'll forever stay within the realm of "beginner". Perhaps that's a goal for those who want to make programmers fungible (and I suspect a lot of the "readability" movement is merely an extension of that), but I don't think that's something we should encourage.
- rhinoceraptor 5y agoHow is rote memorization of the arguments the stdlib of a language the difference between a beginner and an expert? I forget those kinds of things all the time, even for the language I use 99% of the time.
- userbinator 5y agoHow is rote memorization of the positions of the keys on a keyboard the difference between a beginner and an expert? Or for that matter, the spelling of words and their meaning in your choice of (human) language. We call those who can't do the latter "illiterate". Imagine if you had to look up almost every word you speak or write in a dictionary.
- rhinoceraptor 5y agoBeing able to touch type makes you a good typist, and being good at spelling makes you good at spelling. Those two don't make you a good programmer or writer.
- jitl 5y agoPerhaps sleep in $YOURLANG is essential/trivial so there’s an argument that you should memorize it. OF course! It’s just one bit of info. But there are more APIs than sleep that take a number. Are they guaranteed to be consistent? No. What about `someVendorApi.setTTL(ttl: number)`? Is this also another thing to be looked up and internalized? What if there are hundreds of APIs that take numbers? I would rather have my team spend time internalizing good design rather than the trivia of what units are associated with every numeric argument in every codebase.
- l33t2328 5y agoYou’d prefer we made our code as hard to read as possible to increase job security?
- Spivak 5y agoAlthough there is some merit to learning by repetition and using memorization to keep core concepts top of mind, this is a very bad example of it since it’s literally just trivia. There is nothing at all fundamental about time.sleep being seconds. People memorize it because the have to and have used it enough times. If time.sleep took a timedelta it becomes impossible to use incorrectly with a type checker since the caller specifies their own units. There is no merit to worshiping ambiguous design.
- tharkun__ 5y agoDisagree. What you say works at a small startup. Absolutely. My reality and lots of other people at companies with larger code bases: you need to constantly look at code you have never seen before in one of many languages used at your company using one framework or another that is out of date by years or just came around the corner and you just heard the name of for the first time. This is the reality of many an architect or team lead or principal engineer. Of course you will say: why make everything better for them, works fine for me who I only ever work in language X with framework Y? I agree that makes sense for the you of now. Why care? Think about the future you. The principal engineer you. The architect you. Heck even just the 9 months from now you when you have moved on to the next framework. Never mind any other changes.
- jackblemming 5y agoPeople have died because airplane mechanics thought they were working with one unit instead of another. Don't be a macho tough guy who thinks you'll never slip up.
- gpderetta 5y agoSure, but how does the reader of the code know if the writer of the code did internalize this information or just made a mistake?