Tombstone
Cauldron v2 · zmlc
Nov 2005 – Sep 2006 · age 23–24
What it was
The schema compiler that made the 2006 Cauldron's data model possible. It read a file that looked like a C++ header, with classes, fields, pointer and array bounds, and a single foreign word, note, for documentation. ANTLR parsed it, the syntax tree was printed as Lisp text and re-read by a small hand-written reader, and about two thousand lines of C# emitted everything that touched those classes: C++ headers and sources, a flat-binary serializer that stored pointers as offsets, an XML serializer, a class registry and loader, a C API for the editors, and a C# mirror carrying property-grid metadata. Growing the engine's model from 45 classes to 74 was one schema edit and a rerun. It worked and stayed in use through November 2006, until its successor took over.
Wins, for the age
- At twenty-three, Jeff generated zero-copy loading for every class, a vtable borrowed from a static prototype and offsets turned back into pointers, eight years before Cap'n Proto made the idea famous in 2013.
- Made the schema look like the code it replaced, so there was nothing new to learn, finding on their own what Qt's moc had already found.
- Emitted five outputs from one model, finding on their own what the CORBA IDL generators had already found, so engine, file format and editor could not drift.
- Printed the syntax tree as text and read it back, which made a one-primate compiler trivially debuggable. The habit lasted through every compiler after it.
What it taught
- Code generation can sit at the center of an engine. The successor was built that way on purpose.
- A printable intermediate form beats generated visitors when one person owns the compiler.
- Adopt the template engine. The slot for templates stayed empty while two thousand lines of
WriteLinedid the work. - Paired serializers give round-trip tests for free.
Genealogy
Ancestors: ZMLC: the same header-shaped schema compiler, in its first standalone form. Descendants: Kitchen ZMLC2: reflection APIs, a third target, and use until the end. Part of: Cauldron v2.
Epitaph
Here lies zmlc. A header-shaped schema went in, and seventy-four classes, their serializers, a C API and an editor's tooltips came out, from two thousand lines of
WriteLineand templates never written.