News for hackers. Stuff that matters.
Re:Ask HN: Ways for reading open source code bases? by patio11 on Monday December 07, 2009 @12:11AM (#980751)
Once upon a time, a client of the day job dropped a substantial Perl codebase on our desk and said "Tell us what this does." My boss gave me the job, and expected me to actually READ all the code, but given that I had no desire to read through 100 kloc of Perl code commented only in Japanese, I went for visualization instead:

1) Inspect several files for commonalities. Thankfully, the author was obsessive compulsive about coding standards.

2) Write a parser for the Perl they used. Use it to glean what pages of the site were connected to each other and what the flow control was like. (a -> b, b -> c, b -> d, etc)

3) Plot that on a graph (all hard work already done for me: http://rgl.rubyforge.org/rgl/index.html )

4) Visually inspect the graph to learn non-obvious things about the codebase like "Oh, there is an English language version of the site embedded in here. Isn't that TOTALLY UNDOCUMENTED." Do a bit more code to chop the graph into subgraphs by related functionality (signup flow, admin functions, etc etc).

5) Spit out all the code into HTML pages with appropriate autogenerated navigation, inline flow control graphs, and syntax highlighting. Do a bit of quality control, add in some comments about notable things I had learned, burn on CD and hand to customer.

6) Charge customer $X0,000 for the CD. The customer was overjoyed they got it done so cheaply. (Did I mention 100 kloc of Perl?)

Re:Ask HN: Ways for reading open source code bases? by cperciva on Monday December 07, 2009 @12:30AM (#980774)
(Did I mention 100 kloc of Perl?)

Hey, you got off easy. Just imagine how much more work it would have been if everything had been done in a single line of Perl. :-)

Re:Ask HN: Ways for reading open source code bases? by pasbesoin on Monday December 07, 2009 @02:29AM (#980877)
Or it might have been Klingon.

(Lest I be considered entirely off topic: http://www.perl.com/lpt/a/560 http://www.perlmonks.org/?node_id=88704 and search "klingon". Better the salariman, than Conway in a playful mood.)

Re:Ask HN: Ways for reading open source code bases? by patio11 on Monday December 07, 2009 @01:20AM (#980823)
70 hour workweeks, 3 hour daily commutes, salary below the median for a starting graduate from my alma mater, and debugging code written in India based on instructions translated by Babelfish: all of these I will endure without complaint. But I will not blackbox analyze Perl one-liners. That is just abusive.
Re:Ask HN: Ways for reading open source code bases? by tptacek on Monday December 07, 2009 @02:13AM (#980867)
... why DO you work 70 hour workweeks with 3 hour commutes for below-market wages? "Because, Japan"?
Re:Ask HN: Ways for reading open source code bases? by mahmud on Monday December 07, 2009 @03:24AM (#980914)
This happened "once upon a time", he might have done it while learning the ropes and picking up the language.
Re:Ask HN: Ways for reading open source code bases? by skywalker on Monday December 07, 2009 @01:14AM (#980821)
Yes. When I write anything in Perl I frequently try to compact what would be several lines in just a few obscure expressions.

But as the Freebsd security head, what do you do to understand a large code base you probably aren't familiar with and its security implications?

Re:Ask HN: Ways for reading open source code bases? by cperciva on Monday December 07, 2009 @02:24AM (#980875)
But as the Freebsd security head, what do you do to understand a large code base you probably aren't familiar with and its security implications?

I ask someone to explain it to me.

Being FreeBSD Security Officer, I have an uncommon luxury: I have about 200 highly qualified developers available who will stop what they're doing and help me out if I say "so, umm, I sort of need to understand how this code works...".