Wednesday, June 13, 2007
Programming like Lego? I gave that up long ago
[S]oftware is not like Lego; we still do not assemble software from ready-made components as if we were building a Lego house. Almost every programmer has to write low level stuff like if blocks, for and while loops, opening and closing files, creating and deleting resources, thread synchronization etc.
I never thought of while loops or opening a file as “low level details.” Twenty-five years ago, “low level” was writing in Assembly language and twiddling bits. But times change, and what was once a high level language (C++) is now considered “bare metal,” much like Assembly was years ago.
But “while loops” and “if blocks” are low level details? I don't
necessarily think so. You might be able to hide such things behind more
syntactic sugar (just as “while loops” hides the
built out of) but I don't think you'll ever hide them completely (exceptions
are one way of hiding a
goto but I think that particular cure
is worse than the original disease it tried to cure).
And there are others out there who will say we have software Lego—the Unix command line. A series of pre-written programs (easily over a thousand such programs) that can be linked together in millions of ways.
Actually, the more I think about it, the more I'm inclined to think that the Legoesque metaphore of software development is not the way to go. We've already been there and have gone beyond it. In its pure form, Lego has a limited number of bricks, in a limited set of colors, which can be used to build just about anything you can imagine. That is, if you don't mind your resulting thing looking a bit blocky. The closest thing we have to that in computer science? Other than the command line, the only computer language I can think of that fits that (limited number of commands is the closest analogy I can think of) is Assembly. Moving, shifting, adding (among other mathematical operations) and testing of bits comprise over 80% of Assembly language (the other 20% Shifting execution to other parts of the program and some other, really esoteric operations usually reserved to the operating system itself).
How many programmers today use Assembly daily?
We've got tools that will take a high level concept like:
double A; double B; double C; C = A × B;
And assemble all the
Lego bricks Assembly language
instructions required to express the concept (in this case, matrix
multiplication). We'll do better, programming wise, to program at higher
conceptual levels, than in trying to make programming like Lego bricks.
(I'm also finding Scott Rosenberg's Code Reads well worth reading)