by nly · 1d ago · 0 comments
My personal view is APIs and behaviours should be standardized, not libraries. In that respect C++s efforts to figure out universal async I/O is a noble one unmatched by other languages. And it's a hard problem.
That's not to say it hasn't gone off the rails. The Sender-Receiver model has never 'clicked' for me. I think the ideas is alien and overly abstract and I've never seen anything elegant fall out of it on a single page. Coroutines on the other hand make sense. The C++ language implementation of them is elegant and versatile.
std::execution is a verbose mess.
At my employer pretty much all of our code is C++ and threads aren't used anywhere. As a result, I/O tends to go through our own APIs written to use an Linux ioring backend behind C++ coroutines, which yield to our own main event loop.
In practice it's bad, a generator (co_yield) is often an encapsulated object that will have a non-deterministic lifetime, thus it cannot be put into a fifo.
"Tasks" however (co_await / co_return) often live on a stack-fifo that could've been mixed with partial bump-allocators to allow pointer-stability for the stack-frame (there is kind of the machinery via the new overloading for the promise), but due to varying lifetimes it easily becomes a mess (Looked at some other task library that seemingly had low allocations like this but it feels like the entire machinery can easily break with "careless" usage).
And I think that's a part of why std::execution feels like a mess, it tries to make coroutines in task settings more "usable" for those writing things around tasks, but it doesn't really decide on a coherent direction for tasks (since the language primitive was left too abstract/messy).
It's also not at clear to me why you'd want to put a generator into a fifo. Any succinct code snippets that demonstrate the issue?
> there is kind of the machinery via the new overloading for the promise
Any details?
See under the topic dynamic allocation, https://cppreference.com/cpp/language/coroutines
So char always means "byte" and never a real character. I don't think many C programs will work well if char is a 32 bit type so it supports full unicode.
int8_t came way too late and has a way too long name. It should be i8 or int8. There is a problem when C is more verbose than Java. Also: why did it take so long to get a boolean type and fix the "bools are ints" design mistake.
Lack of standard libraries and module system is just another layer of not wanting to standardize things.
That's not really how unicode support works. It can be useful to have a specific type for storing unicode code points (like Go's 'rune' type), but strings are generally UTF-8 encoded these days, so having a wide char type plays at most a marginal role in a language's unicode support.
E.g. in Java a char is 16 bit while strings are encoded as 8 bit or 16 bit. (If the string only contains Latin1 chars, it will use 8 bit encoding to save memory).
The char type should be what you use while looking at a single decoded character (e.g. when parsing text files), not how you encode it in a string.
Correct but I'd argue almost nobody builds desktop applications in C anymore and the places where C is the most common (embedded) they built full on frameworks including package managers around them.
If you write any daemon that uses jsonrpc for example you immediately pull in 100k+ loc of dependencies just to get off the ground (json via nlohmann, a webserver, ser/de library possible etc) while for an embedded application a lot of projects itself are smaller than just the dependencies most C++ projects desktop have.
C++ competes with Rust. C doesn't.
You can have all the standardization in the world but if you can't trivially swap one implementation for another then what's the point?
I also feel this is self fulfilling. If there's no simple way to pull in libraries then why worry about being compatible anyway? Every codebase has its own quirks and build setup and macros. Why not? There was no simple tool they broke by making those choices.
I feel like this is really a commentary on how young rust is as a language that this issue hasn't been important yet. It takes a long time to realize an API is a mistake.
Note that I said API not ABI above. ABI is a different category of problem.
C will make this obvious by stepping on your toes. C++ will help you along until it has enough leverage to break ‘em.
The package manager for C is whatever your distribution uses plus pkg-config. The standard library is the C standard stuff plus POSIX.
I rather love C, Perl, Python with how easy it is to fit them in any context by manipulating flags and environment variables. It's way better than Go which you have to coerce to not go online and Node.js/npm with its complicated mechanism. People talk about conflict between projects, but system packages works fine before, and you can always use containers and vms to isolate two infrastructures. Also such conflicts is always brought up by the libraries developers who break API contracts happily.
But then, if I want to develop something for Python, I need to reach for a totally different package manager that lives in its own universe and barely integrates with my existing package manager. Then, for Rust, same thing, totally different package manager, totally outside of my OS.
Having multiple package managers on a system is an anti-pattern as far as I'm concerned.
There is, its called Linux kernel, along with whatever package manager used to download the headers and shared libraries.