Z Space Blog

your source for Game Z

Why I learned C "Category-0" Style

I've been asked a few times over the years why I chose to learn C with the colloquially-known "K&R C Bible", and specifically the Category-0 style, coined on USENET back in the day.

For those unfamiliar, I'm talking about The C Programming Language, 2nd Ed., by Brian Kernighan and Dennis Ritchie, the creators of the language. In it are a series of exercises that the reader can work on to build their knowledge of C through actually building something with it. On comp.lang.c, people would share their solutions to exercises in this book. After a while, they coined different categories of solutions, to refer to their robustness and complexity.

Category-0 is solving each exercise using only the knowledge the book gives you, up to that point. In other words, it's to approach it as a complete newbie and see what you can put together using only the stuff you've learned in the book.

I had considerable difficulty learning C at first, due mostly to its similarities to C++, the challenge of finding good advice and practice, etc. I settled on the K&R because it was written by the original language authors. By choosing my reference on that criteria, I was certain to find a book that was more accurate than most, at minimum.

After buying my copy and eventually discovering the clc-wiki, I started grinding out my own K&R solutions. As you can see via the commit log on the repository, it was a very slow advancement due to real life interfering. But I did eventually complete it, so that's cool, right?

Similarly, I have a copy of Programming in Lua, by Roberto Ierusalimschy, one of the language's authors, and it's also a wonderful resource in teaching me Lua. I've heard Stroustrup's C++ books are great for learning. I would buy a similar reference for Python by Guido van Rossum, but Python is a large beast that evolves quickly via PEPs and its online docs are superb, so I'm not sure what the value of it would be.

If you're into C, feel free to give it a look. Patches and constructive feedback are both welcome. There are plans to make a "modern C standard" version of the solutions as well, to illustrate the difference between "good code for learning" and "the way you should actually build this".