Saturday, 15 October 2011

Dennis and language design

I hadn't intended on writing this entry until Rick Floyd posted about Dennis Ritchie's fine and sparing taste. This brought to mind the influences of language design on C and (by extension) C's influence on further languages.

C's history is well known: it is descended from 'B', which is completely unknown. However, we can look at BCPL. BCPL is a descendant of CPL, which was designed by none other than Christopher Stratchey (talk about an illustrious family, the Stratcheys are amazing). A look at CPL is illuminating: if you know BCPL, then you can see the providence right there. For an example, see his checkers program by Peter Norvig's.

However, CPL was less real than BCPL. BCPL was designed by Martin Richards at Cambridge in 1967. It had a number of interesting features: First, it was designed to be portable over different machine architectures. Second, it's fundamental data type was the machine word. For an assembly language programmer like myself, this was heaven: I could write algorithms and imagine the assembly. Furthermore, the structure construct included both words and bits --- thereby providing an immediate mapping to the machine architecture (device drivers and other machine dependent code). BCPL was the first language for the Alto (which is where I learned it).

So, back to C. What did Dennis to do Ken's version of BCPL? Well, the first thing you have to know about Ken is that he codes fast ... And I think he hates to type. Ever wonder why the Unix kernel has so many short names? Blame Ken. So, then Dennis had to create a spare notation to match. But I think the most noteworthy change was going from words to data types. C goes away from the machine dependent side by incorporating types of Algol 60 lore --- except not making the mistake of calling floats reals. Now, I would be remiss if I didn't mention how C imported bits of the PDP-11 assembler syntax: Ever wonder why autoincrement is ++? Don't. But perhaps the key innovation was the use of the address and de-address operators (& and *). Now you can talk about pointers.

C has undergone many changes since I first learned it at Berkeley reading the Sixth Edition Code. But since I already knew BCPL, it was an easy move. Let me add that I've always loved the for statement in C (even though as a language guy, I know you shouldn't really have more than one way to say something). When you see a for loop used to traverse a list, then you know that's clever.

It's interesting that people mention Java as a descendant of C. If anything, from my perspective, Java is the anti-C. It's way more verbose and eliminates pointers. There are of course many other changes but C is pretty far from Java in my book. And then there's C++, C# and Objective C. They all include the name 'C'...

I wanted to add a personal note about Dennis: He was very private. I certainly knew very little about him during my time in 1127. I do remember when I first got there and a bunch of us were going out to dinner. I stopped by to ask Dennis if he wanted to go. He politely declined. When I reported this to my companions, they said "Sure, Dennis always eats at home with his parents". That's the kind of guy Dennis was. Nice, quiet ... and clever.

No comments: