Just wondering... #449

issue grubino opened this issue on August 3, 2011
  1. grubino commented at 11:05 AM on August 3, 2011: none

    I was just wondering why you chose to use Boost.Spirit classic (instead of boost::spirit::qi) for parsing JSON.

  2. TheBlueMatt commented at 1:18 PM on August 3, 2011: contributor

    Probably not something that should be filed as a bug...though I'd assume there was a reason that no one will know any longer as satoshi isnt here to comment.

  3. grubino commented at 1:27 PM on August 3, 2011: none

    Yeah, my bad. It's unlikely, but since spirit classic is no longer being actively developed there may still be bugs hiding there that won't be addressed very quickly if ever. I mean, parsing JSON isn't really the most intensive parsing that I can think of, but spirit v2 would certainly reduce the amount of code needed here and you could get rid of all these nasty semantic actions and just parse directly into a more useful data structure. I'm not doubting the correctness of this parser, mostly because spirit classic parsers are almost too ugly to look at. I'll code up a JSON parser (EDIT: using spirit v2) this weekend sometime and do a performance comparison with this parser. That's the only potential reason I can think of for using spirit classic (since spirit v2 does a lot of default constructing of attributes by default). I'll send my results if you're interested. Also, I'm somewhat new to github, so advice on where comments like this one should go in the future? Should I email the maintainer directly?

    Thanks for the response!

  4. grubino closed this on Aug 3, 2011

  5. TheBlueMatt commented at 1:37 PM on August 3, 2011: contributor

    We aren't the ones using spirit v1, we use an JSON Spirit from http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx You'll have to ask that guy. (though we do do some small modifications and are on an old version of that library)

  6. grubino commented at 1:50 PM on August 3, 2011: none

    On Wed, Aug 3, 2011 at 9:37 AM, TheBlueMatt reply@reply.github.com wrote:

    We aren't the ones using spirit v1, we use an JSON Spirit from http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx You'll have to ask that guy.

    Ah yes, I see now. The message board there has the answers straight away:

    """ I did look a spirit.qi around 18 months ago. I replaced the spirit::classic implementation with one using spirit::qi. The resultant code was very neat, no semantic actions were needed as an AST was generated automatically. However I found using Qi problematic:

    1. Very steep learning curve.
    2. Compilations took a very long time. Moreover compilation errors were of course obtuse due to the heavily templated code. I found that the only way I could often discover the cause of a compilation error was to comment out sections of code to isolate the error to a few lines. This was very time consuming due to the long compilation times.
    3. The resultant code was actually a bit slower than the original classic Spirit. Probably someone knowing Qi well could have speeded it up considerably, but I am afraid that didn't have the time or inclination owing to 1 and 2 above.
    4. I couldn't compile all my test code in one go because the compiler reached some internal limit. (JSON Spirit allows multiple Value types, Value, mValue etc. I could compile the test code for a single type but not all four at once.)

    I have also created a version of JSON Spirit in which I hand wrote a recursive descent parser. This version is actually the fastest. I cannot remember how much faster, but it was by a certain percentage not by some factor. Parsing JSON with a recursive descent parser is particularly easy as you can tell what type the next token is just by looking at the next character.

    Regards John """

    Thanks,

    Greg

    Reply to this email directly or view it on GitHub: #449 (comment)

  7. dexX7 referenced this in commit 651c1cc2d4 on Jan 27, 2017
  8. sipa referenced this in commit fa140ae276 on May 3, 2017
  9. sipa referenced this in commit e7c1b4490f on May 5, 2017
  10. classesjack referenced this in commit 6cd1c7d352 on Jan 2, 2018
  11. lateminer referenced this in commit 79e7a13b07 on Jan 22, 2019
  12. fjahr referenced this in commit eda5c1a062 on Jul 24, 2019
  13. kallewoof referenced this in commit 48e3e957ce on Oct 4, 2019
  14. lateminer referenced this in commit 2a9e9a8827 on Oct 16, 2019
  15. Losangelosgenetics referenced this in commit b32369cb03 on Mar 12, 2020
  16. Losangelosgenetics referenced this in commit 458fbf6cd4 on Mar 12, 2020
  17. rajarshimaitra referenced this in commit 13a1c538a7 on Aug 5, 2021
  18. bitcoin locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 17:56 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me