Hacker News·4 min read·hard

Packing Binary Is Fun

B
BurnerBurner
Packing Binary Is Fun
✦AI Summary

A developer explores the process of creating a custom binary format to optimize data storage, demonstrating how to represent strings and integers more efficiently than JSON. The article provides a technical walkthrough of byte-level data manipulation.

Why it matters

Understanding binary serialization is fundamental for high-performance computing and reducing bandwidth costs in data-heavy applications.

✦Dive DeeperCreate a free account to unlock

I saw someone on twitter arguing that saving data in JSON was apparently not what Real™ developers do.

Obviously, I had to become a Real™ Developer too.

“How hard could it be to make my own binary format?”

I ended up building an entire binary schema language that can shrink JSON payloads by 80%.

"hello world" then it would be translated in ascii to

104 101 108 108 111 32 119 111 114 108 100 h e l l o [SPACE] w o r l d So h becomes 104 in ASCII.

Since these ASCII values fit within 8 bits, each character takes up 1 byte.

h e l 01101000 01100101 01101100 l o [SPACE] 01101100 01101111 00100000 w o r 01110111 01101111 01110010 l d 01101100 01100100 so we can just write it using a lil bitta c:

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologyscience
✦

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in