News for hackers. Stuff that matters.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by beefsack on Sunday September 14, 2014 @05:35AM (#8314880)
Out of interest, do you have any size comparisons compared to gzipping the raw homogenous JSON text?

Edit: I did a quick test by myself, using the first example but repeated for 10,000 objects:

  Raw:                550111
  Homogenius:         150183
  
  Raw gzipped:        1688
  Homogenius gzipped: 419
Interesting to see a ~4x between raw JSON and Homogenius JSON both when compressed and not compressed.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by walrus on Sunday September 14, 2014 @06:00AM (#8314903)
In most real-world cases, it'll look like this:

  gzip+Homogenius < gzip < Homogenius < original JSON
gzip+Homogenius will typically be better than just gzip because Homogenius 'knows' about the structure of JSON. gzip will typically be better than Homogenius (without gzip) because it can compress the payload.

Here's the size (in bytes) of the sample files given with the project:

   69934 packed-homogenius.json.gz
   79550 verbose.json.gz
  213742 packed-homogenius.json
  265177 verbose.json
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by _delirium on Sunday September 14, 2014 @11:05AM (#8315323)
I get the same ordering with gzip, but it seems sensitive to compression algorithm. With bzip2 (default settings, v1.0.6), homogenius seems to actually worsen the compression ratio, at least on this one example:

     52093 verbose.json.bz2
     56298 packed-homogenius.json.bz2
     68521 packed-homogenius.json.gz
     79222 verbose.json.gz
    213742 packed-homogenius.json
    265177 verbose.json
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by Scaevolus on Sunday September 14, 2014 @02:10PM (#8315815)
BWT-based compressors like bzip2 do best when their inputs have highly repetitive structure. In a JSON file with many repeated keys, the information that `"k` is usually followed by `ey_1": "` is compressed very effectively. For similar reasons, bzip2 tends to outperform gzip on executables-- it can more effectively model the conditional probability of opcode sequences.

See http://mattmahoney.net/dc/dce.html#Section_55 for more discussion

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by beefsack on Sunday September 14, 2014 @06:05AM (#8314907)
You had the same idea as me, I think I posted my edit almost exactly when you posted this!

Interesting to see a similar correlation in your results in the ratio between the two non-gzipped and gzipped files.

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by sauere on Sunday September 14, 2014 @11:17AM (#8315349)
Semi-OT: i am amazed to see how many big sites do not have gzip/deflate compression enabled in their webservers. Especially on mobile connections this can actually make a difference.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by _ducky on Sunday September 14, 2014 @07:49AM (#8315025)
I think [Transit][1] by Cognitect addresses this issue as well.

[1]: https://github.com/cognitect/transit-format#caching

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by afshinmeh on Sunday September 14, 2014 @07:59AM (#8315039)
Actually I'm trying to create a new datatype for homogenous data types, which is prevents repeating keys that happened in JSON datatype.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by akx on Sunday September 14, 2014 @04:59AM (#8314840)
I think this needs some sort of marker for the compressed form to make it clear it's not to be digested as is. Maybe `$HMGNS$` or something as the first key of the array?
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by imaginenore on Sunday September 14, 2014 @11:32AM (#8315388)
Why not just use MessagePack (aka MsgPack)

http://msgpack.org/

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by dennyabraham on Sunday September 14, 2014 @12:42PM (#8315560)
MsgPack is great, but pure JSON compaction methods like this or transit can be used directly in a browser.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by imaginenore on Sunday September 14, 2014 @05:04PM (#8316231)
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by codehero on Sunday September 14, 2014 @07:00AM (#8314964)
I see two great things about this tool, and not exactly for what it was designed:

1) Fix bandwidth problems caused by API designer laziness.

2) Detect API designer laziness and programmer laziness.

The API designer laziness merits description. Essentially, if you as an API host server are sending back tons of redundant data, you are doing a disservice to your user by not passing references to this data in the first place. The results in your API should either include an entities section or links to retrieve more data. (Note the scale of repeated data I am talking about here are subtrees, not just key/value)

The programmer laziness is when an he just sends back JSON.stringify(someVeryLargeObject), instead of making sure only a minimal object is sent back.

So we can detect this laziness by running this tool and looking for 4x compression gains!

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by Guillaume86 on Sunday September 14, 2014 @10:17AM (#8315241)
It's not always lazyness, several small connections can be considered worse than one bigger payload in some scenarii. There's no universal truth about API design, every case is different.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by AYBABTME on Sunday September 14, 2014 @02:08PM (#8315810)
Sending too much data is often better than having to do many RPC calls. It's the same problem than normalizing/denormalizing DB schemas, except that DB engines are smart (denormalizing can hurt perf) while RPC clients aren't.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by Ixiaus on Sunday September 14, 2014 @08:20AM (#8315071)
Bandwidth issues can be solved well with msgpack too.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by eli on Sunday September 14, 2014 @09:02AM (#8315130)
If size is a concern, wouldn't a binary message format make more sense?
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by afshinmeh on Sunday September 14, 2014 @09:04AM (#8315134)
Binary format will help as well in homogenius format. Please note that I'm defining a new datatype, not only a compressor.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by bussiere on Sunday September 14, 2014 @07:46AM (#8315018)
You loose in human readability but you win in size. An interesting project and i think about a lot of uses for it (save bandwith, avoid timeout etc ...)

thks to make it and i will use it (in go i think).

Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by sauere on Sunday September 14, 2014 @11:19AM (#8315358)
Yep. Depending on the scenario, i don't think this the loss of readability is worth it. Using gzip on the webserver already cuts enough.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by grimlck on Sunday September 14, 2014 @12:04PM (#8315464)
Except that if you don't care about human readability, you might as well use a binary format and decrease size even more
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by ah- on Sunday September 14, 2014 @06:41AM (#8314943)
So it's a schema plus interned values? Do you think it might be better on real-world data to use just one mapping of value id to value instead of one per column/key?
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by placeybordeaux on Sunday September 14, 2014 @11:34AM (#8315396)
I really don't see too many use cases here. Both parties have to buy into it, then at that point you might as well use a binary protocol.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by jarin on Sunday September 14, 2014 @01:01PM (#8315613)
For some apps, there are cases where you want to load the entire dataset and then operate over it (see pourover.js http://newsdev.github.io/pourover/ )
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by stinky613 on Sunday September 14, 2014 @10:20AM (#8315245)
Doing this with JSON is a neat idea. I recently learned that Excel workbooks do this using a sharedStrings.xml file in the .xlsx package.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by stefan_kendall3 on Sunday September 14, 2014 @10:38AM (#8315276)
No benchmarking or comparisons with gzip.
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by shocks on Sunday September 14, 2014 @08:54AM (#8315119)
Any plans to add this to npm?
Re:Show HN: Homogenius – Packer/unpacker to reduce the size ... by afshinmeh on Sunday September 14, 2014 @09:12AM (#8315144)