[HN Gopher] Brian Kernighan on "The Practice of Programming" [vi...
       ___________________________________________________________________
        
       Brian Kernighan on "The Practice of Programming" [video]
        
       Author : zdw
       Score  : 366 points
       Date   : 2024-07-10 14:45 UTC (1 days ago)
        
 (HTM) web link (www.youtube.com)
 (TXT) w3m dump (www.youtube.com)
        
       | fuzztester wrote:
       | I'm only one third of the way through the video, but could see
       | that the podcasters are asking some good insightful questions.
       | 
       | Thanks for sharing, OP.
        
         | carterdmorgan wrote:
         | I just found out we cracked the Top 20 on Hacker News! Crazy!
         | I'm Carter, one of the podcasters from the video. I'm glad
         | you're enjoying it! It was such a huge honor to talk to Brian
         | Kernighan.
        
           | jjice wrote:
           | I hadn't heard of this podcast until just now, but an entire
           | show dedicated to software book sounds like a dream come
           | true! I'm going to download a few of these for the train. I
           | love that you guys are diving into such a niche!
        
             | carterdmorgan wrote:
             | Thanks so much! When we had this idea, I was certain that
             | it had to have been done before because it seemed like such
             | a gap in the market. To my surprise, it didn't exist! We
             | love the format because not only do we learn a ton, but by
             | focusing on the books we keep the discussions substantive
             | and avoid becoming the millionth "tech news of the week"
             | podcast.
        
           | mettamage wrote:
           | How did you get him on your podcast? That's amazing!
        
             | carterdmorgan wrote:
             | To be totally honest, I just looked up his Princeton email
             | and asked lol. I told him we loved the book and would love
             | to interview him about it. He was like "What? I haven't
             | thought about that book in 20 years. But I'm sure we could
             | find something to talk about for an hour." He was so
             | amazingly kind and generous with his time.
             | 
             | He's not the only author we've gotten on the podcast! We've
             | already published our episode with Mark Richards on
             | "Fundamentals of Software Architecture" but we also have in
             | the can and ready to go over the next few weeks Neal Ford
             | of "Fundamentals of Software Architecture" and John
             | Ousterhout of "A Philosophy of Software Design." That's not
             | public knowledge yet, so consider it an exclusive Hacker
             | News comment section scoop, haha!
             | 
             | We also have some pretty big names we're in talks with, but
             | I won't make any promises until the interviews are actually
             | recorded. But we've been so thrilled at the author response
             | so far and are super excited about the future of the
             | podcast!
        
               | dpb001 wrote:
               | Years ago he was a guest lecturer for a class I was
               | taking from Scott Bradner - as you said, incredibly nice
               | an approachable guy. I could have listened to him for
               | another hour or two.
        
               | carterdmorgan wrote:
               | We would have loved nothing more than to talk to him for
               | hours. He was already calling in from England while on
               | his vacation, so I didn't want to take any more of his
               | time, haha!
        
             | mr_toad wrote:
             | Authors seem to treat podcasts the way celebrities treat
             | talk shows, it's basically free marketing.
        
               | carterdmorgan wrote:
               | That's been my experience so far, especially because the
               | focus of the podcast is explicitly on the book. It's not,
               | "Hey, come on my podcast to discuss the latest AI
               | development and then maybe plug your book at the end,"
               | it's "Hey, come on my podcast solely dedicated to
               | discussing the book you've written." Authors seem pretty
               | eager to participate in that.
        
           | dinkumthinkum wrote:
           | I found your podcast a few days ago on a different book. Keep
           | it up, I think you have a good niche and doing something you
           | rarely see, which are deep dives on programming books. The
           | only other one I really know of is Connor Hoekstra has a
           | couple nice playlists on SICP and something else but this is
           | a little different, good job.
        
             | carterdmorgan wrote:
             | Thanks for listening! Which book was it that you found?
             | 
             | It's definitely a breadth over depth kind of podcast, but I
             | don't think that's necessarily a bad thing. We wanted it to
             | feel like hearing two coworkers discuss a book over lunch.
             | We don't provide comprehensive reviews, but rather just
             | highlight what we found the most interesting, while trying
             | to keep it substantive.
        
           | fuzztester wrote:
           | gotcha, and agreed.
           | 
           | bwk is one of my software heroes, along with dmr, bs, lw,
           | gvr, etc.
        
       | JetSetIlly wrote:
       | I love the Practice of Programming. Of all the books on
       | programming that I've read, the lessons of that book are the ones
       | that remain strongest in my mind. I've not read it in many years
       | but I feel it influences my practice everyday.
        
         | carterdmorgan wrote:
         | It was the first time I've ever read it and I was surprised how
         | much of it still held true given it's 25 years old. Some of the
         | specific programming examples are pretty outdated, but the
         | general ideas are as solid as ever!
        
           | bigdict wrote:
           | Curious what examples you felt were outdated.
        
             | carterdmorgan wrote:
             | They mention at one point that Java doesn't have a way to
             | pass a function as a parameter to another function. That
             | was added in Java 8 with lambdas. That's just one off the
             | top of my head.
        
               | bigdict wrote:
               | Ah ok thanks.
        
               | dehrmann wrote:
               | Nit: it's still right. Lambdas are just functor sugar.
        
               | marcosdumay wrote:
               | The only mainstream languages where you can actually pass
               | function references around, without them being sugar for
               | some complex object that the compiler creates are C, C++
               | and Rust. And it's not trivial to do in Rust.
        
       | zombiwoof wrote:
       | I wish interviewing now was more about knowing the concepts in
       | that book versus leetcode
       | 
       | Brian Kernighan prob couldn't pass a leetcode hard interview in
       | this ridiculous new world
        
         | carterdmorgan wrote:
         | My last interview cycle I interviewed with some big names
         | (Stripe, Square, Shopify, etc.) and was pleased that none of
         | them asked any LeetCode style questions. All pretty practical
         | programming stuff. Stripe had an interview where they had
         | forked the Jackson Java library, introduced a bug, and then
         | asked me to find and fix it. Pretty unique style, but much more
         | applicable to the actual job of programming.
        
           | goosejuice wrote:
           | That's a clever interview question, but wouldn't that suffer
           | from diffing origin/main? Or was this a in person / on screen
           | interview with no git history?
        
             | surbas wrote:
             | I would say that I would hire that person if that was the
             | solution. That said maybe repo wasn't included in
             | interview. (Would be even better if person figure out how
             | to diff against a new clone)
        
             | carterdmorgan wrote:
             | It was an on-screen virtual interview, so while I believe
             | they had scrubbed the Git history, you weren't allowed to
             | look it up.
        
           | HumblyTossed wrote:
           | > Stripe had an interview where they had forked the Jackson
           | Java library, introduced a bug, and then asked me to find and
           | fix it.
           | 
           | I think I would actually enjoy an interview like that.
        
           | senderista wrote:
           | In my most recent interviews with Apple and Amazon there were
           | no LeetCode questions after the phone screen. Quite a change
           | from previous experience.
        
         | kps wrote:
         | Reminiscent of Peter Higgs (Nobel Prize winner for the
         | eponymous boson) saying that he would not be able to get an
         | academic job today, not to mention Katalin Kariko (Nobel Prize
         | winner for mRNA) being demoted by UPenn for not attracting
         | grant money.
        
       | opello wrote:
       | A nice value in this format (since it discusses books) would be
       | to have a comment or portion of the description dedicated to
       | listing the books (or ideally the media) discussed to a list.
       | 
       | I added "The Bit Player" (Claude Shannon documentary from 2018)
       | to my watch list as well as "Recoding America," "Chip War," and
       | "Endurance: Shackleton's Incredible Voyage" to my reading list.
        
         | carterdmorgan wrote:
         | What do you mean by this exactly? Like a list of all upcoming
         | books we'll discuss? If you're curious, you can find that on
         | our website at www.bookoverflow.io!
        
           | farleykr wrote:
           | I think they mean that the description of the episode should
           | have a list of books (and maybe other resources) that were
           | mentioned in the episode itself.
        
             | carterdmorgan wrote:
             | Oh yeah, that's a good idea. We'll have to do that. We've
             | been debating setting up Amazon affiliate links to the
             | books in the episode descriptions. We were going to wait
             | until we were a little bigger, but after today we might
             | have to speed up those conversations, haha.
        
               | opello wrote:
               | I can appreciate supporting the effort, but the
               | "stickiness" of Amazon affiliate links seem pretty
               | pernicious. I briefly tried to find a source for this and
               | failed, but my understanding is that the affiliate can
               | see any product purchased while the affiliation through
               | the link is active, which is something like a 24 hour
               | timeout or another link for a different affiliate is
               | used. Maybe my perspective is out of date, if so my
               | apologies, but that seems like a net negative
               | contribution to personal privacy of viewers.
               | 
               | Edit: This video humorously discusses the "leakage" I
               | think of as bad:
               | https://www.youtube.com/watch?v=M2PYgjgDdWg
        
               | carterdmorgan wrote:
               | Yeah, definitely not my area of expertise. We'll need to
               | explore it further and make sure there's nothing sketchy
               | before making a decision.
        
               | lokar wrote:
               | You can always provide two versions of each link
               | (affiliate/direct)
        
               | carterdmorgan wrote:
               | Good idea. Now that I think of it, I've seen other
               | creators do something similar.
        
             | opello wrote:
             | This exactly, yes, thank you. Sorry for being vague.
        
           | opello wrote:
           | Sorry, I didn't mean upcoming books, just the media discussed
           | in the episode. Like the ones I mentioned adding to my
           | watch/reading lists. It would have made finding them a little
           | easier is all and could serve as value to the description
           | since it's certainly the case that they were discussed in the
           | video! :)
        
       | 256_ wrote:
       | I read the Elements of Programming Style and the Practice of
       | Programming around the same time and they became completely mixed
       | up in my mind. I'll often remember something from one of those
       | books but be completely unable to remember which one it was from.
       | 
       | Both good books, and both were co-authored by Kernighan. I think
       | they complement each other well.
        
         | carterdmorgan wrote:
         | We might have to add Elements of Programming Style to our
         | backlog.
        
           | 256_ wrote:
           | Well if you're interested, the Elements of Programming Style,
           | to me, was interesting for two reasons. It presents plenty of
           | timeless insights about programming, but it's also very
           | interesting as a historical document; it argues against old-
           | fashioned GOTO-based programming in favour of structured
           | programming, and for-loops executing 0 times, for example.
           | 
           | It has a list of rules of thumb at the end, which contains my
           | favourite part of the book. Pretty much all of them are
           | timeless, but right in the middle is "Avoid the FORTRAN
           | arithmetic if."
           | 
           | The one big thing I disagree with it on is the weird idea
           | that you should never have 2 IFs in a row.
        
             | carterdmorgan wrote:
             | Sounds interesting! We're trying to figure out if we should
             | be focusing on more modern books even if they're "unproven"
             | or classics even if they're outdated. Sometimes reading the
             | classics can be a lot of fun because, like you said, they
             | serve as historical documents. As someone who started their
             | career a lot later, it's crazy to me that GOTO used to be
             | in style, but I suppose for it to fall out of style there
             | had to be a book arguing against it at some point. It'd be
             | interesting to read the original arguments!
        
             | mkehrt wrote:
             | Because I was curious:
             | https://en.wikipedia.org/wiki/Arithmetic_IF
             | 
             | It's a three way if statement that scrutinizes a number
             | rather than a boolean, with branches for negative, zero and
             | positive values.
        
         | richrichie wrote:
         | There is a talk he gave at IAS on this. Pretty good one. I
         | think it is available on You Tube.
        
       | commandersaki wrote:
       | Love Kernighan, such a humble person. In one of the videos that
       | he was featured on in youtube, he spoke about how he was solving
       | a difficult problem in his thesis which turned out to be NP-
       | complete before the theory had been fleshed out. Emailed him for
       | his thesis and got a pretty quick response, was a really
       | interesting read.
        
         | carterdmorgan wrote:
         | It's a rare combination to find someone both as intelligent and
         | humble as he is. Truly a blessing to our industry.
        
           | kaba0 wrote:
           | I believe you are right as intelligent grows, but the very
           | top end usually has people excelling in many things and
           | personality as well. At least that's what I noticed.
        
             | carterdmorgan wrote:
             | Certainly successful intelligent people often excel in
             | personalities. Hard to get places without playing nice with
             | others to a degree.
        
         | fuzztester wrote:
         | see the publications section here for more of his books:
         | 
         | https://en.m.wikipedia.org/wiki/Brian_Kernighan
        
         | dgb23 wrote:
         | > Love Kernighan, such a humble person.
         | 
         | A perfect example: Just about 3-4mins into the interview he
         | said that the motivation behind the book was "kind of
         | pretentious".
         | 
         | To me, and many others, his opinions on programming are amongst
         | the most interesting and useful. In large parts because he can
         | convey them so clearly.
        
       | xyzzy_plugh wrote:
       | The "g" is silent, folks.
       | 
       | You should try to get Rob Pike on. He'd probably make it a point
       | to correct your pronunciation. I can hear him now...
        
         | carterdmorgan wrote:
         | Yeah, someone on YouTube pointed out the same thing. D'oh. I
         | wish Brian would have corrected us!
         | 
         | We'd love to get Rob Pike on too! Currently working on it,
         | although he's a little harder to get a hold of.
        
           | nmz wrote:
           | You should ask the arraycast guys on how they did it. They
           | got him to talk about ivy and apl/array style programming for
           | an hour or so.
        
             | mseepgood wrote:
             | He's active on Bluesky and Mastodon.
        
       | rramadass wrote:
       | This book is foundational; all Programmers (especially beginners)
       | should read it. Like all Kernighan's books, the language is
       | simple, concise and precise focusing on the
       | foundations/essentials with no fluff and all in a little over 200
       | pages. Understand the principles from the examples shown here and
       | then apply them in your own context. The beauty of K&P's books is
       | that they do not overwhelm you with theory but show you the
       | craft/practical applications of it after which a study of the
       | theory becomes more accessible.
       | 
       | To give a concrete example; i had some experience in network
       | programming/protocol implementations before i came across this
       | book. In the "Notations" chapter, they show network message
       | pack/unpack routines written in the style of printf/scanf
       | functions with format strings specifying the packet layout! This
       | was a eye-opening lesson for me in the use of proper notations
       | and little languages. There is also some code snippet examples
       | showing ideas behind Virtual Machines, Code Threading, JIT
       | compilation etc.
       | 
       | Folks should also get Kernighan and Pike's older book "The Unix
       | Programming Environment" to go with this. The chapter "Program
       | Development" gives a complete example of developing a compiler
       | for a small calculator language using compiler development tools
       | (and no theory!) in around 50 pages. This is the smallest and
       | simplest exposition that i know of on how to write a compiler.
       | 
       | In summary; get all of Kernighan's books and study them! :-)
        
         | carterdmorgan wrote:
         | Thanks for the heads up on "The Unix Programming Environment!"
         | I've been searching for a book with a concise explanation on
         | how to write a compiler, and you can't go wrong with one from
         | Kernighan!
        
         | mehdix wrote:
         | Can only second you. His style is by far my most favorite among
         | all other technical authors. And thanks for the reminder, time
         | to get another one of his books.
        
           | rramadass wrote:
           | > His style is by far my most favorite among all other
           | technical authors.
           | 
           | All authors should learn from Kernighan's books (co-authored
           | with Plaugher/Ritchie/Pike) on how to write technical books.
           | 90% of all the computer programming books published nowadays
           | are too verbose (why the hell are they so huge?), meandering
           | over inessentials, lack of clarity in language, a paucity of
           | clear and precise examples and overall just a waste of paper.
           | Reading them is more of a chore then enlightening whereas all
           | of Kernighan's books are only a little over 200 pages, dense
           | with knowledge and a pleasure to read.
        
             | Arisaka1 wrote:
             | In discussions with colleagues they blamed the absurd
             | demands of the publishers in terms of hitting specific
             | volumes (in pages), which oddly reminds some past
             | relationships I had with management and sales departments
             | as a developer.
        
         | kaycebasques wrote:
         | Just ordered the true Gang of Four:
         | 
         | * The C Programming Language
         | 
         | * The UNIX Programming Environment
         | 
         | * The Practice of Programming
         | 
         | * The Elements of Programming Style
         | 
         | I've read the C book before and also remember the writing to be
         | excellent. I'm sure I'll pick up lots of programming wisdom but
         | I'm also approaching this as a technical writer, figuring out
         | what exactly makes Kernighan's books so good. I have a hunch
         | that Kernighan has studied writing a lot, or has at least done
         | a lot of "first principles thinking" about writing. The title
         | "The Elements of Programming Style" for example is a reference
         | to one of the most famous books about writing style, "The
         | Elements of Style" by Strunk and White (which everyone should
         | read once; it literally fits easily into your back pocket).
        
           | carterdmorgan wrote:
           | One of the great things about The Practice of Programming is
           | how much it references other non-coding works. You can tell
           | Kernighan draws his knowledge from many sources, not just
           | technical ones.
        
             | foobarian wrote:
             | Well one does wonder, where _did_ the icons like BK pick up
             | their own craft? Surely there were no programming books
             | before computers. Which shoulders did our giants stand on?
        
           | dehrmann wrote:
           | No idea what your background is, but since you just bought
           | four books, make sure you're spending more time reading and
           | writing code than reading books. Some people fall into the
           | theory trap and don't spend enough time making use of that
           | theory.
        
             | carterdmorgan wrote:
             | Agreed. Reading books is great if it's replacing Twitter
             | and Reddit time. It's not great if it's replacing coding
             | time.
        
               | kaycebasques wrote:
               | > I'm also approaching this as a technical writer,
               | figuring out what exactly makes Kernighan's books so
               | good.
               | 
               | I am docs lead for https://pigweed.dev
               | 
               | I will probably also eventually post my findings to
               | https://technicalwriting.dev
        
           | rramadass wrote:
           | To your first three above, add Marc Rochkind's _Advanced Unix
           | Programming_ and Richard Stevens ' _Advanced Programming in
           | the Unix Environment_ and you have got yourself a complete
           | course in C /Unix programming which is the bedrock for
           | everything else; C is the "lingua franca" and Unix (via its
           | variants) the "standard" OS.
           | 
           | Tip: Many of these old books can be had for cheap as used
           | copies on Amazon/Betterworldbooks etc.
        
           | mvdtnz wrote:
           | In fact if you disregard the contents and preface, the very
           | first words in The Elements of Programming Style are a quote
           | from The Elements of Style,
           | 
           | "It is an old observation that the best writers sometimes
           | disregard the rules of rhetoric. When they do so, however,
           | the reader will usually find in the sentence some
           | compensating merit, attained at the cost of the violation.
           | Unless he is certain of doing as well, he will probably do
           | best to follow the rules."
           | 
           | William Strunk and E. B. White, The Elements of Style
        
         | munificent wrote:
         | _> This is the smallest and simplest exposition that i know of
         | on how to write a compiler._
         | 
         | I haven't read Kernighan and Pike's book but another really
         | small compiler exposition I like is Wirth's PL/0 in "Algorithms
         | + Data Structures = Programs". A little outdated at this point,
         | but still a very pleasant read.
        
         | coolbreezetft24 wrote:
         | As someone who has been programming professionally for 10 years
         | - what would I gain from reading this book? Not to sound snarky
         | but genuinely wondering what makes it a 'must read' for people
         | who are comfortably coasting in their careers
        
           | blandblender wrote:
           | If you're at Goog or Meta, you probably have seen best
           | practices around you. If you're working at elsewhere, some
           | things in the book would might be new to you.
        
       | fuzztester wrote:
       | Another author and his books in the same category of excellence
       | as Kernighan and his books, is Jon Bentley and his books
       | Programming Pearls and More Programming Pearls.
       | 
       | https://en.m.wikipedia.org/wiki/Jon_Bentley_(computer_scient...
        
         | carterdmorgan wrote:
         | Added to the backlog! As our audience grows, we've debated
         | doing live backlog grooming on YouTube so that listeners have a
         | chance to chime in and voice their opinions on what we should
         | read.
        
           | fuzztester wrote:
           | I think that's a good idea.
        
         | rramadass wrote:
         | Also his earlier slim _Writing Efficient Programs_ book. What
         | this teaches you is how to think about efficiency from the top
         | down with an emphasis on Algorithm and Language and hence
         | useful to all programmers. Pair it with modern books on
         | efficiency which deal mainly with compiler-level /OS-
         | level/Processor-level performance techniques by Agner Fog,
         | Fedor Pikus etc. and you get a complete picture.
        
           | fuzztester wrote:
           | >Also his earlier slim Writing Efficient Programs book.
           | 
           | Yes, that's a really good one. I own a copy of it, bought
           | years ago, and have read it pretty much cover to cover. Have
           | also applied the guidelines in it, some.
        
           | fuzztester wrote:
           | the war stories briefly mentioned in the footnotes of the
           | book, are very interesting too.
           | 
           | for example, one of them is about a team that speeded up the
           | run time of a quicksort implementation on a supercomputer by
           | a factor of a thousand times (yes, times, IIRC, not percent),
           | by doing successive optimisations at many layers of the
           | stack, from high level algorithms and data structures, down
           | to the hardware.
        
           | fuzztester wrote:
           | >with an emphasis on Algorithm and Language
           | 
           | did you mean algorithms and data structures?
        
       | fuzztester wrote:
       | https://en.m.wikipedia.org/wiki/Brian_Kernighan
       | 
       | that link mentions many more of his achievements.
        
       | fuzztester wrote:
       | I suggest you add Software Tools in Pascal to your list of books
       | to podcast about. Also by Kernighan.
       | 
       | I own a copy of that book and think it is good.
        
         | AnimalMuppet wrote:
         | You might get more than you bargained for on that topic.
         | 
         | Kernighan and Plaugher had written "Software Tools" in RATFOR.
         | Then they wrote "Software Tools in Pascal". And then, in direct
         | response to the experience of writing that, Kernighan wrote a
         | paper titled "Why Pascal Is Not My Favorite Programming
         | Language". (Because writing in Pascal should have been way
         | easier than writing in RATFOR, and it wasn't, and Kernighan
         | gave some thought to why it wasn't.)
         | 
         | It's still an interesting read. You can find it online, for
         | example at
         | https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pas...
         | 
         | Note well: This refers to the original standard version of the
         | language. Extensions like Turbo Pascal fixed many of the
         | problems. (Except that, as he said, there was no portability
         | between the extensions. Even that kind of was fixed by Turbo
         | Pascal becoming the "standard" extensions.)
        
           | rramadass wrote:
           | Just to add to the above; RATFOR
           | (https://en.wikipedia.org/wiki/Ratfor) was implemented as a
           | preprocessor to Fortran with its control structures almost
           | identical to those of C. So going from the freedom of C
           | syntax to the straitjacket of Pascal might have been too much
           | and hence the Pascal paper.
           | 
           | Here is the pdf of Brian Kernighan's paper on RATFOR -
           | http://www.econ.uiuc.edu/~roger/research/repro/ratfor.pdf
        
         | pjmorris wrote:
         | Finding 'Software Tools in Pascal' in my local mall bookstore,
         | before I even had access to a computer running Pascal, turned
         | out to be a kind of cheat code for my career. I marveled at the
         | ideas and the writing and it set me up to acquire much of the
         | the rest of the Kernighan canon.
        
       | fuzztester wrote:
       | Kernighan is also a co-author of The Go Programming Language
       | book, at least of the 1st edition.
        
         | voidUpdate wrote:
         | Is that why Go forces K&R brackets instead of letting you
         | choose?
        
           | bxparks wrote:
           | Maybe you already know this and your comment was in jest, but
           | the real reason is that the Go lexer automatically inserts
           | semicolons (https://go.dev/doc/effective_go#semicolons) using
           | heuristic rules which forces the opening brace to be on the
           | same line.
        
           | fuzztester wrote:
           | Kernighan was a co-author of the Go book, but I don't know
           | how much he was involved with the actual design of the
           | language. Maybe not much, or at all, although, of course, he
           | is a key part of the original Unix mafia (my term, not
           | pejorative), rather meant admiringly), many of whom are still
           | going strong in their 70s and 80s. So the Go bracket style
           | may not be attributable to him.
        
       ___________________________________________________________________
       (page generated 2024-07-11 23:02 UTC)