Live data from Hacker News

Code is not Literature

gigamonkeys.com

31–40 of 88 posts

Re: Code is not Literature

#31
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…

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 RCS thrusters on it work, or I might clone git's repo because I suddenly realize that I don't know how git-notes is implemented.

In either case, I don't read the whole thing (and certainly not straight through in a linear manner, like I read Moby Dick), but rather I'm going to grep/ctrl-f to the part that I'm interested in, then probably jump around a dozen or more times until I am satisfied. That's still reading though.

Re: Code is not Literature

#32
Code is not literature because literature only contains the highlights worth knowing where code has to provide the comprehensive instructions for everything to operate.

A good code reader should be like a tour guide, and a good tour guide doesn't visit every single building and street in a neighborhood but rather describes the historical context of the neighborhood and then visits a few interesting places.

Re: Code is not Literature

#33

Why do we still embed natural language descriptions of source code (i.e., the reason why a line of code was written) within the source code to the exclusion of intrinsically linked separate documents? http://i.stack.imgur.com/JlUiE.png The potential advantages include: - More source code and more documentation on the screen(s) at once - Ability to edit documentation independently of source code (regardless of languag…

Because we're stuck in a tyranny of flat text files as a representation of code. There have been countless proposals over the years for some kind of richer file format for representing code and they have all been busts because so much of our tooling, assumptions, interoperability and culture is centered on flat text code that it's proven impossible thus far to switch.

There's nothing wrong with text files.

Although Smalltalk imaging systems are an interesting alternative.

Re: Code is not Literature

#34
post #16

Every time I have a serious question about how something works in the Linux kernel, I use it as an excuse to do a dive into the code: http://lxr.free-electrons.com/ I still look through other sources, including man pages, books and a lot of googling. But sometimes I just want to see what it is I'm dealing with. I do this with all code bases I deal with. I think it's a good practice to get into.

I like to read cross-referenced code too. I built "SherlockCode" a while ago as a generic tool to browse code but I haven't done anything with it in a while. Here is a sample of a symbol in a file in jQuery:

http://sherlockcode.com/demos/jquery/#!/src/attributes.js:pr...

Re: Code is not Literature

#35
post #6

Code can be literature in specific cases, such as the Shakespeare programming language. It's just a whimsical, esoteric language, like lolcode, but it reads like the Immortal Bard himself was an early adopter of learning to program. Example of a conditional statement: Juliet: Am I better than you? Hamlet: If so, let us proceed to scene III. http://en.wikipedia.org/wiki/Shakespeare_(programming_langua...

Shakespeare is only superficially readable. In reality, the logic executed by the program is very nearly unrelated to the way the program reads to a human. Essentially it's a cute syntax over the same old FORTRAN, much like lolcode. It was a missed opportunity to represent logic as meaningful literature.

Re: Code is not Literature

#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.

Re: Code is not Literature

#37
"The point of such a presentation is to take a piece of code that the presenter has understood deeply and for them to help the audience understand the core ideas..."

I do get lots of value out of that. My favorite example is Beazley's GIL talk: http://www.youtube.com/watch?v=Obt-vMVdM8s

Re: Code is not Literature

#38

" Once I’ve completely rewritten the thing I usually understand it pretty well and can even go back to the original and understand it too. I have always felt kind of bad about this approach to code reading but it's the only thing that's ever worked for me. " This strategy may work for small programs, but it doesn't scale to large programs. For example, most people aren't going to have the time to refactor Firefox or…

That's a good point about running it in the debugger.

However, even with a large program, sometimes I find it helpful to write a smaller program that does much the same thing as a small part of it. For example, last year I wrote a debugger frontend in Dart, based on the Chrome DevTools debugger. Whenever I wanted to implement something I'd first look at how the Chrome debugger did it.

Currently I'm working on a reimplementation of the React framework, also in Dart.

Re: Code is not Literature

#39
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…

Yes I agree. But, for myself, even (or especially) with a purpose I mind, I decode, not read per se. I've recently been working through the selfoss source and adding some new features, and this is the tack I've taken through it -- decode the source to find where the feature should be added. So I agree with you, and the OP.

Re: Code is not Literature

#40
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…

It does happen. I've been reading jQuery source recently as a learning exercise, for instance.
Post reply on HN