4 ms·
Using c++ after learning rust feels like picking through moldy bread
by blurbleblurble 2y ago
Using c++ after learning rust feels like picking through moldy bread
- hypeatei 2y agoUsing C++ after Rust made me appreciate the latter a lot more. You quickly learn all the footguns that the compiler stops you from doing and is generally a good learning experience.
- ModernMech 2y agoThis is what I feel as well. I liken it to using an aimbot in Quake. Turn off the aimbot and you still win because the aimbot trained you how to get headshots. There are many times the Rust compiler told me I couldn't do something I had insisted would be fine, only to ponder and realize in fact what I was doing would cause subtle bugs in an edge case. Rust catches it at compile time, C++ allows you to write the code and sends you a segfault when the subtle edge case occurs in production.
- chowells 2y agoSegfaults in production are the good case. They're when the system recognizes you've made a mistake and stops it from propagating. The bad cases are when the program keeps running but silently does the wrong things.
- spacechild1 2y agoYes! This can be a real problem when your data structures are allocated from a memory pool. Since the whole memory region is owned by the program, out-of-bounds writes will either do nothing or silently corrupt your program state.
- ModernMech 2y agoThe good case is that you catch the error in development and it doesn't even get to production.
- plandis 2y agoPlus the Rust compiler actually gives you helpful error messages. C++ compiler errors might as well be in Klingon.
- marcosdumay 2y agoStrings! Strings in Rust aren't that great, because there are some details you must keep track. But when I was first learning it, I eventually had some desire to rewrite stuff in C++, and always stopped at the first thought of dealing with strings.
- remram 2y agoElaborate?