Focus, Not Flex

Written on October 23rd, 2012. We've got comments, too!

I stumbled across something new today: a fresh Content Management System. One great for blogging. It’s called kirby, and it’s awesome.

And thus my ditching of Wordpress is complete!

Kirby sports a flashy no–database–at–all approach, and it’s one of the best I’ve seen. It also addresses a horrible problem I’ve been struggling with: the overuse of super-flexible platforms. Like dear old Wordpress. Sometimes — no, almost always, you don’t need the full grunt (and weight) of something like Wordpress for a simple blog. And I’m perfectly cool with writing in Markdown or vanilla HTML. I’ve had enough of those <? get_the_title(); ?> tags.

Flexibility comes at great cost. Great complexity cost. Remember, these content management systems are really just front-ends to a database. So why are we dealing with confabulated taxonomy systems and plugins?

Cachegrind is a tool that allows me to see how PHP processes a script (here’s how to do it on MAMP on OS X). It’s great for finding bottlenecks in code. Here’s the output for a simple Indonesian-language Wordpress blog:

cachegrind
Click for a better view.

The list goes from the most expensive operations (top), descending down. The “Total inclusive cost” refers to how much time is spent doing this operation, plus any other stuff this operation invokes.

All those “MO”, “PO”, and “Translate” bits are part of the translation feature. It’s spending a huge amount of time just to translate a few bits of text into Indonesian. Is this a fair price for something as trivial as translation? I think not.

As Rasmus Lerdorf said in this talk, most of a program’s work should be in the database. A CMS is, again, mostly a database front-end. See how even cache calls here are more expensive than mysql_query()? There are also horrifyingly slow calls like get_permalink(). Would fetching a permalink cost 40 milliseconds? Granted, most of that lag comes from file/database reads. A good cache system should eventually fix it. And a really experienced developer would know which calls are expensive and how to avoid them. It’s not an unfixable problem.

But most websites don’t care. Instead of tweaking code, they simply throw more hardware in the ring. It makes sense when they compare a developer’s cost to that of a server… Until something big happens and the server collapses. This isn’t a case of premature optimization — it’s a case of fixing a problem before it (inevitably and hopefully) occurs.

Kirby, my new CMS, doesn’t have that extra baggage. It accepts blog posts in simple text files, written in markdown. So the bulk of the work is split between reading files and parsing the syntax. That’s it. Wordpress’ cachegrind file was 10MB large. This blog’s is under 500KB. And the processing time was cut by a factor of 100.

I can use Kirby because I trust myself to write for it. I’m a programmer, after all. Wordpress and its kin may be more appropriate for everyday people… At least until I find a good replacement!