Friday, December 07, 2012

SQLite and the Sistine Chapel?

Out of curiosity and boredom, I decided to read the source code for SQLite. The main part of it - vdbe.c - is 111 pages long. That's 6,207 lines of code (including the blank ones. Those are easy to read... And the comments.) The header is 5 pages long.

The clue to vdbe.c is this comment:
What follows is a massive switch statement where each case implements a separate instruction in the virtual machine.
That switch statement is read by a script that produces two other files, opcodes.h & .c. The main file, .h, is a list containing 150 #defines. So, yeah, I guess it really is a massive switch statement!

All I can say is: Wow!

No wonder I couldn't find any rewrites*! It would be like repainting the Sistine Chapel. With a toothbrush.

*I was curious. So I poked around and found lots of wrappers, but no rewrites. Considering the amount of time that has gone into the original, and the licensing (open source, public domain) - you'd need a pretty strong business case to rewrite it. Mind you, it's very fast and capable and simply works. Why mess with success like that?

Carolyn Ann

No comments:

Post a Comment

Anonymous comments are disallowed for the time being.

Comments and conversation are encouraged. :-)

Miserable attempts at insult, self-pity and whiny sniveling isn't. There are other blogs that specialize in, and relish, that sort of pedantry.