Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D] http+json #1

Open
cyrusmsk opened this issue May 30, 2024 · 0 comments
Open

[D] http+json #1

cyrusmsk opened this issue May 30, 2024 · 0 comments

Comments

@cyrusmsk
Copy link

cyrusmsk commented May 30, 2024

Not sure if you are interested in PRs.
I was wondering how D will do http + json.

On my M1 machine LDC is the most popular option (DMD will require Rosetta, GDC probably possible to build, but there is no pre-generated packages).
LDC is LLVM based D backend. And it is providing more optimized code, but it takes more time for compilation, than reference compiler DMD.

So in D world popular flow is: using DMD in developing iteration, and LDC for preparing deployable to production binary.
So on x86 systems DMD should be even faster!

Using DUB for building I have (with /usr/bin/time):

initial build:
0.40 real 0.37 user 0.05 sys
Second build:
0.05 real 0.03 user 0.00 sys

With go build I have (actually the first build took 2s - probably because it was downloading packages):

Initial build:
0.30 real 0.37 user 0.21 sys
Second build:
0.09 real 0.11 user 0.20 sys

import std.stdio: writeln;
import std.json: parseJSON;
import std.net.curl: get;

void main()
{
    auto luke = get("https://swapi.dev/api/people/1").parseJSON();
    writeln(luke["name"].str, " has ", luke["eye_color"].str, " eyes");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant