Hacker News new | ask | show | jobs
by mrec 4190 days ago
I was intrigued by the bullet in your manifesto about using C++ "because Rust is not yet ready to replace C++".

Obviously not disagreeing given that Rust is still pre-1.0, but I'd be interested in hearing what you see as the big stumbling blocks; is it just library/tooling/ecosystem maturity, or do you have major reservations about the language as it stands?

1 comments

Rust is currently developing so fast that this bullet point in the manifesto is nearly obsolete. C/C++ currently still has the edge for multiplatform-support (emscripten, PNaCl, iOS, Android(?), game consoles), but that's about the only remaining point. With Rust it is also easy to integrate existing C libraries (e.g. middleware libraries for game development), which is usually the main problem when choosing a language other them C/C++ for game development.
Yeah, I'm not sure what the current outlook is for Rust+Emscripten. I'd hoped that the recent runtime removal might put that back on the table, but haven't seen any explicit confirmation of that.

Rust programs also seem to produce big binaries, even with LTO, which would be another strike against it for web delivery.

Rust's big binaries (these days, about 500kb for hello world) are due to the combination of two factors: 1) it statically-links by default (if you opt for dynamic linking, you get the typical C-esque 10kb binaries) and 2) it ships jemalloc as a custom allocator rather than relying on the system allocator. Considering that jemalloc would be unnecessary for any program targeting a web-based platform, you'd be able to strip down the compiled size considerably.
Is jemalloc's footprint really in the hundreds of kilobytes?
As source I cite this PR that just landed today:

https://github.com/rust-lang/rust/pull/20218

"It's quite possible that small programs don't use all of jemalloc, and building with -ffunction-sections and -fdata-sections allows the linker (via --gc-sections) to strip out all unused code at link time. This decreases the size of a "hello world" executable for me from 716K to 482K with no measurable impact on link time. After this patch jemalloc is still the largest portion of our hello world executables, but this helps cut down on the size at least somewhat!"