Settings

Theme

Ask HN: Zed Shaw's critique of K&R

16 points by gilesgate 6 years ago · 21 comments · 1 min read


I've read of Zed Shaw's critique of K&R in "Learn C the Hard Way", and I've gathered that he had indeed raised an interesting range of issues, regardless of the backlash.

I've tried tracking that critique down to no avail. A link to Shaw's website that I found wasn't accessible,[0] nor was any archive.org copy of it.[1]

Does anyone happen to have a copy of or a link to it? I'd be interested in reading through it.

(Disclaimer: I'm not interested in refueling a debate, I just would like to read the critique or find out its salient points.)

[0] http://c.learncodethehardway.org/book/krcritique.html

[1] http://web.archive.org/web/*/c.learncodethehardway.org/book/krcritique.html

brudgers 6 years ago

I can see why Shaw made the article less accessible via search. Shaw has done the same with other essays he wrote around the same time. The basic analysis is sound. If you write programs like those in The C Programming Language those programs will lack mitigations for buffer overflows and null pointers.

A weakness of this essay is it jumbles pedagogical and engineering considerations together for dramatic effect. The defensive code Shaw does not find in K&R is only justified if crashing is both likely and worth the effort to prevent. YAGNI and "let it crash" are alternative engineering approaches.

The strength of Shaw's essay is that the grappling with the absence of defensive programming motivated Learn C the Hard Way to introduce Valgrind and Make right away. And the outrage probably adrenaline fueled Shaw's writing. All the controversy was consistent with Shaw's public image at the time, to boot. But in the end, the essay, like many of the period, lacks nuance. Their fading searchability is probably a sign of Shaw's recognition.

I think Learn C the Hard Way is better for Shaw having written the essay and I think his book is a pretty good introduction to C programming in part because it introduces Make and Valgrind and eschews IDE's. K&R is also good, but it's written with the assumption that the reader is ok learning from material written in a documentary style. That's less common today than four decades ago.

nenadg 6 years ago

[0] https://archive.is/7cbe6

  • jrugk 6 years ago

    What he probably wants is this: http://archive.is/euOjX

    • gilesgateOP 6 years ago

      Yes, that must be it. As I understand it, the deconstruction was included in the working copy of his book before Chapter 1, and then later removed, correct?

      Edit: Ah, incorrect. He actually intended it to be a chapter-by-chapter deconstruction but never completed it.

      • klingonopera 6 years ago

        Are we sure he never completed it? Or are these just missing parts from the (pirated? preview?) online PDFs?

        Because if that's it, then it was just two points he was making, 1. Null-terminated char arrays are "defective"/unsafe, and 2. Don't omit curly braces, for which he seems to have received a lot of backlash, even though those are quite valid points. I'm guessing it may have something to do with taking it up against the grandfathers of C and his rather ...hands-on writing style?

        Critique 1. isn't actually that controversial, and does have merit[1], and 2. is a stylistic decision, that even John Carmack[2] would agree on.

        [1]: https://news.ycombinator.com/item?id=20792938

        [2]: See "Spacing" in https://kotaku.com/the-exceptional-beauty-of-doom-3s-source-...

jdmoreira 6 years ago

"Learn C the Hard Way" is considered by many to be a horrible book on C

sverona 6 years ago

I doubt my Google-fu is better than yours (and it looks like Zed has basically retracted what he said anyway by way of going so far to remove it from the Internet) but one of the salient points was definitely "some of the code in the book doesn't compile or do what it says it does."

  • klingonopera 6 years ago

    One of his criticisms was the (usual) critique of C's null-terminated char arrays (to be precise, that failure to include an null-terminator in a char array causes overflow, thus functions needed to be designed to accommodate such cases), and another was stylistic critique, one with which I agree with ZS, that optional curly braces should never be omitted, no matter how mundane.

yesenadam 6 years ago

Library Genesis has almost everything.

http://gen.lib.rus.ec/search.php?req=Learn+C+the+Hard+Way

antiquark 6 years ago

Try google with "PDF" as part of the search term, there seem to be a couple of stragglers on the web.

psv1 6 years ago

Zed Python3-strings-are-too-difficult-for-me Shaw? I wouldn't bother with anything he's ever said or written.

  • Nextgrid 6 years ago

    What's the problem with his Python book? I bought "Learn Python the right way" for a close friend as I thought it was a good one to get started - is it not?

    • psv1 6 years ago

      The book has multiple chapters on printing (!?) and the style of writing is incredibly condescending. It's one of the worst Python books I've come across. A sample of his idiocy - https://learnpythonthehardway.org/book/nopython3.html.

      > When you start out programming the first thing you work with is strings, and python made them far too difficult to use for even an experienced programmer like me to use. I mean, if I struggle to use Python's strings then you don't have a chance.

      To get away with this kind of attitude, one needs to be much smarter than he is.

      • reitzensteinm 6 years ago

        Given your ridiculous strawman of his Python 3 criticism, I won't be bothering with your review of his book.

        • psv1 6 years ago

          Not sure how it's a strawman, but let's address his statement directly.

          Do you agree with him that Python 3 strings are difficult for experienced programmers? Apparently they are difficult for Zed Shaw as I quoted above. And also since they're difficult for him, does that mean that beginners "don't have a chance"? Demonstrably false and arrogant claims like this one, as well as many others in his Python and C books, make him lose all credibility.

          • reitzensteinm 6 years ago

            They are not difficult for Zed Shaw. You might not like his writing style, but disregarding context and interpreting statements literally that are quite obviously there for dramatic effect is in fact a strawman.

            While I do find his writing entertaining, I wouldn't recommend it for beginners either. But not because he doesn't know how Python 3 strings work.

            Python 3 was a disaster, and while his diatribe against it was questionable, the emotion behind it was not particularly misplaced.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection