Home > Uncategorized > The Design of Fossil

The Design of Fossil

January 7th, 2010

Partly in response to my post about building something Fossil-like on a NoSQL data store, Richard Hipp has written a brief discussion of Fossil’s design that tackles two questions:

  1. Why is Fossil based on SQLite instead of a distributed NoSQL database?
  2. Why is Fossil written in C instead of a modern high-level language?

His answer to the first is that Fossil is a NoSQL database—its use of SQLite to store metadata and other stuff is an implementation detail. His answer to the second is, “Fossil does use a modern high-level language for its implementation, namely SQL.” He goes on to say:

Much of the “heavy lifting” within the Fossil implementation is carried out using SQL statements. It is true that these SQL statements are glued together with C code, but it turns out that C works surprisingly well in that role. Several early prototypes of Fossil were written in a scripting language (TCL). We normally find that TCL programs are shorter than the equivalent C code by a factor of 10 or more. But in the case of Fossil, the use of TCL was actually making the code longer and more difficult to understand. And so in the final design, we switched from TCL to C in order to make the code easier to implement and debug.

I’m sceptical: I earned my living as a C/C++ programmer for almost 15 years, but believe these days that other languages give better bang for the buck in almost all cases. On the other hand, Richard has shipped much more high-quality software than I have. I wish I had time to dig into this deeper… *sigh*

Uncategorized

  1. Robert
    January 7th, 2010 at 17:49 | #1

    I would go with Richard. He is no slouch when it comes to Tcl or C. I am sure he tested both quite a bit before coming to his conclusions.

  2. sage
    January 10th, 2010 at 05:08 | #2

    Well… I earned my living as a C/C++ programmer for only 10 years. I use C for more than 15 years. But clearly, the C/C++ I see in professionnal daily life can’t be compared to C/C++ in some well designed open source codes.

    I didn’t looked at fossil implementation, but I read SQLite early implementation (SQLite 2, before it was picked up by PHP to be included in stadard PHP 5 distribution, thus becoming “Hipe”). And despite the heavy use of 3 letters variable names, the code was exceptionnally small AND readable. I felt some zen reading that code. As SQLite and fossil has been written by almost the same guy, I don’t think it’s strange to see fossil as well done piece of C.

    Anyway, IF fossil is mainly SQLite + SQL + small fossil “framework” + some glue in C, no doubt that the “glue” part is simple : it’s just a sequence of function call. There isn’t that much difference between a sequence of 15 C function calls, a sequence of 15 python function calls or a sequence of 15 TCL calls.

    So you’re sceptical about the glue part. In fact I think that getting to the point where you only need to do glue may have been longer with C than, for example with python.

Comments are closed.