Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Owed a billion dollars in Nvidia stock (colo.to)
    295comments
  2. Thinking fast and slow in AI: The role of metacognition (2021) (arxiv.org)
    30comments
  3. Ember-1 (fireworks.ai)
    215comments
  4. When did Google get so weird? (sancho.bearblog.dev)
    724comments
  5. Nissan's third generation e-POWER powertrain (nissan-global.com)
    77comments
  6. Prompting Claude Opus 5.5 (claude.com)
    83comments
  7. Footguns with Postgres "at time zone 'UTC'" (bookofrevenue.com)
    11comments
  8. Malleable software: Restoring user agency in a world of locked-down apps (2025) (inkandswitch.com)
    43comments
  9. Functional Mechanical Sympathy [video] (youtube.com)
    1comments
  10. Made by Mechanical Means (felixrieseberg.com)
    5comments
  11. Analysis: EVs are now nine times cheaper than petrol or diesel to drive in UK (carbonbrief.org)
    6comments
  12. Alan Kay's answer to “Did the ENIAC have a BIOS”? (quora.com)
    42comments
  13. Maybe don't let Muse run your Facebook Marketplace account (threads.com)
    39comments
  14. Self-Hosting on the Dark Web (alvarezrosa.com)
    77comments
  15. Guitar amp and effects pedal built on the Waveshare ESP32-S3-Touch-AMOLED-2.06 (github.com/dashersw)
    39comments
  16. Lunar Terminator Paradox (secretsauce.net)
    51comments
  17. The state of SIMD in Rust in 2026 (shnatsel.github.io)
    38comments
  18. Don't couple your Go code to GitHub (iain.rocks)
    111comments
  19. In an $80 motel room, a discovery to shed light on the origins of life (nytimes.com)
    94comments
  20. Deterministic Concurrency [video] (youtube.com)
    3comments
  21. What I did at Recurse Center (thill.me)
    32comments
  22. Show HN: Lofi Cities – Pixel-art city nights with browser-generated lofi (loficities.com)
    112comments
  23. Imp is a full port of DSPy to the BEAM (github.com/deepfates)
    7comments
  24. Replacing the old battery on rechargeable bike lights (jvns.ca)
    93comments
  25. There is more to code review than (automatable) detection (adaptivecapacitylabs.com)
    86comments
  26. Reading’s Bayeux Tapestry (diamondgeezer.blogspot.com)
    18comments
  27. SpaceX's Starship launching to orbit for first time ever today (space.com)
    —discuss
  28. Previously unheard recordings of John Coltrane, captured by Frank Tiberi (jazzwise.com)
    33comments
  29. Writing Efficient C++ Code (2013) (asawicki.info)
    119comments
  30. Oral history of John Chowning, inventor of FM synthesis [video] (youtube.com)
    24comments

Packing Binary Is Fun

22 pointsby 8h agohereticpleb.vercel.app
9 comments
4h agoHN ↗

Cool. And the next enlightening step would be to generate custom parser code from message schemas. So that when de-serializer reads a next field, it does not read what name and type it will be, it expects and fails if it's not. Safer and more compiler friendly.

4h agoHN ↗

Congratulations, your strings dont support Unicode and you just ignored probably more than 3/4 or more of the world's languages.

2h agoHN ↗

Schemas save you space, but then you lose the ability to understand the data without the schema. That's where JSON has always been handy despite its inefficiencies.

Of course you can get the same kind of thing in binary. I wrote a drop-in binary JSON replacement because it's easy to write a binary one that's twice as fast as simjson and yyjson. The important thing is to never give the drop-in replacement any extras that break roundtrip compatibility.

Was a fun little project to write, and quite useful for me: https://github.com/kstenerud/bonjson

1h agoHN ↗

Schemas save you space, but then you lose the ability to understand the data without the schema. That's where JSON has always been handy despite its inefficiencies.

Of course that’s orthogonal to using a text v binary representation, you can have a schema’d text format, and a self-describing binary format.

BSON, UBJSON, MessagePack and CBOR are binary but self-describing.

39m agoHN ↗

One of my favourite yak shaving adventures in a previous job was writing a parse in place UBJSON decoder for ~1MB of data on a device with about as much free memory. Fast (enough) access by key, binary search with a few shortcuts for the mostly numeric payload. It built an index of maybe 30 bytes to speed things along, but also to let it keep working on the tail of the old message whilst the new one was overwriting it's start.

Should the system design have required all this of a device with 4MB of memory? Probably not. But it worked, and I had a great time

20m agoHN ↗

I'm missing some important parts that I would argue any (binary)format needs.

  - a magic header
  - a version number
  - a crc or data corruption check

Additionally I would argue one would be better off writing a custom text parser instead of parsing a binary format in this case, this is similar to the debate about unixlike config vs windows regedit. I would prefer something other then json but sill readable as txt.

Even the json example provided at the bottom can be minified from 418 characters to 166 by replacing the field names with single characters and removing the spaces. Almost all of the savings in this format come from not including the the field names and having a position dependent layout. You can choose to have delimiters or arrange for a byte to indicate the type(+size) for example the following string encodes the example data almost (85bytes vs 80bytes) as efficient but is still readable and supports utf-8 interpretation.

  123456789;LeroyJenkins;60;alliance;p,100,200,300;i,999,1,1;i,45,100,0;a,s,120;a,a,45;

You may optimize it further by allowing recurring entries and allowing assumed values from a defined default and only sending delta's can be dependent on the type of data you are expecting.

  { "itemId": 999, "quantity": 1, "isSoulbound": false }
  i,999,1,0

could become:

  default = { "itemId": 0, "quantity": 1, "isSoulbound": false }
  { "itemId": 999}
  i,999
14m agoHN ↗

I also want to be a real developer so i just GZIP the JSON to make it binary.

9m agoHN ↗

There already exists a "binary analogy" of JSON called Protocol Buffers or Kiwi. They are pretty simple (a parser can be made in 2 kB of code). Wouold be great if the author compared his reinvented wheel with existing wheels :D