Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Zed Shaw on Deconstructing K&R C

Name: Anonymous 2011-12-03 1:32

The book is still unfinished/alpha, but he's started work on this final chapter already.
http://c.learncodethehardway.org/book/learn-c-the-hard-waych55.html

When I was a kid I read this awesome book called "The C Programming Language" by the language's creators, Brian Kernighan and Dennis Ritchie. This book taught me and many people of my generation, and a generation before, how to write C code. You talk to anyone, whether they know C or not, and they'll say, "You can't beat "K&R C" . It's the best C book." It is an established piece of programmer lore that is not soon to die.

I myself believed that until I started writing this book. You see, "K&R C" is actually riddled with bugs and bad style. Its age is no excuse. These were bugs when they wrote the first printing, and the 42nd printing. I hadn't actually realized just how bad most of the code was in this book and recommended it to many people. After reading through it for just an hour I decided that it needs to be taken down from its pedestal and relegated to history rather than vaunted as state of the art.

I believe it is time to lay this book to rest, but I want to use it as an exercise for you in finding hacks, attacks, defects, and bugs by going through "K&R C" to break all the code. That's right, you are going to destroy this sacred cow for me, and you're going to have no problem doing it. When you are done doing this, you will have a finely honed eye for defect. You will also have an informed opinion of the book's actual quality, and will be able to make your own decisions on how to use the knowledge it contains.

In this chapter we will use all the knowledge you've gained from this book, and spend it reviewing the code in "K&R C" . What we will do is take many pieces of code from the book, find all the bugs in it, and write a unit test that exercises the bugs. We'll then run this test under Valgrind to get statistics and data, and then we'll fix the bugs with a redesign.

This will obviously be a long chapter so I'm going to only do a handful of these and then I'm going have you do the rest. I'll provide a guide that is each page, with the code on it, and hints to the bugs that it has. Your job is to then tear that piece of code apart and try to think like an attacker trying to break the code.

I think his approach is a Good Thing that the software world needs, but probably will dismiss anyway merely because of his curly brace style.

Name: Anonymous 2011-12-17 6:26

"Learn C The Hard Way" (LCTHW) is a book by Zed A Shaw about C programming. It extends his "Learn Code The Hard Way" series, a collection of books aimed at helping beginners learn to code, ostensibly the hard way.

Despite their name, Zed's books present an authentic and forthright dialogue, demonstrating the effectiveness of traditional pedagogy in a modern context.

The books are targeted at novice programmers. To experienced coders, Zed notes, "You won't learn anything from it since the entire book is me telling you to do repetitive boring tasks." This, along with the patronising nature of the books has earned them disdain among veteran coders.

The most common criticism of the books comes relates to a chapter in Learn C The Hard Way, titled "Deconstructing 'K&R C'". In this chapter Zed's arrogance and perversity are put on full display. Zed attempts a critique of the time honored and widely regarded book, "The C Programming Language" by Brian Kernighan and Dennis Ritchie. Zed falls far short of providing any actual substance and as a result has, in one of the most disgraceful displays in modern history, was outcast from the programming communities and censured on /prog/, newsyc, /r/programming and LTU.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List