Live data from Hacker News

Code is not Literature

gigamonkeys.com

61–70 of 88 posts

Re: Code is not Literature

#61
post #7

Asking people what they've read "just for the heck of it" is the wrong question, because code is not linear , so it's extremely ungainly to read without purpose. But as soon as the skilled code reader has a purpose in mind -- a question to answer -- he or she can rapidly find a meaningful narrative. Put into that context, programmers read code constantly, and the more they read the better they get. So I don't like th…

I think the claim is "nobody reads code the way they read literature", which isn't a strawman in the context he's writing.

Re: Code is not Literature

#62
It's a cultural, psychological, linguistic mixup more than anything else. People do read code all the time, they just hesitate to respond to a question like "what code have you read recently". It's hard to answer that question in english without implying that you have completely read a program (rare) that was completely written (in other words, "finished", which is even more rare).

If you asked a different question, like "explain how you read code in the course of a typical project or experiment" you will get a ton of examples. They might describe how they look to understand the basic data structures, and then imagine some sample data flowing through the algorithm to understand the purpose, and then examine the details, edge cases, and interactions to see why some non-obvious choices were made. Then they might describe how they use this to find what parts of the code should be generalized, specialized, or extended to fit new functionality.

It might be interesting to incorporate code reading into an interview to see the strategies that people use. It would be quite difficult to make it a fair question, though, because patterns vary widely and it often takes more than an hour or so to adapt.

Re: Code is not Literature

#63

It's a cultural, psychological, linguistic mixup more than anything else. People do read code all the time, they just hesitate to respond to a question like "what code have you read recently". It's hard to answer that question in english without implying that you have completely read a program (rare) that was completely written (in other words, "finished", which is even more rare). If you asked a different question,…

I think it is understood that we all read code during a typical project. I think what the OP is referring to is code reading for the purpose of improving your skill in general, to get exposed to code that you wouldn't normally see by just working as usual.

Re: Code is not Literature

#64
For me, the fastest way of understanding code is a mix (back and forth) of reading it and running it. Some questions on how it works are more easily answered by running it and seeing what happens, while other questions are better answered by reading (e.g. what are all the possible cases here?).

Re: Code is not Literature

#65
post #31

Earlier quoted context omitted.

Exactly. I think that asking "what repos have you cloned just so that you could look at something, not intending on actually building or using that particular code" is probably roughly analogous to asking "what Wikipedia pages have you read recently" I frequently do both of those for the same reasons. I might pull up the wikipedia page for the Apollo Lunar Module because I suddenly realize that I don't know how the R…

You just made me realize that github needs better search. I like the presentation on github but, without git grep, I just pull it local and read from there.

It is possible to search for a string within a repo but it isn't a grep replacement.

Example: https://github.com/django/django/search?q=modelchoicefield&t...

Re: Code is not Literature

#66

I think the author has a somewhat limited definition of “literature”, though he ultimately comes to the right conclusion that code must be “studied”, not “read”. It’s true, code is typically less linear than a pulp novel, but other types of literature are also involved, with layered meanings, which must be examined carefully, with reference material handy, and lots of flipping back and forth between sections. For ins…

None of your examples are very good examples of "literature" as it's usually understood - in everyday use, the term by itself denotes prose fiction (and often excepting pulp novels). Not by coincidence, this is the "limited" definition Seibel uses.

Re: Code is not Literature

#67
post #36

I think the author has a somewhat limited definition of “literature”, though he ultimately comes to the right conclusion that code must be “studied”, not “read”. It’s true, code is typically less linear than a pulp novel, but other types of literature are also involved, with layered meanings, which must be examined carefully, with reference material handy, and lots of flipping back and forth between sections. For ins…

You summarize very well exactly what I felt from the article. I sometimes feel the metaphor goes the other way, that is, when I seriously read a literature (in my case, it's often a play) I feel like I'm "decoding" it.

Absofulukingtely. Litterature is like code, can be pretty obvious and linear and you just read it, or it can be deeply intelligent and you decode it, ponder over what it implies and what it assumes.

Re: Code is not Literature

#69

I think the author has a somewhat limited definition of “literature”, though he ultimately comes to the right conclusion that code must be “studied”, not “read”. It’s true, code is typically less linear than a pulp novel, but other types of literature are also involved, with layered meanings, which must be examined carefully, with reference material handy, and lots of flipping back and forth between sections. For ins…

Well put.

Personally, I have to use the skills I gained learning rhetoric and analyzing literature to make sense of some code bases. I've seen some shocking ball-o-mud code bases, and the only way to make sense of it was to understand the author(s), though never having met them. And to understand the subtext of the syntax, despite inconsistent application (poor naming convention and mixing ladder and structured text is like reading illuminated medieval engravings). There's code smells and slight variation in copy/paste blocks that belie the history of edits. There are threads woven through multiple volumes, where deprecated interlocks and crossed wires lead to bizarre plot twists. It's easy to think of certain machines as having personalities (or mental disorders, as the case may be). And there's never just an atomic dozen lines of code; at best you can reference five subroutines across two PLCs to describe what may be going on. And like good literature, you can't spoil the ending, as the joy is in the retelling of the story (of how you tracked down what was really happening).

It doesn't have to be a fascinating travesty, but I've yet to see a boring, dull, straightforward control system. Perhaps industrial programming logic just naturally turns out that way.

But it sure feels like Moby Dick, both in size, depth, and the unreliable narrator.

Re: Code is not Literature

#70

The main problem I see is that code is read left to right, top to bottom (for the most part) but it is rarely, if ever, written that way. The order that decisions are made is almost as important as the decisions themselves. But, we lose almost all of that order or 'context'. Worse, although we can place comments in the code, we cannot attach comments to the evolution of code. Evolutional comments could describe why t…

> we cannot attach comments to the evolution of code

I guess Google has spoiled me. When reading code, I constantly look at its development history - commit messages, diffs and line-by-line "blame", linked bugs and code review threads. If you have good tools for that, there's much less need for inline comments.

Post reply on HN