3 ms·
> If we accept that Rust is indeed more difficult to learn than comparable systems programming languages My problem is with "comparable systems programming lan
by tialaramex 4y ago
> If we accept that Rust is indeed more difficult to learn than comparable systems programming languages
My problem is with "comparable systems programming languages". To me the only thing that fits there today is C++ and while a great many programming languages would be easier to learn than Rust, C++ is not one of them by a long shot.
I think the C++ Quiz https://cppquiz.org/ https://cppquiz.org/ and the Rust Quiz https://dtolnay.github.io/rust-quiz/ https://dtolnay.github.io/rust-quiz/ illustrate handily. Neither of these languages is a walk in the park, but, notice they both have "Undefined behaviour" as a possible answer? Safe Rust doesn't actually have undefined behaviour, so you get to rule out one of the possibilities any time you don't see the "unsafe" keyword, which is in fact every time on the Rust Quiz. In C++ some of the quiz questions invoke UB, but good luck correctly guessing which ones.
- actionfromafar 4y agoIn the future as C++ evolves (it had a hiatus of a decade or more where not much happened) it will be interesting to see how it will compare to Rust. C++ is performance first at any price. Hence UB. Rust is also after performance, but will specify implementation details where C++ will defer to compiler writers.
- gmadsen 4y agoI don't think thats correct.. C++ has UB because of backwards compatibility, which has origins to design choices of C in the 70s. Its not like it is optimized for performance above all else, it had immediate needs to be close to metal, and that is the best they could do back then, there was not some "strongly typed" versus "performance" debate happening at the time. The creator of C++ would love for there to be safer abstractions, but has the baggage of the past to carry.
- pornel 4y agoModern C++ is still a safety-third design. std::optional is relatively new, and supports dereferencing, which when it’s empty is UB instead of an abort. There are no plans to add checks to any existing APIs, because “it didn’t have a branch before” is also considered a compatibility issue.
- gizmondo 4y ago> C++ is performance first at any price. Hence UB. I don't think this is entirely correct, C++ in some cases famously preferred ABI compatibility over maximum performance.
- vlovich123 4y agoC++ has no ABI defined. Did you mean API comparability? Would help to clarify some examples
- sirwhinesalot 4y agoWhile the C++ standard does not define any ABI, some implementations (namely GCC and clang) put a lot of effort into maintaining reasonable ABI compatibility. GCC has only changed ABI twice (afaik) and the second time the only thing that changed was std::string! Nowadays MSVC tries to maintain ABI compatibility too, so we should stop seeing a proliferation of those msvcrXXX dlls. Haiku uses C++ for its OS ABI so it relies quite heavily on the fact that ABI compatibility stays very consistent across compiler versions for example.
- pjmlp 4y agoSame applies to Rust, with the difference that there isn't a story for shipping binary libraries, that is why OSes like Haiku care about keeping the ABI consistent, those BeOS applications aren't going to be recompiled.
- bigbillheck 4y agohttps://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2028r0.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p20...
- vlovich123 4y agoInstead of breaking ABI compat for `unordered_map` why not define a new type given that it's so different? It can even be called the same thing and just exposed through a different namespace version (something that's been supported for a while). About the only thing real is intmax_t. The rest feel resolvable within a library without changing ABI / breaking back compat.
- stefan_ 4y agoAs anyone who has looked at disassembled C++ code can attest, "C++ is performance first at any price" aka "zero-cost abstraction" is mostly a pipe dream. Whatever sufficiently smart compiler was meant to make it happen has not materialized.
- bigbillheck 4y ago> (it had a hiatus of a decade or more where not much happened) C++11 is almost as old now as C++98 was when C++11 came out. It's evolved plenty.
- adql 4y agoThe difference that at same level of let's say "UB bugs in code", C++ code will compile, Rust will not. So person learning C++ will start producing code quicker even if their level of competence will produce more buggier code.
- nequo 4y ago> will start producing code quicker This will reinforce bad patterns early on which they will have to unlearn through bug hunting or reading about the edge cases and foot guns.
- nwienert 4y agoOr maybe it allows them to complete a fun side project quick enough that they keep their interest in programming altogether.
- dhosek 4y agoI’ll say that when I started working on finl a couple years ago, I started in C++ (employing 20+-year-old memories of the language). When I switched to Rust, starting from zero, I found myself instantly productive. Yes, there are some things that are harder, but in general, the if it compiles, it works rule holds for Rust. I can still remember some rather disturbing bugs that should never have even compiled in some of my early C code (e.g., treating argv values as if they were variables and could be modified in place).
- nequo 4y ago> keep their interest in programming altogether Python will do that too and without reinforcing patterns that produce UB.
- Filligree 4y agoAlthough Python is getting long a little in the tooth. It used to be a simple, easy to learn language, but who can honestly claim its async implementation is 'simple and easy to learn'? I'm curious if there are any newer alternatives that fit in the same niche.
- swsieber 4y agoIt's worth noting that safe Rust prevents two things. Please be patient with this explanation, as I'm about to butcher it badly (probably not using the right terms): 1) UB - this is when code is invoked. Basically memory mismanagement. We know the signs: segfaults, etc. 2) Unsound code - this is code that has the potential to trigger UB if called incorrectly. I think this distinction is pretty important. It explains why small projects in c++ can get going so quickly, and they have issues when they grow. You can prevent unsound code from triggering UB, but that of course gets harder to do as a project gets bigger.