A small excerpt from the true horror at The C Programming Language Brian W Kernighan & Dennis M Ritchie & HP Lovecraft:

Exercise 4-13. Write a function reverse(s) which reverses the string s by turning the mind inside out, converting madness into reality and opening the door to allow the Old Ones to creep forth once more from their sunken crypt beyond time.

(bonus points for spotting the error in Cthulhu).

blog postings devoted to it, not that this is.

Hat tip: Paul.

Comments

  1. #1 dhogaza
    2010/02/03

    Ah, yes, C, the only language that comes with its own puzzle book, because apparently writing unreadable code is a mark of pride …

    [You're think of perl, which people seem to have an unreasonable distaste for nowadays :-( -W]

  2. #2 carrot eater
    2010/02/03

    For a second I thought this was Hank’s guest post, and I was quite disappointed it was just a blurb about C.

    So I again look forward to Hank’s glory.

    [Sorry :-) -W]

  3. #3 Greg Laden
    2010/02/03

    Now my life is complete.

  4. #5 Gray Gaffer
    2010/02/03

    And Tony did cause the cursed Engines of Recursion to be instantiated on the Elliott 4130, and thus did release upon the world the insanities of forever attempting to view one’s own retinas without the aid of a mirror.

    AFAIK, the 4130 was, in 1964 or so, the first to implement hardware support for recursion. Point me at any earlier ones if I am wrong. But I knew that machine, it kerneled my computing soul.

  5. #6 David B. Benson
    2010/02/03

    Well, c is better than b.

    Thank g*d nobody devised a d language.

  6. #8 Kim Dabelstein Petersen
    2010/02/04

    Hmmmm – C++ comments in K&R (&l)?

    I’ll assume that the void thingie is either #define’d or is from the newer (but worse) edition.

  7. #9 Kim Dabelstein Petersen
    2010/02/04

    Not to mention case-sensitivity

    [That was my point :-) -W]

  8. #10 Deep Climate
    2010/02/04

    #9, 10

    I’m with you on the C++ style comments. But void and enum data types (not to mention case sensitivity) were in C by the early 80s, no? I guess that marks me as a hopeless newbie.

  9. #11 blf
    2010/02/04

    C++ style comments (which, if my memory is correct, came from either B or BCPL) have been in ISO-standard C since the 1999 standard, and were a common extension prior to that. enum was in the original K&R book and the (later) original ANSI/ISO 1989 standard, which also introduced void; both are also in the 2nd K&R book. It’s possible early C was not uniformly case-sensitive, but by the time of the original K&R book, it was uniformly case-sensitive except for external identifiers on certain antiquated (even then) non-Unix systems.

  10. #12 Kim Dabelstein Petersen
    2010/02/04

    #10,#11

    I was referring to the original K&R which are still close to my heart, since i learned C from it in the early 80′s on an AT&T system III (of all things)

    void wasn’t introduced before later, the reason being that a function would always return a value (int), iirc the first implementations of void did actually still return an integer (ie. pure syntactic sugar).

    case-sensitivity was already there in the K&R first release, and i’m rather certain it has been there since the very beginning.

  11. #13 John Mashey
    2010/02/04

    1) As usual, one can write unreadable code in any language.
    However, good people can write clear code in most languages, although APL could be subject to serious abuse.

    2) I learned C in 1973 from a 25-page BTL-internal memo of Ritchie’s and looking at their code, since that’s all there was, but reading good code was a great way to learn. that was when the total population of UNIX systems in world was ~20. The Lions’ Commentary was a learning tool for legions of computer scientists.

    If you rad that article, you may note that AT&T lawyers hassled John and tried to stop that from being used … at the same time as we used John’s commentaries for internal course at Bell Labs. I later lost my copies, but John, a scholar and a gentleman, kindly gave me signed replacements when I last saw him, ~year before he died, one of the reasons I own the California license plate “UNIX”.

    [Sounds like a clear need for an addition to your wiki page :-) -W]

    3) C was certainly case-sensitive when I started with it, and I would be astonished if it had ever been otherwise.

  12. #14 Deep Climate
    2010/02/04

    #11 bif
    Are you sure about enum? I don’t have the K&R first ed (oh, the shame), but all my sources say it wasn’t there (including Rochkind’s Advanced UNIX Programming from 1985).

  13. #15 Alastair McDonald
    2010/02/04

    enum is not in my K&R. I think it was introduced into standard C along with void well before the second edition of K&R was published.

  14. #16 David B. Benson
    2010/02/04

    Mark Hadfield | February 3, 2010 10:08 PM — Horrors!

  15. #17 John Mashey
    2010/02/04

    UNIX plate: well, it has caused amusement.
    Scene: I’m sitting at a stoplight.
    Car pulls up next to me, young guy rolls down his window, yells:

    “Cool license plate, dude, cool plate.” (this is California)
    “How’d you get that plate? I’m a UNIX sysadmin, is that what you do?”
    me: “Sorry, not for a long time”
    (Thinking, probably not since before you were born…, i.e., the very first UNIX-based computer center didn’t have full-time technical support, so some of us rotated taking TI725 terminals home and were on-call for tech support. That meant fielding occasional calls from operators (who normally did IBM mainframes, and weren’t sure about this UNIX stuff), and doing things like patching filesytems by hand. Thank goodness when fsck was written.)

    [this is California - good grief yes. *Talking* at the lights in England, to a stranger? The very idea is shocking -W]

  16. #18 Adam
    2010/02/05

    “*Talking* at the lights in England, to a stranger? The very idea is shocking”

    Winding down the window lets the rain in. ;)

The site is currently under maintenance and will be back shortly. New comments have been disabled during this time, please check back soon.