5 ms·
Rust Unpopular Opinion
The best part of rust is not coding, it's debugging.
You get about 30 or something number of errors in large project. And you debug, one by one, and one by one. It goes down to 30, 29, 25, 24 .. and with a little patience you get it down to 4, 3, 2, and a error. Sometime you can even increase errors, because there is error around error, but it generally goes down just as quick.
Then you correct the last bug, and it then shows `Finished dev in ## seconds`. And, most probably, your code works just as you expected. No memory bugs, no side stuffs. Sure, there can be logical errors, and it can be corrected. But no hard to know errors. The error message tells you how to correct your syntax error. It's a bit opinionated, but it's good and, at the end of day, it guides you to write a decent code. And finally with `cargo fmt`, and your code looks just as compact and pretty as flawlessly it works.
- pestatije 4y agoWait until the frameworks spoil it
- thesuperbigfrog 4y agoFor more super debugging powers, try the Design by Contract features in the 'contracts' crate: https://crates.io/crates/contracts https://crates.io/crates/contracts
- worik 4y agoThat is an awesome crate!
- deleted 4y ago[deleted]
- gavinray 4y agoFor a really unpopular opinion: I prefer modern C++20/23 to Rust. For 98% of tasks Rust is incredible. But modeling those 2% of problems that don't fit neatly into Rusts domain, the level of "unsafe", "PhantomData", and advanced type-system hacks you need feels obscene when I can use some pointers in C++. Rust also does not have a compelling platform/story baked into the std for low-level asynchronous programming. High level Mutexes and locks are there, but you're in for a world of hurt if you want to do something like sharded/striped locking, where the actual data being protected isn't directly owned by the lock (see Tokio's "OwnedMutexGuard" for this, thanks to Alex Chi and Victor Yang for telling me about this)
- worik 4y agoYes. Any system like Rust will have corner cases where it is awful. The simplest example is doubly linked lists, specifically, and any circular data structure in general. They are hard in any language to get right, but for all its sweat and pain Rust is no help here. C++ is a better choice.
- gavinray 4y agoI will openly say I think Rust is an all-around better language. If you are building general-purpose systems software, or just want to write fast software, use Rust. If you are fiddling with bits, doing low-level concurrency, writing a GC/Memory Manager etc, or have self-referential datastructures like graphs or trees, you're going to have an order of magnitude easier time writing it in C++. (Rust-experts excepted) Also, the developer experience writing C++ is worse than Rust by miles. Though the tooling (fuzzing, LSP, debugging, sanitizers, etc) is stellar, likewise with Rust.
- rich_sasha 4y agoI agree with this, but also sadly note structures like trees are sadly quite common, in the type of code I write anyway. It is a bit of a niggle I have with Rust.
- worik 4y ago> sadly note structures like trees are sadly quite common, in the type of code I write anyway. It is a bit of a niggle I have with Rust. Trees are no problem with Rust It is circular, rather than recursive, data structures that are troublesome
- rich_sasha 4y agoI had to use recursion to build a tree in AoC '22 day 7. I needed to have both a mutable stack of current tree nodes (`cwd` if you like) and the tree structure. Or equivalently a doubly-linked tree, where nodes point at their parent. It was a bit ugly. In C++ you just write it. I get why it's hard in Rust, just saying, it really does crop up.
- xiphias2 4y agoAt this point data on Android bugs shows that Rust clearly won. Also if we don't want government spying easily on all our devices (even open source ones), we all have to take safety seriously.
- pjmlp 4y agoPartially, Android team still doesn't have any public roadmap to support Rust for writing apps. Thus anyone that wants tooling support in NDK and AGDK at the same level as C and C++ have to do the whole integration themselves. Android and Visual Studio plugins, project templates, mixed language debugging, APIs, JNI bindings generation, ... No doubt this is eventually come, maybe something for Google IO this year.
- lelanthran 4y ago> Sure, there can be logical errors, and it can be corrected. Yeah, but the vast majority of my bugs in C projects were logical errors :-/ Logical errors outnumber memory errors at roughly 100:1
- Gigachad 4y agoThe problem is memory issues are extremely toxic. They hold the ability to completely derail the program and do just about anything.
- woodruffw 4y agoThis is a measurement error: the idea behind Rust is to make the ratio between logic and memory errors infinite, by eliminating memory errors as a bug class (to a vanishing degree, anyways). Besides, logic errors in Rust don't cause memory errors as knock-on effects. Most of my logic errors in C and C++ codebases ultimately manifested as some form of unsound memory access.
- rich_sasha 4y agoIt's quite easy to accidentally segfault a C++ program. IME so far it's much harder to accidentally segfault a Rust one. Even unwrap et al are useful, because they show you explicitly where you assume something potentially unsafe is happening.
- worik 4y ago> Logical errors outnumber memory errors at roughly 100:1 Mēh! Possibly. But you can catch logic errors with logic tests. Catching memory errors is a different problem.
- pictur 4y agoWhat you're talking about is more like lint checking than debugging. I thought you meant debugging a running application.
- rich_sasha 4y agoTo be honest, my reasons for preferring Rust have little to do with any of this. Yes I think Rust is a nicer language, but it also does get in the way a bit more than C++. The real reason is that C++ feels ancient and creaky. Packaging? Nope. Build system? Yeah, set it up yourself. Easy to use build tools? Erm no. Reasonable error messages with templates? Lol. Macros and templates feel both central to the language and like hacks. Syntax is also borderline unreadable; double ampersands, lambdas all look like a cat walked across the keyboard. I'm not hating on C++, I have many happy memories of using it, but Rust feels just so much user friendly.
- trinovantes 4y agoI really wish C++ also had a standard package manager like cargo or npm
- pjmlp 4y agoLike in many things in C++, you get to choose. Conan, vcpkg, NuGet, Hunter, CMake Packages,... Most of them even support binary dependencies, contrary to cargo (currently).
- steveklabnikger 4y ago[dead]
- pjmlp 4y agoExcept that isn't a feature from Rust, rather from ML linage of languages since it was designed in 1973. It just happens that many never used any other ML inspired language, so they attribute those capabilities to Rust.
- deleted 4y ago[deleted]
- kahlonel 4y agoThere’s nothing unpopular about this. In fact this is the most popular opinion on HN.
- ralston3 4y agoThis is unpopular? XD