r/cpp • u/Shawn-Yang25 • Feb 18 '26
Apache Fory C++: Fast Serialization with Shared/Circular Reference Tracking, Polymorphism, Schema Evolutionn and up to 12x Faster Than Protobuf
We just released Apache Fory Serialization support for c++:
https://fory.apache.org/blog/fory_cpp_blazing_fast_serialization_framework
Highlights:
- Automatic idiomatic cross-language serializaton: no adapter layer, serialize in C++, deserialize in Python.
- Polymorphism via smart pointers: Fory detects
std::is_polymorphic<T>automatically. Serialize through ashared_ptr<Animal>, get a Dog back. - Circular/shared reference tracking: Shared objects are serialized once and encoded as back-references. Cycles don't overflow the stack.
- Schema evolution: Compatible mode matches fields by name/id, not position. Add fields on one side without coordinating deployments.
- IDL compiler (optional):
foryc ecommerce.fdl --cpp_out ./gengenerates idiomatic code for every language from one schema. Generated code can be used as domain objects directly - 6. Row format: O(1) random field access by index, useful for analytics workloads where you only read a few fields per record.
Throughput vs. Protobuf: up to 12x depending on workload.
GitHub: https://github.com/apache/fory
C++ docs: https://fory.apache.org/docs/guide/cpp
I’d really like critical feedback on API ergonomics, and production fit.
85
Upvotes
View all comments
Show parent comment
5
u/FlyingRhenquest Feb 18 '26
Yeah, reflection is just sorcery and it just works. Autocereal would probably have been even smaller, except that I was working around some reflection issues that have already been resolved. I'll probably have another go at it once the reflection code is a bit more stable. Autocereal would also have been a bit larger if I hadn't been leveraging a bunch of stuff that was already in cereal. But even rolling your own serialization library with reflection would not be terribly difficult.
Funnily, I think reflection will give us everything we need to implement "C++ on Rails" in a very real way. I'm waiting on some annotation issues but am planning to automate SQL table and record generation in much the same way. It'd be easy enough to do a library for Pistache or some other REST library. And for the UI on the browser part, you could probably automate the display of simple data elements in something like imgui and just compile the UI with emscripten. That adds up to true, effortless C++ full stack applications from not much more than just writing some structs to store data in.