Kernighan's Lever (2012)
linusakesson.net
linusakesson.net
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.
Just because your event-based framework didn't give you debugging information, it doesn't mean that FRP sucks, and just because your IoC containers depend on undiscoverable undocumented voodoo setup procedures, it doesn't mean IoC containers suck.
And ok, now I'll do the meme... both of those things do suck (for almost every use case people put them through), but it's not because of the perfectly solvable issues you see on their C# implementations.
> 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.
It's been a while since I read Elements of Programming Style, but most of it is in the form of "here is some bad code we encountered, here is how we made it better, and this is the lesson we can learn from it". Some of these are pretty specific and outdated (e.g. IIRC "avoid Arithmetic IF" is one of them) and others are just basic common sense advice that holds up well today. It's all very down to earth and pragmatic and centred around real-world code.
Taking a quote out of that context and then musing that maybe perhaps possibly the author could have meant something different/deeper with it is not really helpful.
> ... 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.
While I think it is wise to heed the warning implicit in Kernighan's aphorism, the question it poses can be answered by noting that finding errors provides additional information, allowing you to debug it without first getting any more clever. What makes debugging harder than writing is that in the former, you are dealing with reality, not your simplified, incomplete and possibly tacit assumptions about it.
And then repeat, with the new thing that should be impossible but is still happening, until I get to the root cause.
The precise feeling I try to avoid leading PR reviewers into.
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)