Structured Objects For Anyone
... so optimized, feels amazing.
Some Other Format Again?
SofaBuffers is an efficient binary format for serializing structured data. While it shares similarities with other formats, it focuses on lightweight, embedded-friendly communication and cross-platform compatibility.
Streams Objects From Anywhere
SofaBuffers is based on a TLV-like principle (Type-Length-Value), enabling compact, fast, and backward-compatible data encoding. One key goal is to run on extremely small embedded devices, so the format is designed to be fully streaming-capable, requiring minimal resources.
Seriously Optimized Format Architecture
Data structures are defined in YAML or JSON files. The SofaBuffers generator then produces code for multiple programming languages, handling serialization and deserialization automatically. Definitions can be highly explicit, allowing precise code generation even for strongly-typed languages.
"Because JSON is too fat, and Protobuf is too Google."
I build software for embedded and IoT systems, where components need to talk to each other within scalable systems and to the cloud. For every imaginable use case, there are some established ways to handle communication properly - but nothing that scales in a way that you can just use it everywhere.
For communication between IoT devices and the cloud, JSON is super attractive: simple, human-readable, extremely common, and with JSON Schema you even get validation for free. But the overhead is real - and don't even get me started on the XML folks. Between MCUs, JSON is basically useless. You need binary message formats for that.
MessagePack is my favorite here. Similar to BSON or CBOR, it lets you easily build compact messages and skip the overhead of text-based JSON. But even then, for small MCUs the footprint can still be too big. And for clear communication between different systems, there is often no way to describe a message definition for validation or generation. Also, attribute names are always transmitted, which is pointless if all communication partners already share a message definition.
So, naturally, we end up at Protocol Buffers (Google). It has a message definition format, attributes are based on IDs, code generators for basically every language, and efficient binary packing - sounds perfect, right? But whatever Google was smoking when they wrote that code generator... it definitely wasn’t the good stuff! The data processing could be way more efficient, and the generated code (especially in C++) looks like trying to crack a nut with a sledgehammer. nanopb is a cool C implementation, but once you add all the boilerplate the developer has to write, it's not exactly tiny either.
"Protocol Buffers solve problems only Google has." - Author: unknown
FlatBuffers (also from Google) are faster and follow a zero-copy philosophy, great for embedded systems. But the payload isn't tightly packed, which makes it bad for slow interfaces between embedded devices. And message backward compatibility cannot be guaranteed. Cap'n Proto could be a candidate too, but many implementations seem outdated or poorly maintained.
There are tons of message formats that are best practice in their specific ecosystems, but they only make sense inside those ecosystems.
SofaBuffers aims to fill the gap - making both embedded developers and cloud engineers happy 😊
- Easy to build and parse binary representation to keep the footprint tiny
- Very low message overhead to make slow interfaces more efficient
- Fully streamable too keep resource usage minimal
- Runs on all architectures, so it can't be zero-copy - but we're not streaming gigabytes per second anyway
- Unified message definitions with embedded-friendly datatypes - no need to reinvent the wheel like .proto, .cddl or whatever
- Only best practices, no "does-everything" monster - just simple, efficient and understandable
- Just enough to fit most protocoll needs for cloud and embedded
SofaBuffers aims to be a pragmatic, lightweight, portable message format - simple enough for small MCUs, but structured enough for scalable systems.
