Live data from Hacker News

Rob Pike: The Best Programming Advice I Ever Got.

informit.com

121–130 of 142 posts

Re: Rob Pike: The Best Programming Advice I Ever Got.

#121
post #8

You are only so smart. Once the complexity of the programming model reaches a certain point a debugger is necessary to validate and discover the true nature of a system. Often that point is quite low.

Yuck, a debugger exposes so little of the world that it's only appropriate in highly targeted approaches.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#122
post #72

At what point in a neophyte programmer's life should he/she switch from the "immediate & non-stop coding" Khan Academy approach recently discussed here on HN to this Ken Thompson "take a moment and think first" approach? Isn't there the danger that they might not be able or motivated to make the switch?

Use debugging to form a mental model.

When I'm trying to understand foreign code in less than enough time, I instrument it (almost always at inputs/outputs) and try to treat functions as black boxes. In an ideal world the black boxes would be working.

Data flows are as important as algorithms. See this thing from Guy Steele.

http://dreamsongs.com/ObjectsHaveNotFailedNarr.html

In particular:

Fred Brooks, in Chapter 9 of The Mythical Man-Month, said this:

"Show me your flowchart and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowchart; it'll be obvious."

That was in 1975.

Eric Raymond, in The Cathedral and the Bazaar, paraphrased Brooks' remark into more modern language:

"Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data structures, and I won't usually need your code; it'll be obvious."

That was in 1997, and Raymond was discussing a project coded in C, a procedural language. But for an object-oriented language, I think this aphorism should be reversed, with a twist:

"Show me your interfaces, the contracts for your methods, and I won't usually need your field declarations and class hierarchy; they'll be irrelevant."

I think, however, that practitioners of both procedural and object-oriented languages can agree on Raymond's related point:

"Smart data structures and dumb code works a lot better than the other way around."

Re: Rob Pike: The Best Programming Advice I Ever Got.

#123

Then again, how many times have you found a bug caused by a single line or function call or bit of syntax that didn't do exactly what you thought, that was easily overlooked? Particularly in someone else's code in a language that isn't your main one. I think line level interactive debugging is valuable precisely because it tells you what you really know for certain at the local level, and so lets you reason more effe…

You can discern those through thinking, too. "Well, it got to this point and broke... hm... well, what do I know about this environment at this point. What assumptions am I making? Since this assumption isn't being fulfilled, it must be this issue... and that was caused here"

Also, this was pair-programming, both people are making sure that what's written is what's intended to be written and so those issues should be (mostly) gone.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#124
post #114
post #103

Earlier quoted context omitted.

The best advice I had (from a theoretician) was that I should not try to randomly fix my code but I should understand why it does not work. How to do that? Can you prove (in the mathematical sense) that it always does what you want?

Giving a full proof that takes language semantics into account is very difficult. I think it isn't a practical way to verify programmes but maybe it'll be in future.

The advice isn't to mathematically prove anything, which as you mentioned is hard and may even be unsolvable.

The advice is to look at the issue as you would a mathematical problem, critically and analytically. Don't use shotgun debugging or quick fixes, but instead try to understand the code thoroughly, what its goal is and how it accomplishes it. Instead of testing with random data, mentally walk through all the possibilities and branches.

This is akin to making a mental model of what you are trying to do, and then verifying that the model is correct, and that your code matches the model.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#125
post #20

Earlier quoted context omitted.

I just want to point out that Rob designed much of the logging infrastructure at Google. Take from that what you will.

For people who do not work at Google, is there something unusual (positive or negative) about Google's logging infrastructure?

Think about the scale at which it must operate. It is quite literally awesome. I wish I could give numbers. :-(

Re: Rob Pike: The Best Programming Advice I Ever Got.

#126
post #80

Earlier quoted context omitted.

Not just that, he coauthored Go together with the coauthor of C.

Didn't realise either of those points. I guess that adequately explains my wondering. What's amusing now are the insecure defensive posts and the downvoting.

You're getting down voted because cynicism is cheap, and that's all you brought to the discussion.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#127
post #116
post #114

Earlier quoted context omitted.

Giving a full proof that takes language semantics into account is very difficult. I think it isn't a practical way to verify programmes but maybe it'll be in future.

I don' think the advice is to do a proof, but rather to design and think about it in such a way that you could given enough time.

One of my CS theory profs had the policy, "A proof is anything that convinces me you could write a proof."

Re: Rob Pike: The Best Programming Advice I Ever Got.

#128
post #95
post #54

Earlier quoted context omitted.

Sometimes visual but more often I imagine the code physically. It has weight, or friction, or rigidity, depending on what aspects of the code I'm trying to think about.

Interesting. I should try using that. That is mechanical models. I have come across it(using a mechanical device analogy/metaphor for thinking about something) in other fields( http://www.ribbonfarm.com/2010/06/30/the-philosophers-abacus... ).But never really used it in code/design consciously so far.

It's not actually mechanical. It's called kinesthetic learning or sensing. That's one of the three types: kinesthetic, visual, and auditory.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#129

Here's a link to the (incomplete) sample chapter on their website for 'The Practice of Programming' on Debugging. http://cm.bell-labs.com/cm/cs/tpop/debugging.html I had this in my wishlist for a while. This just made me buy it. Wonder how different it will be from Code Complete 2.

It's very similar to Code Complete, but much, much shorter. Also, Code Complete has a fair bit of dumb stuff mixed in with the gems of wisdom that comprise most of it; TPOP doesn't.

Re: Rob Pike: The Best Programming Advice I Ever Got.

#130
post #55

Earlier quoted context omitted.

I also found that interesting, but not a big surprise since he is one of the co-authors of go...

Agreed - we'd probably all be most productive working in a language we'd designed ourselves, irrespective of the merits or demerits of that language for other programmers.

I find that I'm much more productive working in languages designed by other people, because they have much larger standard libraries. :)
Post reply on HN