←back to thread

611 points LorenDB | 9 comments | | HN request time: 1.333s | source | bottom
Show context
thrwyexecbrain ◴[] No.43909187[source]
The C++ code I write these days is actually pretty similar to Rust: everything is explicit, lots of strong types, very simple and clear lifetimes (arenas, pools), non-owning handles instead of pointers. The only difference in practice is that the build systems are different and that the Rust compiler is more helpful (both in catching bugs and reporting errors). Neither a huge deal if you have a proper build and testing setup and when everybody on your team is pretty experienced.

By the way, using "atoi" in a code snippet in 2025 and complaining that it is "not ideal" is, well, not ideal.

replies(5): >>43909244 #>>43909532 #>>43910069 #>>43910728 #>>43913902 #
yodsanklai ◴[] No.43909244[source]
> The C++ code I write these days

Meaning you're in a context where you have control on the C++ code you get to write. In my company, lots of people get to update code without strict guidelines. As a result, the code is going to be complex. I'd rather have a simpler and more restrictive language and I'll always favor Rust projects to C++ ones.

replies(1): >>43909887 #
1. bluGill ◴[] No.43909887[source]
That is easy to say today, but I guarantee in 30 year Rust will have rough edges too. People always want some new feature and eventually one comes in that cannot be accommodated nicely.

Of course it will probably not be as bad as C++, but still it will be complex and people will be looking for a simpler language.

replies(2): >>43910391 #>>43913317 #
2. timbit42 ◴[] No.43910391[source]
How many rough edges will C++ have in another 30 years?
replies(1): >>43914716 #
3. simonask ◴[] No.43913317[source]
Rust has rough edges today. The field of programming is still only a few decades old, and there's no doubt that something even shinier will come along, we just don't know yet what that looks like.

That's not a good reason to stick with inferior tools now, though.

replies(1): >>43914759 #
4. bluGill ◴[] No.43914716[source]
Who knows. It will likely have more than any other language. Though it will also continue to not get credit for things it got right.

There will always remain two types of languages: those that nobody uses and those that everybody complains about.

replies(1): >>43925390 #
5. bluGill ◴[] No.43914759[source]
What does inferior mean?

Rust is inferior to C++ for my needs. This is just a reflection on we started a large project in C++ before rust existed, and now have millions of lines. Getting Rust to work with our existing C++ is hard enough as to not be worth it. Rewriting in Rust would cost 1 billion dollars. Thus despite all the problems we have with C++ that Rust would solve, rust is inferior.

(Rust is working on their C++ interoperability story and we are making changes that will allow using Rust in the future so I reserve the right to change this story in a few years, but only time will tell)

replies(1): >>43923758 #
6. simonask ◴[] No.43923758{3}[source]
I don't think it's a defect of the language that your particular circumstance makes it infeasible to port your project. Having a great C++ interop story would be amazing, but Rust would be decidedly less awesome if it had made concessions in that direction early on.

There's a lot of warts here, particularly around the fact that all Rust types are "trivially relocatable" in C++ parlance. At the same time, figuring out which C++ types are trivially relocatable is pretty difficult. To give you an idea of the current situation, all or most non-POD C++ types must be "pinned" on the Rust side, forcing you to deal with the rather clunky `Pin<&mut T>` API. Either that or heap-allocating all C++ types owned from Rust code. Not great.

The story is likely to improve, hopefully. There's an interesting overview here: https://hackmd.io/@rust-lang-team/rJvv36hq1e

replies(1): >>43925079 #
7. bluGill ◴[] No.43925079{4}[source]
I didn't say it was a defect. I said it made rust inferior for me. Those are different things. I don't disagree with rust reasons for making that tradeoff - but the tradeoff as a result makes rust useless for now, for me. If it works for you great.
replies(1): >>43934924 #
8. leftyspook ◴[] No.43925390{3}[source]
Could it be that it gets no credit for things it got right because it got barely anything right?
9. simonask ◴[] No.43934924{5}[source]
I think the term "inferior" isn't really appropriate, then. It typically applies to the quality of the thing on its own, not its applicability outside of its stated scope.