CRUD Ain’t Hard

And now for a little exercise in armchair software architecture — the most despicable coder’s pastime. Dear non-coding readers: despite its name, this blog is still mostly not about programming. Just skip this post or something. Dear coders, many of you will probably disagree with me. I am not a very good or accomplished coder myself, and you probably should not be taking your advice from me. But then again, I could be right, so keep your mind open.

You might have been aware of the very popular, but uptime-challenged social networking tool called Twitter. They have one of the best problems to have: too many very active users. The site is so popular that it constantly goes down and displays and “over capacity” screen that the users have nicknamed The Fail Whale.

Rapidly writing and displaying short chunks of text with high concurrency on the web is not one of them unsolvable problems in programming. It’s not easy, but with right people and tools Twitter could be rewritten inside a month. Twitter founders should do some soul searching. Meanwhile the critical mass has already been reached, the niche for bloggers who want to SMS instead of blogging is big, and even horrible uptime can’t this service. I use it myself.

There is a lot of speculation in the blogocube about whether the reason behind the Fail Whale is the wrong choice of technology — the highly hyped and sexy Ruby on Rails and if it can “scale”. Or is it just simple incompetence?

To me Ruby on Rails falls into a class of technologies that are affected by what I call “the VRML syndrome.” Basically, if I wait long enough the hype will go away, the recruiters will stop posting job listings requiring 4 years of experience in a 4 month old technology, books as fat as my two fists will stop being published, and I will not have to learn it.

What’s the problem with Ruby on Rails? Well, it’s the same problem that slightly affects the content management system that I am currently working with (Drupal), and is the reason why I completely gave up using Microsoft web technologies which are saturated with this shit. See, software craptitechts all of a sudden decided that writing CRUD applications is too difficult for regular developers, and complicated GUI tools and frameworks need to be created to help the poor things. CRUD stands for “Create, Read, Update, Delete” and is just a funny way to say “a browser-based application chock-full’o forms”.

The default way to build these is to rather simple. You hand-code the html forms, then you write functions or classes to deal with the form input — validators and SQL queries for creating, updating and deleting. Then you write some code that will query the database and display the saved data in various ways: as pages, xml feeds, etc. None of this is difficult or non-trivial. Bad coders don’t do a good job of validation and input sanitizing resulting in the Little Bobby Tables-type situation, but these things are not very hard to learn and there are great libraries for this.

Ruby on Rails makes it very easy to create CRUD apps without hand-coding forms or writing SQL. RoR goes to great lengths to abstract out SQL, not trusting the developers to do it right. SQL is more functional than procedural, and thus a difficult thing for many programmers to grasp, but it’s not that hard. Really. SQL is located far enough levels from the machine that abstracting it out becomes a horrible thing due to the Law of Leaky Abstractions. Even when you have full control of SQL queries optimizing them is sometimes hard. When they are hidden by another layer it becomes next to impossible.

In short, RoR makes something that is easy (building CRUD apps) trivial, and something that’s hard – optimizing the database layer next to impossible.

In Drupal there are two modules, CCK and Views that allow you to create CRUD entirely through web interfaces. This is a feature that exist in just about every major CMS, it’s just that in Drupal it’s a little buggier and overcomplicated than necessary. These are fine for small websites and are really useful to amateurs. The problem arises when these are used for high traffic websites.

I think that a lot of people will agree with me that writing HTML and SQL queries using GUI tools is amateur hour. You just can’t make a good website with Microsoft Front Page. You can’t, you can’t, you can’t. But in Drupalland it’s all of a sudden fine to use Views to build queries for high traffic sites. Well, it’s not. Dealing with Views and Views Fast Search has been an ongoing nightmare for me. Hell is not even other people’s code in this case. It’s other people’s Views.

RoR, Views, CCK are one level of abstraction higher than you want to be when building a high performance application. The only way the can be an “Enterprise” tool if your enterprise is a) run by a morons that require 100 changes a day AND b) has very few users. In short, if it’s an app for the HR department of a company with 12 employees – knock yourself out. If you are building a public website for millions of people – forget about it.

Your, Deadprogrammer.

P.S. Yes, I know, you can abstract just about everything and reduce your software application to a single button labled “GENERATE MONEY”. You have to be a very smart LISP developer for that.

Where’s My Flying Car Part I : KABOOM!

“Celebrating Gertsen, we clearly see three generations,
three classes acting in the Russian Revolution. First –
noblemen and landowners, Decembrists and Herzen.
Horribly distant from the people. But their work was not in wain.
Decembrists woke Herzen. Herzen began revolutionary agitation.”
V.I. Lenin

Computers have existed like for 200,000 years in Internet time, yet the innovation in computer technology seems to be a little slow. Brick and mortar slow. Let me present to you an approximate timeline:

In 1945 Dr. Vannevar Bush wrote an article As We May Think about a device called the Memex.

In 1960 Theodor Holm Nelson, inspired by Bush, coined the term “hypertext” and started on Project Xanadu, a vaporware Superinternet.

In 1968 Dr. Douglas Engelbart delivered the MOAD, demonstrating videoconferencing, email, hypertext, copy and paste, as well as some novel input devices including a mouse.

Bush, Nelson and Engelbart show a progression from a dream into reality. Bush was a pure dreamer – he never intended to actually try and build the Memex. Nelson at least tried to build Xanadu, although he failed miserably. He could not even get to the demo stage. Engelbart actually built enough stuff to make very impressive demos, although never to build actual successful products except the mouse. These guys suffered from the RAND Corporation syndrome–the common joke went that RAND stood for Reasearch And No Development.

The problem with these three was that they could not focus on individual problems. Luckily for us, next came Xerox PARC. Xerox corporation had money coming out of its wazoo, decided to invest in a world class R&D center. They used the same approach that Google is using today: spend the extra money on hiring the brightest technologists around and let them run free and wild.

Bush, Nelson and Engelbart were a lot like a character named Manilov in Gogol’s Dead Souls. Manilov was an owner of a large rundown estate. He spent his days dreaming about improving it. Wouldn’t it be nice to build a bridge over the river and on it build little merchant booths so that the peasants could buy stuff there. Of course, none of his projects ever went anywhere, and if they did, they were quickly abandoned.

PARC engineers were men of action. Each concentrated on a particular aspect, and they’ve built working models of many things that we enjoy today: personal computer with GUI interfaces, Ethernet, WYSIWYG text editor, laser printer, and even a computer animation system amongst other things. Sadly, Xerox was able to capitalize mostly on the laser printer, which actually probably paid for all of PARC’s expenses. PARC indirectly influenced Apple and Microsoft in the development of GUI OS. Also Charles Simonyi left PARC to develop Word and Excel for Microsoft, thus creating an enormous amount of wealth. Bob Metcalfe and David Boggs also left PARC, took Ethernet and turned it into 3COM. John Warnock and Charles Geschke left PARC, took PostScript and created a little company called Adobe Systems. Well, you get the picture.

To give you another analogy, the technological revolution of the 60s, 70s and 80s was like a hydrogen bomb. A hydrogen bomb is made of three bombs: a conventional explosive that ignites a fission explosive that in turn ignites a fusion explosion. Semiconductor industry created by William Shockley and the Traitorous Eight was the fuel, Bush and Company–the conventional explosion, PARC–fission, what came after–fusion. KABOOM!