4 ms·
As an old binary file hacker I can't help but to think that the performance would also be improved by using a different format than Json that doesn't require 75
by throwaway2016a 10y ago
As an old binary file hacker I can't help but to think that the performance would also be improved by using a different format than Json that doesn't require 75,000 lines to be parsed on load.
One drawback of formats like Json and XML is that they require reaching the ending tag ( "}" or "]" usually for Json and </root> for XML ) before the file can be considered parsed. A properly designed binary format can be used like a database of sorts with very efficient reads.
- mozumder 10y agoWe really need a binary version of HTML, CSS, and JSON. (WebAssembly would be the binary version of JS)
- rbritton 10y agoThere's MessagePack[0], which serves basically the same purpose a binary version of JSON would. It came up recently in an engineering article Uber posted. [0]: http://msgpack.org/ http://msgpack.org/
- vog 10y agoAccording to their website, there is only one JavaScript implementation, this that one seems to be for server side (NodeJS), not client side (browser). And even if we had that, we would need some consensus (read: coding rules) on how to exactly encode HTML/CSS/etc. in MessagePack. Looks doable for me, but there is a long way do go.
- kelvin0 10y agoWell instead of JSON you can use Google's Protocol buffers: https://developers.google.com/protocol-buffers/ https://developers.google.com/protocol-buffers/ Haven't used it myself, but worked with people on a project which did, and boy does it fly compared to JSON!
- madeofpalk 10y agoThe last time I looked into it, pure JS implementations of profound (that runs in the browser) were lacking and made destroyed much of the speed impreovements.
- niftich 10y agoThere are less verbose, binary formats for storing XML information models -- like Fast Infoset [1], and formats listed on Wikipedia under 'Binary XML' [2]. HTML5 can optionally be written in a mostly-XML-conforming syntax [3]. [1] https://en.wikipedia.org/wiki/Fast_Infoset https://en.wikipedia.org/wiki/Fast_Infoset [2] https://en.wikipedia.org/wiki/Binary_XML https://en.wikipedia.org/wiki/Binary_XML [3] https://html.spec.whatwg.org/#xhtml https://html.spec.whatwg.org/#xhtml
- dom0 10y agoThe point is that the JSON parser runs in the browser - as native code - so it's rather difficult to match it's performance with some other parser in JS, even if that one has an easier job to do.
- bzbarsky 10y agoIt may be hard to match the performance of the parsing per se. But the typical data flow with JSON goes like this: 1) Get a string. 2) JSON.parse it into an object graph. 3) Use that object graph to build the data structure you really care about (e.g. a DOM). If you parse yourself you may be able to cut out the middleman object graph. That might be worthwhile; needs measuring.