Back to browse
First IDL for Object-Graph Serialization (Apache Fory IDL)

First IDL for Object-Graph Serialization (Apache Fory IDL)

by chaokunyang·Mar 11, 2026·1 point·2 comments

AI Analysis

●●SolidBig BrainNiche Gem

Treats object cycles and shared refs as schema contracts instead of manual ID stitching.

Strengths
  • `ref` modifier preserves shared identity and cycles directly in the schema contract.
  • Generates idiomatic structs and classes instead of buffer-access wrappers like FlatBuffers.
  • Single `.fdl` definition compiles to seven languages with compatible wire formats.
Weaknesses
  • Serialization is a crowded category dominated by Protobuf and FlatBuffers ecosystem inertia.
  • Object graphs in RPC are often an anti-pattern, limiting the addressable audience.
Target Audience

Backend engineers building polyglot services with complex domain models

Similar To

Protocol Buffers · FlatBuffers · Apache Thrift

Post Description

Apache Fory Schema IDL is the first cross-language schema that treats object graphs (shared refs, cycles, polymorphism) as a first-class contract and still generates idiomatic domain models.

1. `ref` encodes shared identity/loops in the schema (weak refs supported) — no manual ID stitching

2. `union`/`any` give reusable polymorphism; same semantics across Java/Python/Go/Rust/C++/C#/Swift

3. Generated types are real domain models (POJOs, dataclasses, structs, enums), not transport wrappers

4. Compatible evolution: field-id matching, defaults, unknown-field skip

5. One `.fdl` → compatible bytes across all supported languages

Try it in 60 seconds:

```bash pip install fory-compiler foryc ecommerce.fdl \

--java_out=./java --python_out=./python --go_out=./go \

--rust_out=./rust --cpp_out=./cpp --csharp_out=./csharp --swift_out=./swift

```

Shared-identity round-trip (Java):

```java

OrderBatch restored = OrderBatch.fromBytes(new OrderBatch(first, second).toBytes());

assert restored.getOrders().get(0).getCustomer() == restored.getOrders().get(1).getCustomer();

```

Feedback welcome: where do object graphs bite you today? Try `foryc --emit-fdl` on a `.proto` / `.fbs` and tell me what feels off.

Similar Projects

Open Source●●Solid

Fory C++ Serialization – Polymorphism, Circular Refs, 12x vs. Protobuf

Fory pushes most serialization work into compile-time C++ via a FORY_STRUCT macro so deserialization is inlined and avoids runtime reflection — that alone is an impressive engineering move. Add first-class polymorphism over smart pointers, shared/circular reference tracking, and a single binary wire format across six languages, and you get a rare combo: expressive native C++ types plus cross-language compatibility. The main question is ecosystem adoption and whether the language runtimes and benchmarks hold up in messy real-world schemas.

WizardryNiche Gem
chaokunyang
313mo ago