Forgot your password?
typodupeerror
Programming Education

Code Is Not Literature 240

Posted by Soulskill
from the neither-are-tea-leaves dept.
An anonymous reader writes "Hacker and author Peter Seibel has done a lot of work to adopt one of the most widely-accepted practices toward becoming a better programmer: reading high quality code. He's set up code-reading groups and interviewed other programmers to see what code they read. But he's come to learn that the overwhelming majority of programmers don't practice what they preach. Why? He says, 'We don't read code, we decode it. We examine it. A piece of code is not literature; it is a specimen.' He relates an anecdote from Donald Knuth about figuring out a Fortran compiler, and indeed, it reads more like a 'scientific investigation' than the process we refer to as 'reading.' Seibel is now changing his code-reading group to account for this: 'So instead of trying to pick out a piece of code and reading it and then discussing it like a bunch of Comp Lit. grad students, I think a better model is for one of us to play the role of a 19th century naturalist returning from a trip to some exotic island to present to the local scientific society a discussion of the crazy beetles they found.'"
This discussion has been archived. No new comments can be posted.

Code Is Not Literature

Comments Filter:
  • by bob_super (3391281) on Tuesday January 21, 2014 @03:40PM (#46028465)

    By the time some of my literature teachers are done, I'm sure the Hello World would be a subtle and poignant take on the overbearing consumerism as well as taking us to the depths of despair in search of the hero's hidden personality fractures.

  • by Anonymous Coward on Tuesday January 21, 2014 @03:41PM (#46028477)

    It's more about the metatextual narrative. What does this say about the author? This GOTO implies that the author does not want to be where he is. He is desperate to break out; to be anywhere other than where he is now. He's backed himself into this corner, bound in a loop of his own devising, and yet unable to meet the conditions necessary to move forward. "GOTO!" he cries out, "For the love of God, take me away from the endless DO and WHILE!"

    Here we see laid out the mind of a soul utterly broken. Can you not feel his burning shame? From the time he first took his toddling steps into the Hello, World! his teachers have admonished him "GOTO statement considered harmful". Yet desperate times call for desperate measures. He casts the thread of his execution into the void*.

    Where will he land? We scan the page with increasing alarm. Can you feel your heart quicken? Where is the label? Where are we GOing TO? Now the reader is caught up in the narrative as well as the author. Does the label exist at all? How did this thing ever compile? Until finally, we see it. Safe at last! Our execution can continue, and yet we are forever changed by the experience. Have we exited the loop in the correct condition? Will there be enduring side effects? Read on to find out...

    * The void, that is, not a pointer to an unknown type, I just mean to clarify that as a footnote**.

    ** A footnote, that is, not a pointer to a pointer to a footnote.

  • Re:Music... (Score:5, Funny)

    by jellomizer (103300) on Tuesday January 21, 2014 @03:42PM (#46028497)

    Not as much, it is closer but not really.

    The issue with Literature and Music there is a beginning, a middle and and a end.

    With Software there is a beginning, then the story changes every time the program runs, based on the input at the time. Leading to multiple end points, including a power off.
    Music is closer as it had notation that allows for some loops, however this is mostly to keep shorten the notation process and less about workflow.
    Also a choose your own adventure book, isn't that good analogy, as there are fixed number of stories possible.
    A relatively complex program can have different outcome all the time.

  • by Anonymous Coward on Tuesday January 21, 2014 @03:46PM (#46028531)

    This is just a pathetic attempt to address the fact that boring, drab Computer Science-studying robo-humans devoid of personality still cannot complete against the broke poets and other Liberal Arts majors for female attention.

    You're doing it wrong. Just open up your wallet. The art women appreciate most is green ink on a cotton paper with a portrait of Benjamin Franklin.

  • by gstoddart (321705) on Tuesday January 21, 2014 @03:56PM (#46028639) Homepage

    Discussing the meta-narrative implied by errant GOTO statements?

    The GOTO statement is reflective of the existential malaise experienced by programmers, and typified in post-modern society.

    It shows that the programmer in the code, as in life, feels they have reached a dead-end from which there is no escape, and reflective of a desire to escape the mundane and return to the optimism of youth.

    The GOTO becomes a metaphor for man's desire for a quick solution to our problems, and a naive belief we can make the problems go away, and thus becomes symbolic of wish-fulfillment and fantasy to offset the feelings of stagnation and dread so often described in post-modernism.

    In stack based languages, the GOTO becomes a surrogate for a strong father figure, and metaphorically kills the mother in frustration. It's also convenient for breaking out of nested logic to an error handler, which gives us feelings of going back to the womb, and indulging in self-infantilism in order to achieve a more expedient resolution of the dichotomy between self and other.

    Thematically, the GOTO is both liberation, and the source of our own slavery; it simultaneously demonstrates our desire for freedom, as well as showing the futility of such a quest and how we re-enslave ourselves through our actions.

    Because it highlights the existential question of "how do you implement an IF statement without a GOTO in Assembler?", it forces us to acknowledge that, as much as man tries to escape his primitive roots, there persist behavior which is neither rational nor defensible, but which we nonetheless cannot do without from an evolutionary perspective.

    The GOTO defines for us the boundary between man as thinking entity, and non-thinking animal. And, as in Conrad's Heart of Darkness, forces us to look within ourselves, and confront the things we see but cannot fully understand or control.

  • by DickBreath (207180) on Tuesday January 21, 2014 @03:57PM (#46028649) Homepage
    > That's one of my peeves. When I see a comment like that, I scream . . .

    When someone does it, then put the following optimizations into their header files somewhere. Be sure to include the useful comments that explain their purpose.

    #define struct union // optimization to use less memory
    #define while if // optimization to make code run faster

    It's the thought that counts.
  • by digitalhermit (113459) on Tuesday January 21, 2014 @04:25PM (#46028993) Homepage

    Perl jokes aside, I have some old code written in everything from bash to C to R to Java. The common theme among these absolutely stunning pieces of literature is how incomprehensible some of it can be just a few months later. Sure, good code is self documenting, good code reads like a sentence, a proper module fits on one page of screen (I have a 24" display with better than 1920x1080 resolution, btw) but if my code were indeed prose, it would cause eyes to bleed, to hemorrhage, to explode in a fantastic fountain of blood and aqueous fluid.

    Sometimes I wrote bits of code without knowing that there were easier ways. I may do a "for item in $(ls *.csv)" instead of the proper "for item in *.csv" or some furious hackery to manually rotate 20x10 matrix into a 10x20 (single command in several languages), or try to parse an XML file by regex'ing and other madness... Sometimes I was drunk. There was one class where the instructor didn't like "showoffs" so code had to be written using only the commands that were covered in the lecture. The resulting code from that class was horrid. One of my earliest bits of code from the 80s sent escape sequences to a printer and there are several strings with non-ASCII characters. There is no way to understand the code without knowing the printer. I have similar code for an Atari that stored music in a BASIC string. That might be possible to decode only if one understood how the Atari made sound.

  • by Anonymous Coward on Tuesday January 21, 2014 @04:44PM (#46029189)
    obviously white-only
  • Re:What? (Score:4, Funny)

    by RabidReindeer (2625839) on Tuesday January 21, 2014 @05:25PM (#46029543)

    Reading other people's code is a great way to learn better ways of doing things you thought you already knew how to do. ;)

    Reading the source code to the OS and compilers used at my school probably taught me more than the classes themselves.

    It was good code. Most of the business code I've seen is more like pornography than great literature, though.

  • Re:Music... (Score:5, Funny)

    by camperdave (969942) on Tuesday January 21, 2014 @07:38PM (#46030703) Journal
    BEGIN
    (* I'm dreaming of a white Christmas, *)
    (* Just like the ones I used to know. *)

    IF Christmas [ white ] AND
    ( Christmas [ white ] = Christmas [ known( me ) ] ) THEN
    me := dream( Christmas [ white ] );

    (* I'm dreaming of a white Christmas, *)
    (* with every Christmas card I write. *)

    FOR index := firstcard TO lastcard DO BEGIN
    WITH card [ index ] DO me := dream( Christmas [ white ] );
    END;

    (* When the tree-tops glisten, *)
    (* And children listen, *)
    (* To hear sleighbells in the snow. *)

    REPEAT wait UNTIL stateof ( tree.tops ) = glisten AND
    stateof( children ) = listen( noiseof1in2( bells.sleigh, snow ) ) ;

    (* May your days be merry and bright, *)

    FOR index := firstday TO lastday DO BEGIN
    day.yours[index] := (merry AND bright);
    END;

    (* and may all your Christmases be white. *)

    FOR index := firstxmas TO lastxmas DO
    Christmas.yours[index] := white;

    END.

I cannot conceive that anybody will require multiplications at the rate of 40,000 or even 4,000 per hour ... -- F. H. Wales (1936)

Working...