The Boost libraries

I’ve been hacking on a personal project to make it easier to expose HTTP based devices that are behind a restrictive NAT or firewall. The code needs to run on a OpenWrt based MIPS board 1 which limits my language choice – Python3 is out as it’s too big, and Go on MIPS32 via gccgo on OpenWrt is… tricky 2.

I ended up writing the app in C++ and I’ve been quite impressed with C++14 and the Boost libraries. Especially:

  • boost::optional for covering the optional results without having to use tricks like err == -1 or result == nullptr.
    • boost::algorithm::string for string splitting and trimming.
      • boost::asio for all of your event or blocking based network programming needs.
        • boost::program_options for command line option parsing and validation.
          • boost::asio::coroutine for a very readable implementation of Duff device based coroutines.
            • std::unique_ptr / std::shared_ptr for sane memory management.

            Generous use of auto, lambdas, and using keep the code reasonably terse as well.

            1 I also have two of the $12.90 LinkIt Smart 7688 boards on their way. A good price for a 580 MHz Linux CPU on a DIP carrier with Wifi, RAM, and 32 MiB of flash.

            2 gccgo enables libffi, which assumes floating point registers, but the OpenWrt kernel turns off FP emulation by default and enforces it through binutils flags.

Avatar
Michael Hope
Software Engineer