I learned lots of things this week, but the most important thing I learned is that coding by dogma is a widely followed practice. Who knew? I didn't. And it really took me by surprise.



It all started with my post, "Who Needs a Database?" which despite its provocative title was not anti database in nature. Rather, it was a post about shirking convention and building something that works by using simple techniques and simple code. The end result was a two page website that works exactly the way it was designed to. The sticking point for many people was that it didn't use a database but used a few flat files instead.



There were a few things about the reactions that took me by surprise. The first was that many readers left comments insinuating that my post was "anti database". The second was that the subject of not using a database utterly, completely and totally (I know, those adjectives are redundant - I'm trying to make a point here) polarized people. People either thought it was the most stupid thing in the world or they thought it was great.



In fact, some of the backlash was so vehement that JimboJones took it upon himself to post a link to the article on http://www.thedailywtf.com/. Link is here. For those of you who haven't been to thedailywtf, it's like the kiss of death. To see a reference to your code on thedailywtf is one of the most shameful things that can happen to a developer.



A curious thing happened when I saw the link to my code on thedailywtf and the laugh fest that followed. I entered a state of deep calm when I saw that there are developers who code by dogma. I understood then, what made people so angry.



Coding By Dogma



Even though I had clearly written that databases are standard pieces of any architecture for good reasons, nobody seemed to care. They couldn't see past the fact that I WASN'T USING A DATABASE!



Even though I clearly explained that based on the requirements for my site (requirements that I came up with, for a site that was all mine, not a client), there was no need for a database and I could accomplish exactly what I set out to do with just a few flat files, they still shouted "BUT YOU AREN'T USING A DATABASE!".



Even after I wrote in a follow up post explaining that people were missing the point which was essentially, if the site does exactly what it's designed to do, if the site is lean, simple and took me just a few hours to put together then what's the problem with using a few flat files? But they still shouted, "THE PROBLEM IS THAT YOU DIDN'T USE A DATABASE AND BECAUSE YOU DIDN'T YOU MADE SOMETHING TERRIBLE!"



Ok, so nobody actually shouted at me, but it sure felt like it.



So, why did my responses make those guys so angry, even angrier?



I think it's because many of us code by dogma. When presented with a problem (say, building a simple site exactly like mine) we automatically say: "ok, first, we know we're going to need a database, so let's do that".



In the vast majority of the cases we'd be right. What I tried to do was challenge that convention. I didn't do it senselessly however, I did it in the context where not using a database was a fine choice. But context doesn't matter to us when we code by dogma. We can't see past not using a database. There is no situation that might warrant using a flat file over a database. That's coding by dogma.



This discussion is by no means new. I'd like to wrap up here with a few examples.



Example 1:



radar.oreilly.com









Gabe (of memeorandum.com) wrote: "I didn't bother with databases because I didn't need the added complexity... I maintain the full text and metadata for thousands of articles and blog posts in core. Tech.memeorandum occupies about 600M of core. Not huge." Mark (of bloglines.com) wrote: "The 1.4 billion blog posts we've archived since we went on-line are stored in a data storage system that we wrote ourselves. This system is based on flat files that are replicated across multiple machines, somewhat like the system outlined in the Google File System paper."



In most deployed servers today, the lowest common denominators are VBScript (on Windows), PHP4, and PHP5 (on Unix). If we try to require anything fancier on the server, we increase our tech support costs dramatically. Even though PHP is available for Windows, it's not preinstalled, and I don't want to pay engineers to help all of our Windows customers install PHP. We could use .NET, but then I'd have to pay engineers to install Mono for all our Unix customers, and the .NET runtime isn't quite ubiquitous on Windows servers. Since we don't want to program in VBScript or PHP4 or even PHP5 and we certainly don't want to have to port everything to three target platforms, the best solution for us is a custom language that compiles to our target platforms.

WROTE HIS OWN LANGUAGE

My goodness, these are fairly well known companies. I mean, Google uses databases AND flatfiles...Make sure you read some of the comments. You'll hear a lot of the same rhetoric there that you'll see in the comments left here and on thedailywtf.comExample 2Joel Spolsky got massive backlash when he wrote about Wasabi , the custom language his company developed. When I first heard about it I thought it was the most stupid thing in the world. The more I thought about it though, the more I realized why he did what he did.Joel says:When we don't pay attention to the context - to the real problem we're trying to solve we fail to see that what Joel did was smart. Hard, but smart.What made some people angry was that Joel! To most people, that's just a programming excercise, something you'd do in college, not something you'd ever want to do in "real life".Well, that's just code dogma.Thanks for reading!