Thursday, September 13, 2007

Read more code!

By now most of you have probably read on SlashDot that QNX has opened part of the QNX Realtime OS source code.

Naturally I'm jumping on the opportunity to read more code written by others.  I find it fascinating, particularly with mature projects.  For example, here's the QNX kernel entry code for x86 (written in assembler of course).

Fascinating!  I can read it but I don't understand half of what it's doing.  What more could I expect after looking over a few source modules for less than half an hour?  Too little context.  But oh so much fun!

When I was a kid a several time TI user group members gave me boxes of old TI stuff including books like TI99/4A Intern, schematics, maintenance manuals and reverse-engineered specifications.  I can't count how many hours I spent absorbing all of that knowledge.  I was happy as a clam!  And I eventually put much of it to good use in various software and hardware hacks...

Here's some advice I often offer to programmers:  Read as much code written by other people as you possibly can.  Think critically about what it does, the problems it solves, how it was written, how it was tested, the team that created it, and the context in which it was born.  Use that insight to improve your own work.   (Besides, if you don't enjoy reading code, how are you going to survive doing it all day long?)

Corollary: Also read lots of books about code...

No comments: