I really quite like the idea of small single-file header libraries. I have been a big fan of [@nothings](https://github.com/nothings)’ single_file_libs for C/C++. The rules are:
- Libraries must be usable from C or C++, ideally both
- Libraries should be usable from more than one platform (ideally, all major desktops and/or all major mobile)
- Libraries should compile and work on both 32-bit and 64-bit platforms
- Libraries should use at most two files (one header, one source)
This is a discussion about my adventure into this space.
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 JSON.java
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:
{}
and arrays []
.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.
These are the following planned projects that are within the defined rules: