Coffee Space


Single File Headers

Preview Image

Preview Image

I really quite like the idea of small single-file header libraries. I have been a big fan of [@nothings](' single_file_libs for C/C++. The rules are:

This is a discussion about my adventure into this space.

My Rules

These rules are inspired, but not exactly the same as the ones defined by @nothings - I have different requirements after all. My rules are:

Ideally these libraries follow the ethos of the Unix philosophy where possible:

  • Write programs that do one thing and do it well.
  • Write programs to work together.
  • Write programs to handle text streams, because that is a universal interface.


A while back I wrote json.hh and as part of an effort to role a small, strings only JSON parser that supports both Java and C++.

This needs to be rewritten. It is in C++, is far too long, is literally broken and relies on objects.

Things I liked were:

A few things I would change are:


After initially planning a server concept, I eventually wrote the code to uServer, a very small single-threaded server. I am quite happy with the implementation and it supports even more features since I last wrote about it, with MIME support and content caching in RAM (for files only).

For now it is highly usable and ready for real-time testing. I will think of a small but useful project soon to put it through its paces.

Future Projects

These are the following planned projects that are within the defined rules: