CO: An Efficient and User-Friendly C++ Foundation Library
In the field of C++ development, CO (coost) is a highly regarded cross-platform foundation library. It focuses on performance and ease of use, aiming to make C++ programming simpler, easier, and more efficient. The CO library is feature-rich, covering multiple aspects from command line parsing to network programming, making it an indispensable tool in modern C++ development.
A Streamlined Yet Powerful Library
The CO library was initially referred to as the “small Boost library”; compared to Boost, it is more streamlined, with the compiled static library being only about 1MB in size on Linux and Mac. However, it includes numerous powerful features such as command line and configuration file parsing, a high-performance logging library, a unit testing framework, a benchmarking framework, Go-style coroutines, a coroutine-based network programming framework, and a JSON-based RPC framework.
Core Features Introduction

Command Line and Configuration File Parsing (flag): The flag library of CO is powerful, supporting parameter input from both command line and configuration files, and it can automatically generate configuration files with support for aliases. Integer type flag values can have units (such as k, m, g, etc.), making parameter settings more flexible.
High-Performance Logging Library (log): The logging component of CO supports two types of logs: level log and topic log. Level logs are divided into five levels: debug, info, warning, error, and fatal, while topic logs can write logs to different files based on different topics. Additionally, the log provides a series of CHECK macros, similar to an enhanced version of assert, which can help developers quickly locate issues in debug mode.
Coroutines (coroutine): CO implements a coroutine mechanism similar to goroutines in Go. It supports multi-threaded scheduling, with the default number of threads being equal to the number of CPU cores in the system. Coroutines share a stack, have low memory usage, and can be created anywhere. It also supports coroutine synchronization events, coroutine locks, channels, and waitgroups as synchronization mechanisms.
Network Programming: CO provides a coroutine-based network programming framework that supports the development of static web servers, HTTP servers, and HTTP clients. For example, developers can easily create a simple HTTP server or send requests and handle responses through an HTTP client.
Efficient Development Experience
The efficiency of the CO library is reflected not only in its features but also in its development experience. It adopts a fluent interface design, making the code more concise and readable. For instance, CO’s JSON library supports a fluent interface, allowing developers to build and manipulate JSON objects through chained calls.
Moreover, the CO library also performs excellently in terms of performance. Its logging library’s write speed is nearly two orders of magnitude faster than glog, while the JSON library outperforms rapidjson in stringify and parse operations.
Cross-Platform Support and Build
The CO library supports multiple platforms including Linux, Mac, and Windows, with compiler requirements supporting C++11. It recommends using xmake as the build tool, while also supporting cmake, vcpkg, and conan for building and package management. This allows developers to choose the appropriate build method based on their needs and environment.
Conclusion
CO (coost) is a powerful, high-performance, and easy-to-use C++ foundation library. It provides C++ developers with a wealth of tools and components to help them build and deploy applications more efficiently. Whether for small projects or large systems, CO can provide strong support, making C++ development easier and more enjoyable.