Thursday, May 3, 2007

Crayons and coloring books

In one of my first blog posts, I lamented how I was frustrated with web frameworks and disappointed by the lack of libraries. I suppose this may be a result of my Un*x development background in which the mantra has been "tools not policy". Frameworks are all about policy.

Just recently I read an amusing analogy that reflected the feeling I got when investigating python web frameworks. Which got me thinking again: why is it that frameworks feel so wrong to me?

Then this morning I finally found the words to express my frustration: Frameworks are coloring books; libraries are crayons.

If you want to draw a picture, crayons are a tool to do it. You can draw whatever you like, in whatever color you like. And the final result, depending on your drawing ability, will look exactly as you intended.

Or you can flip through coloring book after coloring book for a picture that looks vaguely like what you had in mind. You may find what you want quickly, or you may spend days and still not find what you really wanted but get sick of looking so settle on something "good enough". The good news is, once you settle on a picture, you now have a rough idea what your result is going to look like.

Now you are free to color it in whatever color you like (notice that you still need crayons for the coloring). Assuming you were able to stay within the lines, you'll end up with a pretty consistent result. The colors are yours, but the overall image is that of the coloring book picture you started with.

Don't get me wrong: a coloring book can save you a lot of work. For better or for worse, you can start coloring with a pretty good idea of what your picture is going to look like. But what if I don't want to rehash the same picture that has been colored in by a hundred other people before me? You know, what if I want to actually create something new? Well, I've seen people color outside the lines, and it is rarely attractive.

Perhaps the crayon analogy is too pedestrian: try oil paintings instead. Frameworks would be paint-by-numbers templates; libraries would be oil paints. If you are just getting started in oils, a paint-by-numbers template can help you make a nice painting pretty quickly. It won't be original, it won't be great, but you'll still probably get compliments on it from your friends and family.

That said, if I want to make a web site just like a hundred other web sites (with different colors, of course!), a web framework would probably save me a lot of time. For example, if I were making a content management system, especially for a newspaper, Django would be a good framework for the job.

Now there seems to be a lot of database-backed, simple CRUD web applications. Which explains why so many web frameworks make (or try to make) CRUD easy. And along the same lines, a lot of little girls like ponies so there are a lot of coloring books with pictures of ponies; one pony with its head up, or two ponies, or ponies eating grass. If I wanted to draw a pony, I would have an embarrassment of riches. With a little creativity, I could even draw a unicorn.

And therein lies the rub: I don't want a pony.

Which explains why frameworks don't feel right to me: they aren't. There is nothing wrong with frameworks per-se; they just aren't right for me. Which still leaves me with the question of why good libraries are so hard to find, but I already covered that peeve in my first rant.

No comments: