One subject that pops up often in computer science discussions is design, in particular the idea of a good design and proper abstractions. The idea that can you build an abstraction that will be usable in multiple cases and in the future is very pleasing.
Conversely operating system and libraries are littered with broken designs so that the resulting system are overly complex and brittle. How comes so many people thrive for good designs and so many bad designs see the light of the day? Are there so many incompetent designers? Some evil conspiracy maybe? From my experiences bad designs are mostly the result of two things: premature designing and changes of scale.
Premature designing is what you learn at the university, i.e. writing code that is generic and reusable. Problem is, many people do this before they have concrete plans to reuse their abstraction in another application, often the code ends up being reusable in ways that are not needed, but the abstraction is made needlessly complex to support these use cases.
Unix sockets are a typical example of complexity introduced by generality: they kind of reuse the Unix file abstraction, while at the same time supporting multiple network protocols, multiple messaging semantics. It works for the main protocols (internet and Unix domain), but it is not nice to use, and many older networking protocols have been dropped, you can’t open an Appletalk socket anymore (I doubt this ever worked, but I remember the options being there at some point).
The second problem is that designs, even the most beautiful ones, typically don’t scale more that two orders of magnitude. Consider one of the oldest tools: the knife. A typical knife’s blade is around 20 cm in the length, swords are big knifes, but beyond 200 cm, the design becomes unwieldy. There are small knifes, but below 1cm of blades, the whole design changes. There are many different designs for the same task of cutting stuff, axes, saws, lasers. There is no perfect design.
The protocols that underlie the internet all have scale problems: IPv4 has reached the limit of its 32 bits address space, the retransmission window of TCP cannot cope with fast, long links. TCP also assumes that devices generally have one IP address, which is typically false on all mobile phones.
It took thousands of years to get to the design of Japanese swords, by the time that shape got perfected, the whole sword idea was getting obsolete. Computer designs have by far not reached the beautiful stage. As long as things keep growing exponentially and people keep on reinventing wheels (preferably without the radial symmetry), designs will probably stay clunky and ad-hoc…
Japanese Guntō – © Rama – Creative Commons.