Slashdot Mirror


Ask Slashdot: How Do You Read Code?

New submitter Gornkleschnitzer writes: The majority of humans read silently by rendering a simulation of the printed words as if they were being spoken. By reading that sentence, chances are you're now stuck being conscious of this, too. You're welcome.

As a programmer (and a reader of fanfiction), plenty of things I read are not valid English syntax. When I find myself reviewing class definitions, for loops, and #define macros, I rely on some interesting if inconsistent mental pronunciation rules. For instance, int i = 0; comes out as "int i equals zero," but if(i == 0) sometimes comes out as either "if i is zero" or "if i equals equals zero." The loop for(size_t i = 0; i < itemList.size(); ++i) generally translates to "for size T i equals zero, i less than item list dot size, plus-plus i." I seem to drop C++ insertion/extraction operators entirely in favor of a brief comma-like pause, with cout << str << endl; sounding like "kowt, stur, endel."

What are your code-reading quirks?

10 of 337 comments (clear)

  1. FFS by nuckfuts · · Score: 5, Insightful

    Could you be any more self-absorbed?

  2. Easy by alvinrod · · Score: 5, Funny

    I just program in write only languages like Perl so I never have to worry about this problem.

  3. WTF Are you Serious? by CrashNBrn · · Score: 5, Insightful

    What competent programmer converts the abstraction of code to ENGLISH to grok it?

    generally translates to "for size T i equals zero, i less than item list dot size, plus-plus i.

    No it doesn't. It translates to, "Iterate 'itemlist'" , You're Welcome.

    1. Re:WTF Are you Serious? by alvinrod · · Score: 5, Interesting

      I recall reading a paper once that mapped how novice programmers read and understand code onto a mapping to express their level of development as programmers. The most basic level was a verbose restatement of the code in English, without grasping what the code did as a whole, whereas the highest level was a high-level description of what it accomplished, typically in as few words as possible.

      Also, "plus-plus variable" seems like a bad way to word it internally even if you're breaking it down to the most basic level. "Pre-increment variable" seems like a much better way to think about it, especially if it's being used as an index into an array or anywhere outside of a standalone statement .

  4. One line st a time... by __aaclcg7560 · · Score: 5, Insightful

    My initial response is, "who wrote this shit?!" And then I recognize it as my own code.

  5. Hearing code read by others is jarring by Dutch+Gun · · Score: 5, Interesting

    It's sometimes odd to hear others pronounce code, because it may not align with your own mental map of how things should be pronounced. I remember getting mildly distracted when watching one of Stephen Lavavej's videos because he would call shared_ptr "shared putter" (with the u pronounced similar to 'put'). Why would you abbreviate the sound when it's not any shorter than "pointer"?

    When reading code by myself, though, I think the translation to a phonetic translation happens quite subconsciously, because I'm typically not aware of it at all. It obviously happens to some extent, or I wouldn't have been bothered by STL's reading. So, trying to think it through (which I haven't done before, really), I can assure you that == would never be "equal equal". It would be "is equal to". "cout" is not "kowt", but "see-out". And I use > so infrequently, I think I don't even bother with a mental pronunciation.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  6. Wrong! by Chris+Mattern · · Score: 5, Insightful

    "The majority of humans read silently by rendering a simulation of the printed words as if they were being spoken".

    Actually, only people who read poorly do that. People who read well decode printed words directly into mental concepts, rather than sounding them all out, only sounding out a word when it is unfamiliar in print. (see jokes about people whose lips move when they read)

  7. I do not read by manu0601 · · Score: 5, Interesting

    Your post made me realize I do not read the source, I look at them it like I would do with a map or a geometric shape. And when someone reads me code, I have to do the mental work of representing it differently as when spoken.

  8. That's how "Look-Say" made illiterate generations by Ungrounded+Lightning · · Score: 5, Interesting

    Actually, only people who read poorly do that. People who read well decode printed words directly into mental concepts, rather than sounding them all out, only sounding out a word when it is unfamiliar in print.

    That (essentially correct) observation led to the creation of the "Look-Say" method of teaching English and its replacement of "Phonics" in the public schools.

    Look-Say attempted to skip the "learn new words by sounding them out" step and teach students immediately to use the faster words-as-a-chunk technique of good readers.

    But that ended up crippling them, because it left them with no way to acquire new words. They knew the handfull they'd encountered in class as a set of pictograms but didn't have the "secret code" to parse somethig they hadn't seen before. Result: Mostly illiterate graduates whose reading was so painful to them that they did little, getting farther and farther behind.

    Turns out that good readers of substantially phonetic languages start with sounding-out (Phonics-style). Then as they gain skill and experience they start recognizing progressively more words at-a-glance, falling back to sounding-out when they hit words for which they hadn't yet built a neural-net recognizer. Eventually the "speed-bump" words become so rare that they blaze along familiar vocabulary without appearing to sound-out at all. But new or rare words bring out the old toolset, rather than bringing them to a full stop.

    There are a corresponding pair of methods for learning a "second (i.e. additional) language: The "Grammatical Method" (learn and practice the lnguage rules) and the "Audiolingual Method" (repeat the samples). The latter came from an attempt to emulate the rapid language acquisition of children by modeling their environent

    Tested right after a series of courses, college students taught by either method score about the same. Tested a year or so later (if they haven't been re-exposed to the second language meanwhile) those taught by the Grammatical Method had a significant skill loss, while those taught by the Audiolingual Method were unable to emit any sentence they hadn't encountered in class. Oops!

    Turns out that (unless you learn two or more languages as a child) the neural structures that make kids little language acquisition machines literally die off, in several stages (at the ends of age ranges called "critical periods") as the neurons that weren't used by the language learned are "pruned". Once this has happened, learning a new language isn't impossible. But it's more like recovering from a stroke.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  9. Re:Maybe by viperidaenz · · Score: 5, Informative

    It's "c out" for those who understand what the statement does and "kowt" for those who don't bother to think about what it means.