Follow

"Debugging is twice as hard as writing the code in the first place.

Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

-- Brian W. Kernighan and P. J. Plauger (in The Elements of Programming Style)

@fribbledom Ah yes but when you get that once in a month brain wave it just works. :-P

@fribbledom I got this lecture from a professor after handing in a perfectly working Haskell solution which re-balanced a tree. It was one line and +- half of the screen width.
The student-assistants had been taking pages of notes while going over it (like I did constructing it) and eventually called in the professor.

I was asked to explain my code, without looking at my notes, that was embarrassing.

The best analogy the professor gave, all in good fun, was that everyone can be a Biologist by pointing at a rabbit and saying: it works right?

@fribbledom The first statement does not match my experience. Writing code requires a good guess at how a correct solution looks like for all cases. Debugging is often merely understanding how a singular example execution did not fit that model.

@Drahflow I think the statement is about cleverness when writing the code, not conceiving an algorithm.

@fribbledom This is the infinite curse of programming, as it also means that it is easier to write your own code than to use code or tool that is already written — even reading the documentation is hard work, and if you make up things as you go, you don't have to read anything!

@deshipu
@fribbledom

From time to time I search for guides and best practices to read and understand code written by somebody else. And albeit you'd think that this is a very common task, work your way into an existing codebase, both guides and tooling are very underrepresented.
E.g. you'd find how-to's for new and fancy JavaScript libraries about 1000 times more often then how to to start reading existing open source code to to begin contributing.

@Chaos_99 @fribbledom You know, if I was to explain how I do this, I couldn't. There are simply so many different things you can do, and you choose them at a hunch, and often end up doing some weird mix of multiple strategies.

I have to say that there are very few guides on reading books as well — sure, they teach you how to read words and sentences, but then you are pretty much on your own. Especially when you pick up a new kind of book that you didn't read before. How are you supposed to do this?

@deshipu @fribbledom
Actually, reviewing books and code is very similar. And there are tools and methods worth teaching about. 'Diagonal reading', annotation strategies, transferring to standardized diagrams for flow analysis, spotting tropes and patterns.
You do find way more in-depth analysis videos on youtube for books and films than you do for code still.
(Yeah, I get it, they are more entertaining ....)

@fribbledom TDD helps to detect overly optimistic programing early 😅

@fribbledom
Readable even if verbose code is better then showing off with a bunch of esoteric pseudo functional syntax.

@fribbledom that's...if you understand code as well as mr. K

if you're a normal human being it's harder than even O(n) and definitely above 2n imho

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!