Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

On one hand this is undoubtedly a very clever use of ++ features. On the other hand that heck of a lot of scaffolding (just look in /iod directory) and the more scaffolding there is, the more caution is needed in adopting the code.

The same goal - not parsing what's not needed - can be done with a conventional callback-based C code. You basically go through the json data, parse, say, a field and call the app asking "is this ok? shall I proceed?". If it's a yes, then you indeed proceed and parse out the value chunk and pass it to the app the same way. If it's a no, you either abort or skip over the value. The end effect is the same - parsing of an invalid json input is aborted as soon as the app flags the first bad entry; and unwanted fields are never parsed in full.

So I seriously doubt that this is a little more than a marketing spin of a proud developer -

  This makes its performances impossible to match
  in other languages such as C or Java that do not
  provide static introspection.
I am fairly certain that vurtun's code [1] can match and most likely beat this lib's performance, with ease.

[1] https://news.ycombinator.com/item?id=8609236



Vurtun's code is probabely faster than the iod json parser since it leaves the type check and conversion to the user. Since iod knows the structure of the object you are parsing, it directly checks types and throw exceptions if the json string does not contains all the required fields of the destination object, things that you cannot do without compile-time introspection, and that vurtun's library leaves to the user.


No, I meant of course that vurtun + all the callbacks are going to be at least as fast as iod. You'd basically pass a bit of context to every callback, so that the app would know where exactly it is in its parsing. It's clearly a bit more of leg work in terms of coding, but I would personally take that over introducing a dependency on a larger abstract framework. I come from the embedded programming background, so I would opt for a pre-processor step that takes in a struct definition and generates a proper set of parsing callbacks. This way you'd at least see the interim code before it gets compiled. But I digress, to each his own and that's not a point here. I spent a lot of time optimizing C code and I find your blanket performance claims to be too absolute and cocky for comfort.


Sax parsers are tools that you have to use to implement a parser for a given json object. The goal of iod's json parser is to do it automatically thanks to static introspection. It also reports errors if the json string is not compatible with the structure of your object, things that you have to do manually with other json parsers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: