K&R and thoughts on the Graph API
With this post I’m going to do something I promised myself I wouldn’t do while writing this blog - kvetch like an old grumpy man. But there’s a point:
While I was in San Francisco for f8, I had the good fortune to attend an informal meeting of Facebook developers to discuss the changes to the Platform that were announced at f8. It was graciously hosted at the offices of one of the leading Facebook development companies in the city. They were beautiful offices high up in an historical building with great views, and more Red Bull than a developer could drink.
While there, I noticed a copy of the iconic Kernighan and Ritchie (K&R) book on the C language sitting on a desk. What transpired was a short conversation between myself and one of the employees of the company:
Me : Very impressive, someone still reads K&R.
Him : <Blank Stare>
Me : The Kernighan and Ritchie book on C – it’s a classic
Him : <Blank Stare>
Me : You should read this book, it’s so beautifully written. Look how thin it is, and the whole language is thoroughly described with examples and exercises.
Him : Yeah, the Rails documentation is much thicker
Me : <Blank Stare>
Him : That’s our CTO’s desk – it’s probably his book
Okay, so the point here is that I’m realizing that you can actually get a degree in Computer Science without ever reading K&R. Without learning C. Without really understanding what goes on at all levels inside the computer without it all getting abstracted away. I was starting to feel bad that this whole drag-and-drop Rubyization of the world was creating developers who weren’t grounded in the basics. Who didn’t deeply understand how to properly analyze an algorithm. And who probably didn’t read stuff from guys like Joel Spolsky who kvetched about it all.
But then something else crossed my mind. The reason I love C and K&R so much is because it works on so many levels. You can use it to develop (practically) on the bare metal. You can use it to write customer-facing applications. You can use it to build a server. However, it’s becoming true that the higher off the metal you get, the harder it is to use C (or even C++). Web apps, Application Servers, Multi-tiered architectures, virtualization – all of these things are so much easier to do with more “modern” languages. And you know what, I’m okay with that.
So here’s my wish: Go get a copy of K&R and read it. I used to own 3 copies: one for work, one for home, and one for lending out. Even if you never plan to use C, please read it. It’s the best technical documentation you’ll ever read, and something you should aspire to. And the reason this is true is that the language is robust and, most importantly, simple.
Which brings me to the new Facebook Graph API and the way it simplifies everything. I think we should all say Hurray. K&R reminds us that simple does not have to mean not powerful. And what the Facebook guys did with this API reminds me of what Dr. Kernighan and Dr. Ritchie had done previously. Go read the book so you too can be inspired to continue building things that are both powerful and simple.
Postscript
For sheer entertainment value, you can’t beat the first version of the Java Language spec. In particular, check out the index entry for index entries to see all of the great references they included, and see how many you can understand. Their description of multiple inheritance (Section 20.3.5) is inspired, obscure, and absolutely brilliant.
3 Comments
Other Links to this Post
RSS feed for comments on this post. TrackBack URI













By William Spears, April 26, 2010 @ 12:02 am
I taught CS3020 Analysis of Algorithms for 12 semesters at UW. It was supposed to be a C++ course. But, I also have 2-3 copies of K+R, so I made sure to throw in some C. It is really sad when 3rd year programming students don’t know what printf is, and arrays (as opposed to vectors). I told them that they *will* encounter legacy C code, and not everything is cin and cout! Generally they actually wanted to learn more, and I did my best to oblige – but since they only had experience in C++ before I couldn’t get very far.
As far as “Who didn’t deeply understand how to properly analyze an algorithm.”, well, I taught the course in a language independent fashion, so they should be able to apply the concepts if they learned them at all. Even w/r recursion.
The biggest concern was a total inability to debug code, however. With the invention of stupid IDE’s, they figure if it compiles it must be semantically correct. I must have repeated 1000 times: “The only real way to debug your code is to trace everything with printfs and do it the hard way – with real thinking”.
Things are much worse at the graduate research level – where CORRECTNESS is of enormous concern. Due to bad software engineering courses, I had to get them to unlearn all the bad habits and focus on correctness and speed. Ultimately I converted most of them to pure C folks.
By William Spears, April 26, 2010 @ 12:03 am
Also, I use the *first* edition of K+R. Ha…
By Sander Smith, April 26, 2010 @ 9:57 am
Wow, how did you get several copies of the first edition of K&R? I remember holding one once and feeling a great sense of reverance towards it. On the other hand, my understanding is that it’s geared more towards compiler writers than app developers.
I’m glad that you’re stressing the fundamentals with your students. It’s amazing what can be done with RoR and a spare 2 hours, but it’s all flashy interface and database lookups. For real processing, there’s so much more that needs to be understood.