7 comments

  • btown50 minutes ago
    This is really interesting. At first glance, I was tempted to say &quot;why not just use sqlite with JSON fields as the transfer format?&quot; But everything about that would be heavier-weight in every possible way - and if I&#x27;m reading things right, this handles nested data that might itself be massive. This is really elegant.<p>My one eyebrow raise is - is there no binary format specification? <a href="https:&#x2F;&#x2F;github.com&#x2F;creationix&#x2F;rx&#x2F;blob&#x2F;main&#x2F;rx.ts#L1109" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;creationix&#x2F;rx&#x2F;blob&#x2F;main&#x2F;rx.ts#L1109</a> is pretty well commented, but you can&#x27;t call it a JSON alternative without having some kind of equivalent to <a href="https:&#x2F;&#x2F;www.json.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.json.org&#x2F;</a> in all its flowchart glory!
  • Levitating2 hours ago
    JSON is human-readable, why even compare it with this. Is any serialization format now just a &quot;JSON alternative&quot;?
    • creationix59 minutes ago
      - this encodes to ASCII text (unless your strings contain unicode themselves) - that means you can copy-paste it (good luck doing that with compressed JSON or CBOR or SQLite - there is a scale where JSON isn&#x27;t human readable anymore. I&#x27;ve seen files that are 100+MB of minified JSON all on a single very long line. No human is reading that without using some tooling.
      • bawolff3 minutes ago
        That kind of feels a bit worst of both worlds. None of the space savings&#x2F;efficiency of binary but also no human readability.<p>Being able to copy&#x2F;paste a serialization format is not really a feature i think i would care about.
    • dietr1ch2 hours ago
      cat file.whatever | whatever2json | jq ?<p>(Or to avoid using cat to read, whatever2json file.whatever | jq)
      • creationix54 minutes ago
        Or in this case, just do `rx file.rx` It has jq like queries built in and supports inputs with either rx or json. Also if you prefer jq, you can do `rx file.rx | jq`
  • barishnamazov2 hours ago
    You shouldn&#x27;t be using JSON for things that&#x27;d have performance implications.
    • creationix55 minutes ago
      As with most things in engineering, it depends. There are real logistical costs to using binary formats. This format is almost compact as a binary format while still retaining all the nice qualities of being an ASCII friendly encoding (you can embed it anywhere strings are allowed, including copy-paste workflows)<p>Think of it as a hybrid between JSON, SQLite, and generic compression. This format really excels for use cases where large read-only build artifacts are queried by worker nodes like an embedded database.
    • Spivak2 hours ago
      Can you imagine if a service as chatty and performance sensitive as Discord used JSON for their entire API surface?
  • garrettjoecox2 hours ago
    Very cool stuff!<p>This did catch my eye, however: <a href="https:&#x2F;&#x2F;github.com&#x2F;creationix&#x2F;rx?tab=readme-ov-file#proxy-behavior" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;creationix&#x2F;rx?tab=readme-ov-file#proxy-be...</a><p>While this is a neat feature, this means it is not in fact a drop in replacement for JSON.parse, as you will be breaking any code that relies on the that result being a mutable object.
    • creationix1 hour ago
      True, the particular use case where this really shines is large datasets where typical usage is to read a tiny part of it. Also there is no reason you couldn&#x27;t write an rx parser that creates normal mutable objects. It could even be a hybrid one that is lazy parsed till you want to turn it mutable and then does a normal parse to normal objects after that point.
  • benatkin48 minutes ago
    Interesting. I&#x27;ve heard about cursors in reference to a Rust library that was mentioned as being similar to protobuf and cap&#x27;n proto.<p>Does this duplicate the name of keys? Say if you have a thousand plain objects in an array, each with a &quot;version&quot; key, would the string &quot;version&quot; be duplicated a thousand times?<p>Another project a lot of people aren&#x27;t aware of even though they&#x27;ve benefitted from it indirectly is the binary format for OpenStreetMap. It allows reading the data without loading a lot of it into memory, and is a lot faster than using sqlite would be.<p>Edit: the rust library I remember may have been <a href="https:&#x2F;&#x2F;rkyv.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rkyv.org&#x2F;</a>
  • creationix4 hours ago
    A new random-access JSON alternative from the creator of nvm.sh, luvit.io, and js-git.
  • Spivak2 hours ago
    I love these projects, I hope one of them someday emerges as the winner because (as it motivates all these libraries&#x27; authors) there&#x27;s so much low hanging fruit and free wins changing the line format for JSON but keeping the &quot;Good Parts&quot; like the dead simple generic typing.<p>XML has EXI (Efficient XML Interchange) for precisely the reason of getting wins over the wire but keeping the nice human readable format at the ends.