Live data from Hacker News

I think C++ is still a desirable coding platform compared to Rust

lucisqr.substack.com

71–80 of 110 posts

Re: I think C++ is still a desirable coding platform compared to Rust

#71
post #68

Earlier quoted context omitted.

My point is that I am acknowledging that C and C++ needs more discipline. I'm not saying we eliminated this class of bugs!

It sounds like you're working on a mature C++ codebase, so yeah, good reason to stick with that. But I'm curious whether you feel it's worth spending effort on this discipline, outside of working on a particular codebase? I don't know C++, but being freed from making effort to avoid a class of bugs was easily enough for me to learn Rust instead (not that this was the only reason).

I think if I had the opportunity to learn Rust, and some guidance so that I didn't have to do everything the hard way (essentially how I learned C and then C++), then I would!

So far I have used Rust very little, but what I have seen I have liked. I especially liked the much simpler inline assembly in Rust.

Re: I think C++ is still a desirable coding platform compared to Rust

#72

Earlier quoted context omitted.

I actually think Cargo & crates.io are the weakest and shittiest part of Rust right now. They're a bit amateur. But yes, CMake is something I do not miss. Though I miss the alternatives even less. Though C++ with Bazel is actually quite attractive.

So having one easy to use build system (and actual package manager) is worse than having countless arcane build systems?

What kind of strawman game are you trying to play? Those are not my words.

Cargo is... ok. It has rough edges, but mostly works. Various things frustrate me, though there's usually work arounds. Workspace support is still a bit half-assed -- I mean, take a look at this terminally open but rather critical issue: https://github.com/rust-lang/cargo/issues/3946 ; our $work source tree is littered with brittle hardcoded relative paths because of this basic missing feature.

Crates.io is ... not ok. It's a wild west full of hobby and abandoned projects with undisciplined massive dependency trees, has people camping out on names, and lacks even the most basic checks and balances (properly moderated submission process, expiry) and features (org namespaces) that Maven had back in like 2007.

Because of this, incredible discipline is required on large projects with large sets of third party deps or you will end up with multiple versions of things linked into your binary, or with abandoned projects in your dep tree, or just dep bloat generally.

And this ties back to cargo, too. It was only with last week's 1.74.0 release that we finally got the ability to do authenticated repositories? Again, something that Maven supported from day 1.

It's a bad culture that was, I think, imported from the node/npm world. If I were starting a serious corporate project from scratch in 2023, I'd seriously consider a model with checked-in, vendored, moderated dependencies that doesn't use crates.io (or a mirror) at all.

Re: I think C++ is still a desirable coding platform compared to Rust

#74
post #33

Earlier quoted context omitted.

Speak for yourself: I'm not returning to the world of "discipline" (aka lost productivity) without a damn good reason to carry on existing codebases. It's just a waste of a good coder and certainly of good time.

In C++ discipline is optional. In Rust it's mandatory.

I completely disagree; discipline is only optional in C++ if you want to ship broken code. Even the top poster in this thread that actually cops to the productivity overhead of C++ admits (albeit obliquely) they still make memory errors

Re: I think C++ is still a desirable coding platform compared to Rust

#75

Yeah, that's a no from me. I'm a full time C++ dev and every time I code in Rust it is harder for me to switch back. The author has pointed to some issues regarding performance. In the end, you can always rewrite your code to generate other/better assembly, if you really need the speed. I would argue Rust is so much more that just Rust itself. Like many others after noted, it is not only the language, but the whole e…

there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast.

c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too.

on embedded systems where storage space is restricted, rust is simply a no-go.

Re: I think C++ is still a desirable coding platform compared to Rust

#76

Yeah, that's a no from me. I'm a full time C++ dev and every time I code in Rust it is harder for me to switch back. The author has pointed to some issues regarding performance. In the end, you can always rewrite your code to generate other/better assembly, if you really need the speed. I would argue Rust is so much more that just Rust itself. Like many others after noted, it is not only the language, but the whole e…

there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast. c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too. on embedded systems where storage space is restricted, rust is simply a no-go.

Use LTO if that's a problem.

    [profile.release] # A profile to try to minimize the size
    panic = "abort" # Abort on Panic
    strip = true
    opt-level = "z" # Optimize For Size
    lto = true # Enable Link Time Optimization (LTO)
    codegen-units = 1 # Reduce Parallel Code Generation Units to Increase Optimization

Re: I think C++ is still a desirable coding platform compared to Rust

#77

Earlier quoted context omitted.

there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast. c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too. on embedded systems where storage space is restricted, rust is simply a no-go.

Use LTO if that's a problem. [profile.release] # A profile to try to minimize the size panic = "abort" # Abort on Panic strip = true opt-level = "z" # Optimize For Size lto = true # Enable Link Time Optimization (LTO) codegen-units = 1 # Reduce Parallel Code Generation Units to Increase Optimization

it helps, I tried 'how to make rust the minimal in size', but still, it's like 10x of the size comparing to c++ with shared libraries.

Re: I think C++ is still a desirable coding platform compared to Rust

#78

Yeah, that's a no from me. I'm a full time C++ dev and every time I code in Rust it is harder for me to switch back. The author has pointed to some issues regarding performance. In the end, you can always rewrite your code to generate other/better assembly, if you really need the speed. I would argue Rust is so much more that just Rust itself. Like many others after noted, it is not only the language, but the whole e…

there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast. c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too. on embedded systems where storage space is restricted, rust is simply a no-go.

You absolutely can get Rust codegen down to as small as you’d ever need: https://news.ycombinator.com/item?id=34032824

Re: I think C++ is still a desirable coding platform compared to Rust

#79

Earlier quoted context omitted.

there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast. c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too. on embedded systems where storage space is restricted, rust is simply a no-go.

You absolutely can get Rust codegen down to as small as you’d ever need: https://news.ycombinator.com/item?id=34032824

that's for MCU and yes, as it does not use rust's stdlib.

there are lots of embedded systems that run with glibc or musl shared libraries, if rust is used there, it will blow up the storage space with just a few executables due to the static stdlibs.

Post reply on HN