Chris Zetter

Booknotes: Web-first and making PDFs

Booknotes 5.

I’m writing a guide to building your own database server. Here’s what I’ve been doing:

Progress

This week I’ve continued with my sample implementation so it can handle filtering, sorting, limiting and joins. I’ve also written a chapter about references.

Building web-first

I’m mildly frustrated when technical books are only available in a fixed-size PDF or in a non-so-nicely formatted ebook. My plan for the book is to first publish it as a website. The web is great at looking good at different screen sizes and is very easy to make updates to. To do this, I’m writing the each chapter as a tab in a Google Doc and have a process that exports the document as markdown and then renders it as HTML with Kramdown.

Making a PDF

Although I am building for the web, I did want to make sure I could turn the book into a PDF that looks good in case there was any need for an offline version. I first tried printing the page as a PDF from Chrome. I knew Chrome Dev tools had a way to change the CSS media type to print but it took me a while to find it. It seems like the Chrome engineers do love moving the setting around every few releases. The wording of the menu and setting has even changed since the Stack Overflow answer.

I fixed some visual issues in a new print stylesheet. I made use of break-inside for the first time to keep certain elements together on the same page. I used the Chrome print dialog to save a PDF, I’ll likely automate it if I need to do it again.

Consistent chapters

One thing I’m doing at the moment is making sure the chapters are all of a similar size and can be implemented in a similar amount of code. I’ve moved a few things from the main implementation into optional ‘extensions’ section that each chapter has to help balance things out.

One example is inserting items into explicit columns (e.g INSERT INTO t1 (b, a) VALUES (2, 1); instead of INSERT INTO t1 VALUES (1, 2);). This feature added a bit of complexity early on to the implementation and no later features relied on it- I think it’s much more rewarding to have features you can use and build upon in later chapters.

~~~

I'm writing a step-by-step guide to build your own database server. Find out more and get updates.

You can read more by me, follow me on Mastodon or subscribe.