top | item 43863489

(no title)

dvratil | 10 months ago

Amazing, now could I just get a way to do asynchronous network requests in two lines of code, like I have with other languages?

Honestly, it seems to me like the committee is constantly chasing the easy bits but is failing to address the bigger issues in the language and, more importantly, the standard library.

discuss

order

binary132|10 months ago

It’s very different to ask for that from a language like Go or Python vs a language like C++. C++ is for interacting with system APIs and resources, on ANY system. Standardizing networking would require that every targetable host must have a common interface. Merely bridging win32, macos, bsd, android, and Linux is hard enough, without regard to all the possible platforms a C++ user might be interested in targeting.

The more you add to the standard, the narrower the platform support gets. Should we also force C++ to only be able to target 64-bit hosts? How about requiring hardware vector support? See what I’m getting at?

If you just want to make an async nw call, there are lots of things you can do that in already. If you want to write an async nw driver or library, then maybe you should use C++.

lavalida|10 months ago

Boost.asio and Boost.cobalt both allow you to do this. You could even implement the coroutine traits yourself if you don't want to use these libraries.

int_19h|10 months ago

co_await etc is there, now it's a matter of libraries picking that up.

On Windows, you can do this today:

  auto response {co_await httpClient.GetStringAsync(uri)};

EliRivers|10 months ago

Sounds like you should use those other languages. Right tool for the right job.