7 ms·
> Rust and Go are much simpler to learn I don't think this is true. I say that even though I would be deliriously happy if Rust replaced C++ in most situations
by quietbritishjim 6y ago
> Rust and Go are much simpler to learn
I don't think this is true. I say that even though I would be deliriously happy if Rust replaced C++ in most situations it's currently used.
Yes, learning the whole of Rust, including any/all dark corners (no doubt it has a few) is easier than learning the whole of C++ including all its dark corners (it certainly has many!). But getting a basic working knowledge of both is not too different... except for Rust's ownership system. I realise that the ownership system is one of Rust's main benefits, but that doesn't change the reality that it's a significant obstacle for many decent developers.
I actually wish it were possible to use Rust in an "unsafe everywhere" mode where you could ignore the ownership stuff. (Maybe this is already possible with liberal use of the "unsafe" keyword, but it is at least socially unacceptable.) Of course it wouldn't be right for every project but it would still be a huge improvement over C++ while being much more accessible than fully safe Rust.
- steveklabnik 6y agoIt's not possible, because unsafe does not turn anything off; unsafe is a superset of safe.
- quietbritishjim 6y agoBut if I use unsafe everywhere then couldn't I pass around raw pointers everywhere instead of references to avoid the lifetime checking? (Try to contain your horror! :-) )
- steveklabnik 6y agoOnly if you write the entire universe; you're going to want to call functions that accept references, and then you're stuck. > (Try to contain your horror! :-) ) Ha! Nah, no horror there. It is interesting to think about, for sure.
- quietbritishjim 6y agoBut I thought you could cast a raw pointer to a reference with "as" in an unsafe block? Obviously that makes it possible for you to create multiple mutable references, or a mutable reference at the same time as an immutable reference, which is undefined behaviour, but undefined behaviour was always going to be the risk of this idea. Also, even if you had a compiler switch to make "unsafe" implicit everywhere, your code is going to be littered with a lot of casts. (Obviously I'm not a Rust expert, which is why my comments are in the form of questions.)
- steveklabnik 6y agoNah it's all good! This is a pretty common thing, and sometimes comes in an alternate form ("can't you just Arc all the things?") You can cast them to a reference. The issue is, the tricky UB happens at this exact boundary. If you're only using references, then the compiler has your back. If you're only using raw pointers, then there are no aliasing issues, so you're good. The hardest part is exactly the boundary between the two. Staying in one world or the other is much easier than going back and forth.
- atoav 6y agoAs someone who had a go at both languages Rust has some hard topics, but the time needed to know enough Rust to be able to not shoot yourself in the foot while getting things done is lower than in C++. Of course this has to do with Rusts philosophy of not letting you shoot yourself into the foot, while in C++ you'd have to get much more experience to achieve the same robustness.
- yahyaheee 6y agoYea I don’t think it’s even comparable, and with c++ it’s still a nightmare to import anything not to mention having to deal with the horribly awkward syntax they have accumulated over the years
- pjmlp 6y agoJust wait until Rust gets 50 years old. As for the rest, there is vcpkg and conan nowadays.
- yahyaheee 6y agoUsed both vcpkg and conan, not comparable to the ease of use of cargo. Needed some high performance code last year, wrote it all in c++. This year migrated to Rust, will never look back. C++ is going to need to break things if they want to fit into the modern landscape.
- pjmlp 6y agoCargo is only simple if one is doing FOSS with Rust only code. Speaking of modern landscape where is a Rust IDE comparable with VS, C++ Builder, QtCreator?
- yahyaheee 6y agoCargo works fine with private repositories, and I use it wrapping C++ code and that works fine as well. I use VScode with rust-analyzer and its been a great experience, had an easier time with it than the c++ vscode extension.