3 ms·
> “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you
by enriquto 5y ago
> “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?”
By becoming more clever! That's the very principle of learning: to become more clever.
The act of debugging your own code to become more clever is a well-known learning technique called "Kernighan's ladder", precisely due to this inspiring quote.
- scollet 5y agoThat's fun. I remember writing a little bit of clever (at the time) code for simplicity and speed. Ended up doing debugging and sanity checks via napkin math to confer with my partner because it was easier than reading through the function.
- vegai_ 5y ago>The act of debugging your own code to become more clever is a well-known learning technique called "Kernighan's ladder", precisely due to this inspiring quote. According to Google, you seem to be the first person to use that phrase.
- Cthulhu_ 5y agoI guess you have a point, but, you don't only code for yourself; the quote applies to others as well, and in practice, few people code in a vacuum. Don't write clever code; the problem you're solving with code is difficult enough already.
- TeMPOraL 5y ago> Don't write clever code; the problem you're solving with code is difficult enough already. No, it isn't. 90% of times it's just tons of dumb boilerplate. The sheer amount of that code creates its own accidental complexity, so if a bit of clever code can cut it down by an order of magnitude, by all means go for it. Other people may need to spend a bit of learning up front, but they'll come out better at the other end, and they won't have to pay the ongoing price of wading through vast amounts of code noise.
- saeranv 5y agoExactly. I've never interpreted that quote other than encouragement to continue writing "clever" code in order to get better at coding, despite the fact it's typically used to suggest the opposite.
- inopinatus 5y agoAs the party guilty of trotting that quote forth, I have to say I couldn't agree more. Nevertheless, the time lag to improving enough to debug your own very clever code may for some be recalled as a period of floundering dismay, self-doubt, and potentially crippling imposter syndrome. At these times it is important to be willing to ask for help. Corollary: at any given time, write code that is only slightly beyond your ability to debug, so that the competence delta is small.
- otikik 5y agoI am not an English native speaker, but I think when you learn you become wiser, not "more clever*. There are things that can increase your "cleverness" like deliberate practice (of mental calculations, of memorization), meditation or deleting social media to increase your attention, or using drugs. I would not call that "learning". Learning is similar to "installing new software on existing hardware". Becoming more clever is similar to "installing new hardware".
- imtringued 5y agoI guess I misunderstood it and falsely applied it to make my code clearer and more effective. I failed to become "more clever" in the process and now I'm doomed to write unclever code other people understand better.
- enriquto 5y agoNobody said that you should never write unclever code. Unclever code is alright, but it does not help you to improve. When you want to have a "cleverness boost", you can try to write and debug some clever code thus applying Kernighans's lever. You are not doomed, you can start doing that at any time. I'm sure that the unclever code that you get to write most of the time will even improve after that process.