sab39

... indistinguishable from magic
effing the ineffable since 1977
The Unix philosophy of Lego bricks

The Unix philosophy of Lego bricks

10/26/2005

As a child I spent an inordinate amount of time playing with Lego (was it just me or did anyone else invent names for the bricks? I had Long-ers, Square-ers, Tippees, Flat Tippees, Very Flat Tippees, Tipping Up Tippees...) The fact that a tubful of basic components could become the most fabulous spaceship I was capable of imagining had a huge influence on me and was probably a large factor in why I became a programmer.

I really think I'm onto something with cmeScribble but I've had a hard time coming up with a way to explain exactly what I think I'm onto. Part of that is because, obviously, I'm writing largely for an audience that isn't familiar with cmScribe, the philosophy it tries to embody, the strengths of its approach or the limitations we're starting to hit. Perhaps I should let my ten-year-old self explain by analogy.

We needed a powerful layout system so we came up with Lego.
Then we needed flexible hierarchical navigation so we built in Duplo.
Then we needed some place to put the content so we made a Rubik's Magic.
We built an eCommerce system out of Meccano.
We built a document repository out of Rubik's Snakes (those were great, weren't they?)
We made a general-purpose form builder out of MegaBloks.
We made a permissions system out of whatever that cool thing was that had all the translucent octagonal pieces with slots in the sides.

And every time we add a new feature we get a different type of construction toy to make it out of.

We've done a good job of making all these things work together. To display products in the nav we built an adapter that allowed Meccano to attach to Duplo. We built adapters so that octagons could be attached to anything. We built adapters to connect Meccano to Rubik's Magic. We built adapters and adapters and more adapters.

What we've ended up with is something that's extremely flexible and powerful, but in doing so we've solved the same problem lots of times - making one kind of toy talk to another, or making one toy appear as if it's a different kind of toy, or solving a problem for one kind of toy that was already solved for one of the others (notably, our Rubiks-Magic search is entirely separate from our Meccano search).

The idea behind cmeScribble is "what would happen if we just did it all with Lego[1]?"

The Lego philosophy and the Unix philosophy have a lot in common. In cmScribe we got the bit about "Do one thing and do it well" right, whether the one thing is "match a regular expression" or "be two by four, full height and red" or "display a product list". But just as important, if less expressable in a pithy slogan, is that the reason Lego and Unix work as well as they do is that every part has a common interface. In Unix it's the plain text file with each line representing some kind of value. In Lego it's the little round bump and the little bump-sized hole. In both cases the power comes from the fact that any piece's bumps can attach to any other piece's holes without having to create a custom Long-er-To-Very-Flat-Tippee-Adapter.

In the next thrilling installment: What do I propose as cmeScribble's little-round-bump-equivalent?

[1] Lego is, after all, the One True Construction Toy and MegaBloks can bite my small cuboidal plastic butt ;)