new XML and JSON libs and replacement of std.net.curl

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 15 20:08:15 PDT 2016


On Monday, August 15, 2016 15:01:13 Oleg B via Digitalmars-d-learn wrote:
> Hello.
> In std.xml docs I read that is deprecated, and std.net.curl can
> be deprecated too (not remember here I read about std.net.curl).
> About std.json I read what it's has slow (de)serialization.

std.json and std.xml are definitely going to get the axe at some point. It's
just a question of when we're going to have the replacements ready, and
they've been slow in coming - primarily because one or more people have to
actually do them, and they're a big undertaking. You can certainly use
std.json and std.xml in the interim, but be aware that at some point, they
will be deprecated, and you'll be forced to change your code to use
something else.

> What I must use at this time?
> vibe.data.json has evolution
> https://github.com/s-ludwig/std_data_json, but, if I correctly
> understood, they are not compatible and I can't use
> stdx.data.json in vibe.

std_data_json is the most likely candidate for replacing std.json. It did go
through the Phobos review process on some level, but it was decided at the
time that it wasn't ready (unfortunately, I wasn't pay a lot of attention to
it at the time, so I don't know the details). So, it will probably end up
replacing std.json eventually, but I don't know when, and I don't know how
much it will change before then. I have been using it for my projects, and
it works reasonably well. It's what I'd suggest that you use, but you can
choose to use std.json, and there are at least a couple of other projects on
code.dlang.org that handle JSON.

As to whether std_data_json is compatible with vibe.d, I don't know. It
looks like it uses the same package, so I would have thought that vibe.d
would just rely on it, but I don't know what Sonke is up to in that regard.

> For XML I found this project
> https://github.com/lodo1995/experimental.xml. Is this really
> candidate to std, or author just called it as he want?

That's an official GSOC project that is attempting to create a replacement
for std.xml. It's very much a work in progress, and even if it is accepted,
it's likely to go through a lot of changes before then. But as long as it's
versioned well enough to use without having to deal with constant breakage,
it would be valuable for you to use it and give feedback. If you don't want
to deal with that, you can still use std.xml for now (as horrible as it is),
and I think that there are at least a couple of other XML-related projects
on code.dlang.org.

> As replacement of std.net.curl I found
> https://github.com/ikod/dlang-requests. Who know's about this
> lib? Is this good replacement of std.net.curl?

I fully expect that std.json and std.xml will get replaced at some point.
std.net.curl is a bit more questionable. The main reason that a number of
folks want it gone is because it requires that you have an external, C
library (curl) installed, and it's caused issues as a result, though those
have more or less been resolved, and while Walter wants to get rid of it,
Andrei doesn't seem to agree, so it may be here to stay. And since curl does
stuff with SSL, and it's highly unlikely that we'd implement all of the
crypto stuff in D without relying on an external C library, if we tried to
get rid of std.net.curl, we'd either be trading one external library for
another, or we'd lose functionality in Phobos. But regardless, if it did get
removed, it would end up on code.dlang.org. While it does have various and
cons, it's not like it's fundamentally bad. It's just questionable as to
whether we want it in the standard library. So, if std.net.curl does what
you want, then just use it. Worst case, at some point you _might_ have to
change it so that your project pulls in std.net.curl as dub package instead
of just getting it from Phobos. But there are alternatives on code.dlang.org
that you can use if you'd prefer.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list