r/cpp • • 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:

  1. Automatic idiomatic cross-language serializaton: no adapter layer, serialize in C++, deserialize in Python.
  2. Polymorphism via smart pointers: Fory detects std::is_polymorphic<T> automatically. Serialize through a shared_ptr<Animal>, get a Dog back.
  3. Circular/shared reference tracking: Shared objects are serialized once and encoded as back-references. Cycles don't overflow the stack.
  4. Schema evolution: Compatible mode matches fields by name/id, not position. Add fields on one side without coordinating deployments.
  5. IDL compiler (optional): foryc ecommerce.fdl --cpp_out ./gen generates idiomatic code for every language from one schema. Generated code can be used as domain objects directly
  6. 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.

89 Upvotes

27 comments sorted by

View all comments

Show parent comment

10

u/Shawn-Yang25 Feb 19 '26

Thanks for your detailed comments and suggestions, realy helpful.

C++ 26 reflection is great! When I design `FORY_STURCT` macro, I also take a look at c++ 26 reflection. It's elegant and exactly what I want to have. With c++ 26 reflection, I can remove `FORY_STURCT` macro totally. But it's not available yet and I want to support as many projects as fory can. So in the end I choose to use a macro+template based way. I also try some c++20 tuple unpack trictk, it can unpack struct fields into a tuple without the macro, and is used by some pure c++ serialization framework, but it can't control fields serialization order, which is very important for a cross language serialization framework. To sort fields at compile-time, I choose to use `FORY_STURCT` to define fields order and also expose fields member pointer.

When C++ 26 reflection is ready, I may try to introduce a conditional-compile branch so c++ 26 users don't have to write `FORY_STURCT` anymore