It’s not my one trick, of course, but it illustrates my usefulness. It’s more maintainable not just because it is shorter but also because it has decades of theory behind it. Drawing the connection unlocks inspiration from entire branches of math. And the speedups from standing on the shoulders of giants go far beyond the constant factors from vectorized instructions.
I’m not disagreeing with you (I don’t think?), but just pointing out a mistaken lesson someone new to programming might draw from your comment.
it’s more maintainable not just because it is shorter but also because it has decades of theory behind it
Being shorter is way down the list of things you should consider when you’re thinking about how to make your code more maintainable. In fact, longer code is often more maintainable. As a trivial example, imagine a variable called x and the alternate name for it: seconds_since_midnight
I’m not sure there is a good rule of thumb wherein you say “shorter/longer is more maintainable”.
What about after the maddening 8-hour debug session where you finally realise they were storing a number representing seconds since noon in that variable?
It’s not my one trick, of course, but it illustrates my usefulness. It’s more maintainable not just because it is shorter but also because it has decades of theory behind it. Drawing the connection unlocks inspiration from entire branches of math. And the speedups from standing on the shoulders of giants go far beyond the constant factors from vectorized instructions.
I’m not disagreeing with you (I don’t think?), but just pointing out a mistaken lesson someone new to programming might draw from your comment.
Being shorter is way down the list of things you should consider when you’re thinking about how to make your code more maintainable. In fact, longer code is often more maintainable. As a trivial example, imagine a variable called
x
and the alternate name for it:seconds_since_midnight
I’m not sure there is a good rule of thumb wherein you say “shorter/longer is more maintainable”.
What about after the maddening 8-hour debug session where you finally realise they were storing a number representing seconds since noon in that variable?
It’s good to keep in mind that whomever wrote the code is probably a freakin’ liar!