Warning
๐ง WIP โ Active AI Pipeline Construction & Architecture Optimization in Progress.
โก Universal, zero-bloat dual-format serialization and parsing engine for the FastJava ecosystem.
FastFileFormat standardizes data storage across FastJava. It bridges human-readable text specifications (.format, .kv, .theme, .config with @KEY variable aliasing and sections) with sub-microsecond binary streaming (.bin, .fbin, .themebin with 12-byte magic headers and zero-allocation primitive reads).
import fastfileformat.FastFileFormat;
import fastfileformat.TextFormatParser;
import fastfileformat.TextFormatWriter;
public class TextDemo {
public static void main(String[] args) {
// 1. Fluent Text Generation
String configText = FastFileFormat.textWriter("Engine Configuration")
.section("Graphics")
.set("resolution.width", 1920)
.set("resolution.height", 1080)
.set("vsync", true)
.blankLine()
.section("Palette")
.set("primary", "#00F0FF")
.set("accent", "#FF007F")
.alias("cursor", "Palette.accent") // Resolves dynamically to #FF007F
.toText();
// 2. High-Speed Text Parsing & Alias Resolution
TextFormatParser doc = FastFileFormat.parseText(configText);
int width = doc.getInt("Graphics.resolution.width", 1280);
boolean vsync = doc.getBoolean("Graphics.vsync", false);
String cursor = doc.getString("Palette.cursor", "#FFFFFF"); // "#FF007F"
}
}import fastfileformat.BinaryHeader;
import fastfileformat.BinaryReader;
import fastfileformat.BinaryWriter;
import fastfileformat.FastFileFormat;
public class BinaryDemo {
public static void main(String[] args) {
// 1. Zero-Allocation Binary Streaming
BinaryWriter writer = FastFileFormat.binaryWriter()
.writeHeader(FastFileFormat.DEFAULT_MAGIC, (short) 1, (short) 100, 0)
.writeString("FastJava Payload")
.writeIntArray(new int[]{10, 20, 30, 40})
.writeDouble(Math.PI);
byte[] payload = writer.toByteArray();
// 2. Direct Little-Endian Deserialization
BinaryReader reader = FastFileFormat.binaryReader(payload);
BinaryHeader header = reader.readHeader(); // 12-byte FastJava header
String name = reader.readString();
int[] numbers = reader.readIntArray();
double pi = reader.readDouble();
}
}- Why FastFileFormat?
- Key Features
- Real-World Use Cases
- Architecture Overview
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Traditional data formats in Java (JSON, YAML, XML, Java Serialization) are ill-suited for performance-critical engines:
- Massive Memory Bloat & GC Overhead: Jackson, Gson, and SnakeYAML create millions of intermediate objects, wrapper instances, and HashMaps during parsing, causing garbage collection spikes.
- Dangerous Legacy Serialization: Java's built-in
Serializableis notoriously slow, insecure, and tightly coupled to rigid classpath class definitions. - Complex External Tooling: High-speed alternatives like Protocol Buffers and FlatBuffers require external schema compilers (
protoc) and cumbersome build-step code generation.
FastFileFormat solves this by offering a lightweight, zero-dependency, dual-mode text and binary format standard:
| Feature | JSON / YAML (Jackson/Gson) | Protocol Buffers | FastFileFormat |
|---|---|---|---|
| Human Readability | โ Yes (Text) | โ Binary blob only | โ Clean Key-Value & Aliases |
| Parsing Latency | 50โ500 ยตs (Token parsing) | 5โ20 ยตs (Generated code) | < 1 ยตs (Direct binary stream) |
| GC Pressure | High object churn / HashMaps | Medium buffer allocation | 0 bytes on primitive reads |
| Tooling & Compilers | None | protoc / schema |
None (Pure Java 17+ / no setup) |
| Dual Format Bridge | Separate formats required | Binary only (Complex textproto) | Unified Text-to-Binary transcode |
| Dependencies | Heavy (~2โ5 MB JARs) | Protobuf runtime JAR | Zero dependencies (< 35 KB) |
- โก Dual-Format Standard โ Human-readable
.formattext and sub-microsecond.binbinary streaming. - ๐ Variable Alias Resolution โ Native
@KEYand@SECTION.KEYreferencing for dynamic configurations. - ๐ฆ 12-Byte Standard Binary Header โ 4-byte Magic, 2-byte Version, 2-byte Payload Type, 4-byte Length.
- ๐งฎ Zero-Allocation Primitive Streaming โ Little-Endian writers and readers for
int,float,double,long,String, arrays, and byte slices. - ๐ Zero Dependencies โ Self-contained pure Java 17+ core backed by
FastCore.
- ๐จ UI Theming & Dynamic Palettes: Powers
FastThemewith human-editable.themepalettes and instant pre-compiled.themebincaches. - ๐ง Agent State & Checkpoint Dumps: Serializes multi-agent blackboards in
FastAIStateinto high-density binary snapshots in under 12 microseconds. - โ๏ธ Hot-Reloadable Game Configurations: Human-readable game engine configs with dynamic
@aliascolor and resolution linking. - ๐ Zero-Copy IPC & Shared Memory Streaming: High-throughput binary streaming across local OS memory rings and inter-process sockets.
FastFileFormat acts as the canonical data serialization and interchange layer for FastJava:
- ๐ FastFileFormat (Dual Format): Standardized 12-byte header, text parser, and binary serializer.
- โก FastBinary (Binary Bit-Packing): Provides VarInt, BitSet, and bit-level packing primitives.
- ๐ง FastAIState (Shared Agent State): Uses FastFileFormat for high-speed blackboard snapshots.
- ๐จ FastTheme (Desktop Theming): Loads human-readable
.themespecs and serializes.themebin.
FastFileFormat is profiled using JMH to guarantee zero-overhead serialization:
| Benchmark Operation | Score (ops/ms) | Ops per Second | Memory Allocation |
|---|---|---|---|
| Binary Stream Deserialization | ~14,680 ops/ms | > 14.6 Million | 0 bytes / op (Zero GC) |
| Binary Stream Serialization | ~8,880 ops/ms | > 8.88 Million | Minimal buffer churn |
| Text Parsing with Alias Resolution | ~248 ops/ms | > 248,000 / sec | Linear memory footprint |
Measured on Windows 11 x64, Intel Core i5 (Surface Pro 8), JDK 21.0.12.1.
| Class / Method | Return Type | Description |
|---|---|---|
FastFileFormat.textWriter() |
TextFormatWriter |
Creates a fluent pretty-printer for human-readable text formats. |
FastFileFormat.parseText(text) |
TextFormatParser |
Deserializes formatted text and resolves all @KEY alias references. |
FastFileFormat.binaryWriter() |
BinaryWriter |
Creates a Little-Endian primitive stream writer. |
FastFileFormat.binaryReader(bytes) |
BinaryReader |
Creates a high-speed Little-Endian binary deserializer. |
FastFileFormat.isBinaryFile(path) |
boolean |
Checks if a file starts with a valid FastJava binary magic header. |
BinaryHeader.readFrom(buffer) |
BinaryHeader |
Decodes standard 12-byte FastJava binary header. |
parser.getInt(key, defaultVal) |
int |
Type-safe value accessors with default fallback values. |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Interactive Format Showcase | Demo.java | run-demo.bat |
Text format generation, alias resolution, and binary roundtrip demonstration. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
High-throughput throughput benchmarks for text and binary serialization. |
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastFileFormat</artifactId>
<version>0.1.1</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastFileFormat:0.1.1'
}Download the latest JARs directly to add them to your classpath:
- ๐ฆ FastFileFormat-0.1.1.jar (The Core Library)
- โ๏ธ fastcore-0.1.0.jar (FastJava runtime substrate)
- REFERENCE.md: Exhaustive catalog of API contracts, binary specs, and data structures.
- PHILOSOPHY.md: Zero-allocation and dual-format design principles.
- ROADMAP.md: Planned milestone features and performance extensions.
- CHANGELOG.md: Version history and release notes.
- COMPILE.md: Full compilation guide (Maven Build Setup).
| Platform | Architecture | Status | Notes |
|---|---|---|---|
| Windows 10/11 | x64, ARM64 | โ Fully Supported | Native high-performance pure Java |
| Linux | x64, ARM64 | โ Fully Supported | Tested on Ubuntu / Debian / RHEL |
| macOS | Apple Silicon, x64 | โ Fully Supported | Tested on macOS Sonoma / Sequoia |
MIT License โ See LICENSE for details.
- FastCore โ Native JNI Loader and Utilities
- FastBinary โ Bit-packing, VarInt encoding, and binary parsing engine
- FastTheme โ High-performance native window styling and dynamic themes
- FastAnimation โ Zero overhead timeline orchestration
- FastTween โ Zero overhead pool-based tweening
- FastDWM โ Native Desktop Window Manager API
- FastDisplay โ Native display telemetry and multi-monitor DPI scaling API
- FastANSI โ High-performance terminal ANSI compositor
- FastUI โ High-Performance GUI Framework
- FastTUI โ Terminal User Interface Toolkit
Part of the FastJava Ecosystem โ Making the JVM faster. Small package. Maximum speed. Zero bloat. ๐๐