4 ms·
I see C is missing. If you're going to do a language comparison, might as well include the one language we know will have the best performance and lowest memory
by throwawaaarrgh 3y ago
I see C is missing. If you're going to do a language comparison, might as well include the one language we know will have the best performance and lowest memory
- gigel82 3y agoThere is no light-weight threading concept in standard C/C++, and the cost of one OS thread is at least 1Mb (stack) + 4Kb (tls) reserved memory (at least by default, on modern Windows), so for 1m threads that will be 1Tb of RAM :)
- shrimp_emoji 3y agoHow is your compiler addressing bits like this?
- tialaramex 3y agoC++ 20 has async/await (but of course named co_async and co_await, because C++ isn't the sort of language where you're allowed nice things, the beatings will continue until morale improves) However AIUI C++ 20 doesn't actually supply an executor out of the box, so you would need to choose what to do here as for Rust, where they picked both tokio and async-std and you can see they have different performance. C does only have threads, but you could presumably pull off the same trick in C that Rust does, to get Linux to give you the bare minimum actual resident memory for your thread and you needn't care about the notional "real" size of the thread since we're 64-bit and address space is basically free.
- pkolaczk 3y agoStack memory is allocated lazily on Linux. I thought this benchmarks shows it pretty clearly. Otherwise 10k threads would be already in GBs territory, when in fact it is below 100 MB.
- kaba0 3y agoSince when is C the most performant? One can’t even write a performant generic vector with it. C++ is the de facto language used for hight performance.
- remram 3y ago"One can't even write a performant garbage-collected function in C++" You're describing features not performance.
- kaba0 3y agoSo how do you write programs without data structures? You copy paste some implementation and modify it slightly at every use site? Possible optimizations depend on the semantics of the language — C++ can do just orders of magnitude more with for example a string data structure, than what is possible with a C “string”. So no, C is not the most performant language in general — de facto C++ is used for everything performance critical.
- remram 3y ago> You copy paste some implementation and modify it slightly at every use site? Yes, or use macros. Not saying it's the most convenient, but that's an orthogonal concern. You wouldn't say hand-written assembly isn't performant, so your objection strikes me as wrong.