Project Aardvark

Reflector: Feature-Complete

Thursday, May 26, 2005 posted by Benjamin Pollack

For the past two and a half days, I’ve been methodically chopping away at one of the four major components in Aardvark. The experience was a bit exhausting; I went from knowing no C# and only a limited amount of .NET at midmorning on Tuesday to basically hitting feature-complete on the component called the reflector at 1:00 PM Eastern. Now, I’ll be the first to admit “feature complete” is a code word for “still has a ton of small yet annoying bugs that you ‘forgot’ about for the time being, and at least one major bug that, if properly triggered, will cause your computer to explode” (see antonym: “finished”), but the fact that I was able even to get that far that fast attests to two things: the power of a good development environment and the value of a good product specification.


As you have all probably inferred from Joel’s photo of all the books we have to read, Aardvark will largely be implemented in C#. I initially approached C# with a bit of trepidation. Although my bread and butter (and grades) depend on C++ and Java, anyone who knows me well knows that I’d much rather be working in one of the dynamic languages—especially Squeak Smalltalk or Ruby—than in any of the C descendents. My previous experiences with Microsoft languages (VisualBasic in all of its many varieties) did not exactly raise my expectations, and I was prepared for the worst. After a few days, though, I can honestly say that C# basically feels like Java with many of the problems removed and surprisingly few new issues of its own. The .NET library, too, has been very solid, and several components whose counterparts only just arrived in Java 5 (such as relatively easy-to-use non-blocking I/O) greatly expedited my work. I’ve also begun playing with Mono—an open-source/free-software implementation of .NET for Windows, Linux, and Mac OS X—on my PowerBook, and have been fairly impressed. .NET, at least in its non-graphical variety, seems likely to become genuinely multi-platform. The fact that .NET is so similar to Java in so many ways does mean that it is not revolutionary by any stretch of the imagination, but even an incremental improvement can greatly aid productivity.


Yet VS.NET was not the tool that most aided my coding. That honor goes to the Aardvark product specification. Last semester, I served as an undergraduate teaching assistant in a course that is supposed to teach advanced program design. As part of the course projects, students had to write detailed specifications describing how their project would work. A lot of the students loathed writing these specifications, and generally wrote as little as possible. They then plowed in with half-finished designs, changed everything as they discovered they had failed to account for basic functionality, and ended up with a product that had little relation to their original proposal. The end result usually worked; it was even frequently well-designed. But the students went through a lot of needless pain by not planning ahead, and then having to go back and rewrite large amounts of code.


The Aardvark spec, in contrast, is exceedingly detailed, and makes crystal-clear how each discrete component should interact with the others. Quick sketches of screenshots show how a user will interact. Protocol specifications detail precisely how various components will communicate. Questions that cannot be easily answered without running prototypes are prominently flagged so that we know where we will experience potential problems and can prepare for them with flexible code. That does not mean that all of the decisions are already made for us at all; the reflector clocks in at 950 lines of code, and designed its internals on my own. We’ll all have to do likewise on the other components as well. What it does mean is that we can write the components in isolation. Once I finish writing a solid testing framework (probably using NUnit), use that to iron out the remaining bugs, and do one last empirical verification that everything is working properly according to spec, I can know that the reflector will work when it’s dropped into the rest of Aardvark—even though none of those components currently exist.


That’s power.


Next week: details on New York City (short version: it rocks) and a discussion of bringing the REPL to .NET.