On 17 Dec 2020 10:00 -0800, from lm at mcvoy.com (Larry McVoy): > Most old guys get it. But my guys were seasoned and still would try and > slip stuff in. > > I think it is part of being really smart, it's a puzzle for them and they > "win" if they can do something clever. I always replied "It is write once, > read many. Optimize for reads". It's depressing how much of my job was > pounding that message home year after year. I would rather say to optimize for debugging, which in my experience happen even more often than (casual) reads. My personal experience is that most code pretty much just sits there until there's (a) a bug involving it in some manner, or (b) a new feature that requires somehow modifying it. When you're trying to figure out why in the $DEITY $EXPLETIVE $VOLUME the code doesn't do what you think it should, _any_ amount of "clever" is usually too much. Yes, it might save a few lines of code somewhere. Yes, it might be fun to play with a brand new language or compiler or framework feature. Yes, every once in a long while there's actually an actual, good reason to go the "clever" route because it provides some _significant_ advantage. Performance for performance-critical code is one such example. (I think that so far, professionally, I've written _one_ piece of code where performance was actually critical enough to warrant getting clever. More often, trying to be clever has just ended up confusing the compiler.) But if it takes the next person a week to figure out why the code doesn't work right when a more direct approach would have made the error obvious at a glance without any significant downsides other than that it doesn't use Feature X, then almost every time that's going to be a really, really, _really_ bad trade-off. What was that saying again? The person who will need to fix the bugs in or build upon your code is a sociopathic axe murderer who knows where you live, so write your code accordingly? For me, I try quite hard to steer clear of "clever" unless the cleverness offers some seriously compelling advantage. And I don't even consider myself particularly old. -- Michael Kjörling • https://michael.kjorling.se • michael at kjorling.se “Remember when, on the Internet, nobody cared that you were a dog?”