Hacker News new | ask | show | jobs
Show HN: First IDL for Object-Graph Serialization (Apache Fory IDL) (fory.apache.org)
1 points by chaokunyang 93 days ago
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.

2 comments

Tiny Schema demo

message Customer { string id = 1; string name = 2; }

message Order {

  string order_id = 1;

  ref Customer customer = 2;

  list<string> items = 3;

}