People have an interesting tendency to believe that best practices do not apply to them. In this post I discuss the “I’m special so I should write my own web framework” case.
Take for instance:
- Writing a CV. Best practice states that shorter is better, but oh so many people still want to have an eight-page CV because they are special.
- Web frameworks. Best practice states that using an established, documented and supported framework is better, but look at the proliferation of different MVC frameworks, ORM systems, CSS frameworks et cetera. And these are just the published examples: there are many many more in private use, because the authors were special and had special needs.
- Pitching. Best practice states that you should rehearse, keep your presentation short and focused, you should do market research and you should not rely on “chinese math”. Yet we have tons of pitches which are not rehearsed, overly long, unfocused, unresearched and based on lazy assumptions – because people expect to succeed because they are special.
- You can probably think of ten more examples pretty quickly.
Why oh why do we have to be in this situation? Can’t other people figure out that we don’t care about their overly long CV, their self-authored web framework and boring, unrealistics pitches?
The “I’m special” excuse
I hate the excuse that someone is special, and therefore does not need to follow good advice. And yet I find myself compelled to, for instance, write my own web framework. (Update: I didn’t do it! I went with Kohana instead.)
As always the problem is other people. And the worst thing is that to other people, you are another person!
I will stick with the web frameworks example, because it is so common and easy to recognize as a problem.
Writing your own web framework – are you really that special?
Why on earth would anyone want to reinvent the wheel by writing yet another web framework? The justifications I think come down to one of:
- Speed. The existing web frameworks are slow, because whomever wrote them was either incompetent or because they included the kitchen sink with their framework.
- Ease of coding. The existing web frameworks are horribly documented, and you prefer to reinventing the wheel to reading API documentation.
- Unique problems or novel ideas. You have a really unique problem or a really innovative new idea, and the existing frameworks do not support it.
- Learning experience.
And here are the reasons why you shouldn’t be doing it:
Assume for a moment that all other developers are not incompetent (I know, it’s a huge jump for someone as special as you!). This implies that the reason frameworks are slower is that they have more features, which inevitably increases execution time. Thus you can quite safely assume that by the time you reach the same level of functionality as any top-tier web framework, you will be equally slow or slower.
The only way you will reach that point and know for sure is through grueling reinvention of the wheel.If you want certainty about performance, pick a reasonably fast existing framework and go make it slower by adding your own functionality. As Don Knuth said: “We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.”
How many times have your customers called you and complained about performance? I’m not saying that performance does not matter – it clearly does – but this isn’t likely to be the most significant business, or even technical problem you encounter.
Ease of coding
The lack of documentation is in my humble opinion a valid criticism of existing frameworks. While some documentation and tutorials exist for existing frameworks, the state of documentation in PHP web frameworks is rather bad.
However, how well documented is your own framework? You will be familiar with it when coding it, but what about five years from now? What about the other people you will want to add if your project succeeds?
Unique problems or novel ideas
How unique are your problems? Most of what web applications is a variation of a theme rather than a wholly novel problem. In fact, I have a hard time thinking of a counterexample. It is true that some frameworks make working with complex backend logic harder – but this is more a matter of picking the right framework; having the perfect framework won’t still make the backend logic any more simple.
Is your novel idea actually useful? Imagine that you had built that crazy new framework with that neat idea – how much time would it save you in practice?
I’m pretty convinced that this reason is in fact just an excuse for not liking the aesthetic feel of whatever frameworks were evaluated, rather than a real reason. The core reason is that whatever you are doing is complex, and having your own framework will only provide a slight relief at a huge maintenance cost.
I think this is a legitimate reason. There is no substitute for learning by doing – but if you deploy that code into production, you are no longer learning: you have gone into the business of framework maintenance.