Skip to main content
Version: 0.14

Cross-Language Serialization Guide

Apache Fory™ xlang (cross-language) serialization enables seamless data exchange between different programming languages. Serialize data in one language and deserialize it in another—without IDL definitions, schema compilation, or manual data conversion.

Features

  • No IDL Required: Serialize any object automatically without Protocol Buffers, Thrift, or other IDL definitions
  • Multi-Language Support: Java, Python, C++, Go, Rust, JavaScript all interoperate seamlessly
  • Reference Support: Shared and circular references work across language boundaries
  • Schema Evolution: Forward/backward compatibility when class definitions change
  • Zero-Copy: Out-of-band serialization for large binary data
  • High Performance: JIT compilation and optimized binary protocol

Supported Languages

LanguageStatusPackage
Javaorg.apache.fory:fory-core
Pythonpyfory
C++Bazel/CMake build
Gogithub.com/apache/fory/go/fory
Rustfory crate
JavaScript@apache-fory/fory

When to Use Xlang Mode

Use xlang mode when:

  • Building multi-language microservices
  • Creating polyglot data pipelines
  • Sharing data between frontend (JavaScript) and backend (Java/Python/Go)

Use language-native mode when:

  • All serialization/deserialization happens in the same language
  • Maximum performance is required (native mode is faster)
  • You need language-specific features (Python pickle compatibility, Java serialization hooks)

Quick Example

Java (Producer)

import org.apache.fory.*;
import org.apache.fory.config.*;

public class Person {
public String name;
public int age;
}

Fory fory = Fory.builder()
.withLanguage(Language.XLANG)
.build();
fory.register(Person.class, "example.Person");

Person person = new Person();
person.name = "Alice";
person.age = 30;
byte[] bytes = fory.serialize(person);
// Send bytes to Python, Go, Rust, etc.

Python (Consumer)

import pyfory
from dataclasses import dataclass

@dataclass
class Person:
name: str
age: pyfory.Int32Type

fory = pyfory.Fory()
fory.register_type(Person, typename="example.Person")

# Receive bytes from Java
person = fory.deserialize(bytes_from_java)
print(f"{person.name}, {person.age}") # Alice, 30

Documentation

TopicDescription
Getting StartedInstallation and basic setup for all languages
Type MappingCross-language type mapping reference
SerializationBuilt-in types, custom types, reference handling
Zero-CopyOut-of-band serialization for large data
Row FormatCache-friendly binary format with random access
TroubleshootingCommon issues and solutions

Language-Specific Guides

For language-specific details and API reference:

Specifications