reflect-cpp¶
💻 Source Code: https://github.com/getml/reflect-cpp
reflect-cpp is a C++-20 library for fast serialization, deserialization and validation using reflection, similar to pydantic in Python, serde in Rust, encoding in Go or aeson in Haskell.
reflect-cpp fills an important gap in C++ development. It minimizes boilerplate code and enhances code safety for seamless and efficient data exchange across system components.
Design principles for reflect-cpp include:
- Close integration with containers from the C++ standard library
- Close adherence to C++ idioms
- Out-of-the-box support for JSON
- Simple installation
- Simple extendability to other serialization formats
- Simple extendability to custom classes
- Being one of the fastest serialization libraries in existence, as demonstrated by our benchmarks
Why do we need this?¶
Suppose your C++ program has complex data structures it needs to save and load. Or maybe it needs to interact with some kind of external API. If you do this the traditional way, you will have a lot of boilerplate code. This is annoying and error-prone.
Example
If you are new to reflect-cpp, please refer to our GitHub repository for the latest list of supported serialization formats. You will also find a simple and more comprehensive code example.
reflect-cpp is not just a reflection library, it is for serialization, deserialization and validation through reflection.
That means that you can encode your requirements about the input data in the type system and have them validated upfront. This is why the library also includes algebraic data types like tagged unions and numerous validation routines. Having your requirements encoded in the type system is the most reliable way of ensuring they are met. If your requirements are not met, the user of your software gets a very clear error message. Encoding your requirements in the type system also makes it a lot easier for anyone reading your code.
This increases user experience and developer experience, it makes your code safer (fewer bugs) and more secure (less prone to malicious attacks).
For a more in-depth theoretical discussions of these topics, the following books are warmly recommended:
- Category Theory for Programmers by Bartosz Milewski on GitHub
- Domain Modeling Made Functional by Scott Wlaschin
The team behind reflect-cpp¶
reflect-cpp has been developed by getML (Code17 GmbH), a company specializing in software engineering and machine learning for enterprise applications. reflect-cpp is currently maintained by Patrick Urbanke and Manuel Bellersen, with major contributions coming from the community.
Related projects¶
reflect-cpp was originally developed for getml-community, the fastest open-source tool for feature engineering on relational data and time series. If you are interested in Data Science and/or Machine Learning, please check it out.
Professional C++ support¶
For comprehensive C++ support beyond the scope of GitHub discussions, we’re here to help! Reach out at [email protected] to discuss any technical challenges or project requirements. We’re excited to support your work as independent software consultants.
License¶
reflect-cpp is released under the MIT License.