Kernighan's Lever (2012)
Kernighan's lever highlights that while clever coding can complicate debugging, facing challenges fosters skill development, making debugging a valuable learning opportunity that enhances programming capabilities.
Read original articleKernighan's lever is a concept derived from Brian Kernighan's observation that debugging is often more challenging than writing code. He suggests that if programmers write code in a clever manner, they may find themselves unable to debug it effectively. This notion serves as a caution against overly complex coding techniques, which can hinder problem-solving. However, the article argues that cleverness in programming is not static; it is a skill that develops through practice and experience. The process of debugging can actually enhance a programmer's skills, as it forces them to confront and solve problems that push their abilities. This dynamic creates a motivational mechanism—referred to as Kernighan's lever—where the effort to implement functionality leads to greater long-term growth as a programmer. The article emphasizes the importance of engaging with challenges that match or slightly exceed one's current skill level to foster improvement. It also warns against consistently opting for simpler coding solutions to avoid debugging difficulties, as this can lead to stagnation in skill development. Ultimately, the act of debugging is framed as an opportunity for learning and growth, reinforcing the idea that tackling complex problems can lead to increased cleverness and capability in programming.
- Debugging is often more difficult than writing code, according to Kernighan.
- Clever programming techniques can hinder debugging but also promote skill development.
- Engaging with challenging problems can motivate programmers to improve their skills.
- Avoiding cleverness in coding may lead to stagnation in personal growth.
- Debugging is an opportunity for learning and enhancing programming abilities.
Related
Laziness is the source of Innovation and Creativity
Laziness can spur innovation in programming by encouraging efficiency and problem-solving. Embracing laziness responsibly can lead to creative and efficient solutions, promoting a balance between productivity and creativity.
Programmers Should Never Trust Anyone, Not Even Themselves
Programmers are warned to stay cautious and skeptical in software development. Abstractions simplify but can fail, requiring verification and testing to mitigate risks and improve coding reliability and skills.
Holding a Program in One's Head (2007)
The article highlights the cognitive processes in programming, emphasizing mental retention of code, the impact of distractions, and advocating for smaller teams and independent work to enhance creativity and understanding.
Thoughts on Debugging
The article emphasizes the importance of reproducing issues in debugging, effective communication, logging for real-time analysis, clear documentation for recognition, and warns junior engineers about the absence of favors in business.
Magic Isn't Real
The article reflects on a software developer's journey from confusion to clarity in programming, emphasizing the importance of experience, continuous learning, and tackling challenges to gain deeper understanding.
That all evaporated within a month of initial release, when I had to diagnose my first production defect. It turns out that usable call stacks are a very nice thing to have in your exception reports! I could already see that, in the long run, this design was going to cost us more to maintain than it saved us in initial development costs. Soon after, the team and I agreed to revert to doing it the crufty old boring way, and we were ultimately glad we did.
I've subsequently had similar experiences with other "easy button" compute frameworks, IoC containers, etc. They were all high quality pieces of software that did a good job of doing what they do, and possibly did save on initial development costs. But when the beeper wakes you up at 3AM, nothing beats a readable call stack that corresponds very closely to the lexical structure of the code.
The moral of the story for me has been that it's always good to experiment with clever tools techniques. But you should also remember that you have the option to thank them for the learning experience they provided while choosing to put something unsexy into production.
> Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)
> Rule 4. Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.
It's a bit ironic then for this post to rely on such a convoluted interpretation instead of the simple, dumb one.
> ... since you are confident that you understand how the code works, having written it yourself, you feel that you must be able to figure out what is going on. ... Suddenly you see it, and you're blinded by a bright light as all the pieces fall into place.
There's a particular frame of mind like 'I feel that there's a bug in this specific bit of code'. I often find that once I make that shift it's suddenly easy to see the bug. I have tried to cultivate this feeling, but it's not easy to suddenly conjure up. A bit like flow state.
Somehow there is a mismatch.
In the graph depicting flow, you see that you achieve best results flow- (and as a bonus, grow-) wise, when you take up challenges slightly harder than according your comfort zone.
The mismatch is that debugging is quite a large notch harder than implementing. There might be a race condition, or you understood a used API differently from how it was implemented. Or some FPGA's software registers are poorly documented. So you spend a lot of time in the frustration/imposter syndrome zone, as opposed to the comforty growing, flow zone.
The effect is much more explicit when the code or design is not from your own hand. You first need to understand other people's clever tricks or paradigms and find the holes in the reasoning or even worse, in the several half baked refactorings that happened afterwards.
Not an axiom I would agree with, and I find it strange the rest of the article builds on this assumption.
(seriously though, liked the read and it makes me feel a bit more sane when i struggle to debug my own code! kind of feels weird that can happen but this puts a positive twist on it which i feel is likely quite true :))
Being better at debugging doesn't necessarily makes you better at writing less complex, more approachable code. Though debugging should teach you which patterns cause bugs or impede debugging.
And what do you do once you are so skilled your software doesn't have bugs? :P
Regarding self improvement, Aaron Swartz put it better here: https://web.archive.org/web/20240928215405/http://www.aarons... (tldr: do things you don't like)
Related
Laziness is the source of Innovation and Creativity
Laziness can spur innovation in programming by encouraging efficiency and problem-solving. Embracing laziness responsibly can lead to creative and efficient solutions, promoting a balance between productivity and creativity.
Programmers Should Never Trust Anyone, Not Even Themselves
Programmers are warned to stay cautious and skeptical in software development. Abstractions simplify but can fail, requiring verification and testing to mitigate risks and improve coding reliability and skills.
Holding a Program in One's Head (2007)
The article highlights the cognitive processes in programming, emphasizing mental retention of code, the impact of distractions, and advocating for smaller teams and independent work to enhance creativity and understanding.
Thoughts on Debugging
The article emphasizes the importance of reproducing issues in debugging, effective communication, logging for real-time analysis, clear documentation for recognition, and warns junior engineers about the absence of favors in business.
Magic Isn't Real
The article reflects on a software developer's journey from confusion to clarity in programming, emphasizing the importance of experience, continuous learning, and tackling challenges to gain deeper understanding.