On Monday, April 25, 2016 at 11:41:09 AM UTC-4, Jerry Stuckle wrote:
>
> I can see why you think iostreams are so slow, though.
Always nice to see that ah hah moment in our friends and acquaintances on
usenet.
> I would never
> use to_json, to_xml, etc. to write data unless it had to be in a format
> compatible with many applications across a network or something similar.
> That's what these formats were made for.
Using my own modest attempt at a json library for parsing and
serialization (published as open source), on my Dell Precision notebook,
it takes a little under 10 seconds to read a gigabyte of json text, and a
little under 2 seconds to write it, with insertion to an ostream and
extraction from an istream. Those numbers require some optimizations within
the library when reading and writing to the stream, without them, using
stream io simplistically, read would be about 5 times slower, and write 4
times slower (there are other open source json libraries that are faster,
but they have their own issues.)
Generally, I find these times acceptable for reading and writing a gigabyte
of text, and usually the amount of data I work with is somewhat smaller.
Typically, if I push a button on a python app which sends a json request to
C++ server to simulate some data and transfer it back as json over a socket,
the resulting 3D plot in the python app appears close to instantaneous. So
in most cases, I'm not particularly motivated to transfer anything except
text, given text's other advantages. In those other cases, I use Google
protocol buffers.
>
> >>> manipulators were never a good idea, too inflexible.
>
> Good enough tat millions of programmers around the world have been happy
> with them.
But perhaps not very, very happy. A little Google search will show you much
wailing and gnashing of teeth, many hacks and workarounds, and not a few
alternative toolkits for formatting.
> But as for the format mask - you're still thinking
> procedural code, not object oriented.
You weren't one of those who subscribed to JOOP, were you :-)
In any case, the substance of OO, abstract interfaces, is silent about
whether I want to keep the format of a number, date, currency, phone number
etc. as a string representation in a data store, where my users can
configure it without having to recompile a computer application.
Best regards,
Daniel