reflect-cpp¶
📖 Documentation: https://rfl.getml.com — 👨‍💻 Source Code: https://github.com/getml/reflect-cpp
📣 From the Author (01.11.2024): Hi everyone, Patrick (liuzicheng1987) here. With reflect-cpp reaching the 1k-star milestone, we’re excited to roll out an overhauled documentation site at https://rfl.getml.com, giving it a permanent place in our company. Initially developed as an internal tool for our machine learning library, getML, reflect-cpp has grown into something much larger.
A big thank you to all contributors for helping us reach this point! Your feedback, ideas, and dedication have been invaluable.
As we look to the project’s future, I would like to hear your thoughts on potential new directions, discuss ideas to expand our user base, or learn more about what you’re building with it. For the next month, I am opening a few slots in my calendar for anyone who wants to connect (link).
— Best, Patrick
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 support@getml.com 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.