4 ms·
Why do you specifically enjoy it more than C++? As far as I know, the main goal of Rust is to be safer than C++, not more enjoyable to write.
by sdegutis 10y ago
Why do you specifically enjoy it more than C++? As far as I know, the main goal of Rust is to be safer than C++, not more enjoyable to write.
- livingparadox 10y agoHaving confidence and trust in your code, and having less surprise runtime bugs in your code would naturally lead to a more enjoyable coding experience, I'd imagine.
- pcwalton 10y agoIt was designed to be nicer than C++ to write too. Why would we have gone through the trouble to add (for example) pattern matching if it wasn't?
- vvanders 10y agoTotally. Pattern matching and blocks as expressions are something I reach for constantly in C++ & Java and always end up disappointed when I remember they aren't there.
- outworlder 10y agoWasn't it? I can contrast the respective compiler error messages to point out that, whether it was designed as such or not, writing Rust IS more enjoyable.
- jamesmunns 10y agoFor me (also ~1000 lines of rust in production), the tooling and packaging was a huge winner. Having docs (with a doc generator), a test framework, a package manager, and a helpful [cross] compiler all put together, along with blazing speed and amazing reliability at runtime is an amazing combo.
- quantumhobbit 10y agoMerely being safer than c++ is enjoyable because I don't have to be quite so paranoid about introducing bugs. Also rust has some more modern functionalish constructs like lambadas and pattern matching.
- duneroadrunner 10y ago> Merely being safer than c++ is enjoyable because I don't have to be quite so paranoid about introducing bugs. For those times when you have to use C++, SaferCPlusPlus[1] should help. [1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus https://github.com/duneroadrunner/SaferCPlusPlus
- pjmlp 10y agoHow does it help to make everyone on the team play ball to not use C style coding or the quality of third party libraries? If the answer is code review, it will never work.
- duneroadrunner 10y agoI can certainly appreciate the sentiment that one of the most valuable features a language can have is the ability to make your co-workers write better code :) And it's hard to compete with Rust in that sense. That is, if you're starting a brand new project. But in other circumstances, another valuable feature would be to be able to make your co-workers' (and predecessors') existing code retroactively safer. The easiest way to do that is probably by enabling the llvm/gcc sanitizers when compiling. But unfortunately that is often not a practical solution for several reasons[1], not least of which is the performance penalty. So the more practical solution may be to use SaferCPlusPlus to replace (in a straight-forward but not quite automated manner) all the potentially dangerous C/C++ data types (pointers, arrays, etc.) with safe, fast compatible direct substitutes. Thereby salvaging existing code bases. Wrt preventing the use of C/C++'s unsafe data types in new code, currently SaferCPlusPlus does not provide any mechanism for such enforcement. But you could imagine the effort required to implement such an enforcement mechanism might be small compared to rewriting some large code bases in, say, Rust. And in the mean time, even existing C++ static analyzers seem to be getting better at flagging potentially unsafe code. [1] http://duneroadrunner.github.io/SaferCPlusPlus/#safercplusplus-versus-clangllvm-sanitizers http://duneroadrunner.github.io/SaferCPlusPlus/#safercpluspl...
- 10y ago
- sidlls 10y agoLong time C++ programmer here. I specifically like the immutable-by-default, borrow, and move semantics. I can write safe code without bloating up my source with 'const &', std::move, '&& ...' and the like. The safety issue for me is about the least important thing. Touting it as the big reason to use Rust is a distraction from my point of view.
- santaclaus 10y ago> The safety issue for me is about the least important thing. For real. Rust is a great language, but for the love of god, all you hear is safety safety safety. I give about 2 out of 10 fs about safety. The worst part of C++? Dependency management. Cargo is sick -- hype that up more!
- pjmlp 10y ago> The worst part of C++? The worst part is people using it as if it was C with a C++ compiler. I lost count the amount of times I had to create a nice C++ wrapper for "C++" libraries that are just a pile of C functions and data structures, due to copy-paste compatibility. And yes, the respective lack of safety by not making use of C++ improved type system and standard library.
- deleted 10y ago[deleted]
- shadowmint 10y agoIt is though. I don't know about 'main goal' but rust is fun to write. Far more than c++ for me. Compile times. Traits. Generics that aren't templates. A package manager. Functional constructs. Cross platform. It's got all the shiny toys. The state of the art in C++ is what? One file drop in headers, no package management and STL hell? Have you read the UE4 engine code base? What are horrific mess. There are certainly problems with rust (imo tooling and libraries), but I don't think for a moment how enjoyable to write it is, is one of them... C++ is a bloated language and I hate writing code in it. I hate that the mix of C++14/11/?? You get is different is every project. I despise that my C++ code from QT, UE, win32 is virtually incompatible, and the header/code legacy divide (or not if you happen to be in a system that allows it). I guess your milage may vary, but I've not talked to many people who didn't like programming in rust... Mostly just people who found it hard, or didn't know why they would bother vs. their current 'good enough' language (eg. C#).
- pjmlp 10y agoGame developers, specially AAA studios, are well known for writing messy code, regardless of the language. I bet you if UE5 would get rewritten in Rust, it would just look as messy.
- dman 10y agoPeople havent had enough time to write huge messy codebases in Rust. Irrespective of language, I suspect that people hate reading source code and would much prefer to write code rather than read code. Ten years from now, I am hoping that Rust becomes the defacto systems language, but I strongly suspect that people will have similarly bad things to say about large Rust codebases then as they do about C++ codebases now.
- burntsushi 10y agoI find Rust to be more enjoyable to write in than any other programming language I've used. The reasons why aren't that interesting, because they're the same reasons everyone else has: algebraic data types, safety, control and tooling. (I just finished implementing a parallel recursive directory iterator that respects gitignore files. No unsafe. No data races. No mutexes. Blazing fast. So I'm particularly over the moon at the moment. :P)