4 ms·
It is always irresistably tempting to claim as proof of virtue the products of what is really just good luck. Rust had the good luck to come along behind C++,
by ncmncm 5y ago
It is always irresistably tempting to claim as proof of virtue the products of what is really just good luck.
Rust had the good luck to come along behind C++, but not too close behind, and so get benefit of hindsight to choose nicer defaults.
I have seen people (even on HN!) earnestly assert that Rust originated the notion of language recognition for object ownership and lifetime, and move semantics—and even insist C++ copied those from Rust, badly. Rust's custodians are equally as bound by their unfortunate early choices as C++'s; sufficiently-aware readers will be able to list numerous cases where early choices are already regretted.
Rust benefits from much more than hindsight: it had nothing to be backward-compatible with, beyond its C ABI subset, where C++ was bound by almost all of C's early-'70s choices. (Function prototypes (along with implicit struct copy, "//" comments, void, and const) were successfully back-ported from C++ to C, freeing C++ from need to parse K&R function declarations.)
To a working programmer, history is void. Rust coders can luxuriate in its lucky defaults while sneering at C++ coders saddled with clumsy evolved syntax and backward-compatibilities. In their turn, old Rust coders will, if they are lucky enough, be sneered at by users of future languages that lucked into lessons Rust has taught by unfortunate example.
- tialaramex 5y agoThe existence of people who mistakenly believe that Rust is innovating is not at all remarkable, this happens all the time for technologies, and if you're setting HN as a high bar you are certain to be disappointed. Of course one thing you certainly can learn from other people's experience is that you're going to learn from experience :) Once upon a time Rust didn't reserve keywords for async and await. Once upon a time Rust's arrays weren't IntoIterator. But when students in 2022 pick up Rust it will seem as though Rust always had async and await and its arrays always implemented IntoIterator. Only if those students dig through old code will they discover that these things were once not true. Contrast C++ where the C++ beginner soon learns that there is a built-in array but it's awful and they mustn't use it. They might reasonably wonder why C++ hasn't fixed that. There are two related things going on here. First and most obvious Rust Editions, the Editions get to change the standard prelude (a set of standard library components which are exported to your program by default without action, such as std::result::Result::Ok which can thus refer to in your program as just Ok); add new keywords (which may not yet have a definition when added); tweak the syntax of the language and even make syntax that previously gave a warning into a hard error in the new edition. Secondly, and enabling Editions to be more powerful, the Rust language syntax was chosen to reserve room to improve and expand. Implementations are not licensed to just carve off potential future syntax for their own purposes. In particular many types of Rust token can grow to accommodate future needs. Once upon a time Rust's identifiers didn't have a raw syntax, which would have made new reserved words painful - so they grew one. This is furthered by the choice to have token-oriented macro processing. Even scary proc macros (which could in principle cause absolute havoc) in practice mostly just manipulate tokens, meaning they don't blow up mysteriously as a result of new library features. A fundamental change to token parsing is invisible to a macro that only wanted tokens anyway, while tweaks to C++ grammar will upset your pre-processor macros because those don't process tokens they just mangle raw text. I have no doubt that Rust will run into unforeseen (and perhaps unforeseeable) obstacles that render it less suited for a future some day than it is today. But I believe it is much better equipped to adapt than C++ was, and as we can see C++ managed to stick around anyway for decades.
- ncmncm 5y agoRecognizing a need for non-disruptive extensability is yet another benefit of decades' hindsight. Invariably, though, dimensions not so well allowed for will sprout necessary extensions like thistles that need to be lived with indefinitely. Of much greater value than smugness for bullets dodged is humility in recognition that not all will be (or, indeed, have been).
- tialaramex 5y agoSure, however, sometimes it turns out you did a good enough job and you're done. Subsequent work is academically interesting or has some narrow use cases, but there isn't going to be further revolutionary change. In cryptography for example, AES-256 is probably enough. Permanently. When DES was designed its keys were purposefully too short and the block size was purposefully too small, and those are the only two elements that are actually broken decades later despite years of intense scrutiny, in AES the keys are long enough and the block size is big enough, and so we're done. Or in audio. Some prototype work for Sony's Compact Disc assumed 14-bit PCM. 14-bit PCM is kinda marginal, some people are going to notice if the track is properly dithered, trivial transformations leave noticeable distortion, levels must be set correctly at all stages, and so you can make a reasonable argument it's not quite good enough. But they actually shipped 16-bit PCM. And 16-bit PCM is easily transparent. Bad dithering in the final mix? Can't hear it. The recording studio wants 20-bit PCM (for headroom), non-audio sampling applications may need 24-bit PCM, but for recorded music playback we are done. It's also disingenuous to say bullets were merely dodged. Happening to not have two increment operators because you couldn't figure out how to do that in your parser would be a bullet dodged. Intentionally choosing not to provide either of them because they are footguns is something else. C++ is old, and C is even older, but neither of them is old enough to argue that all their mistakes were unrecognised at the time.
- ncmncm 5y agoC++ had no choice about increment operators; they came to it directly from C, so anything "recognized" in the '80s would be wholly moot. If you expect to maintain that C's post-increment operator was recognized as some sort of problem in the mid-'70s, you will need documentary evidence. As Bruce Schneier likes to say, cryptanalysis only ever gets better; it never gets worse. The best we can say about AES-256 is that it might be good enough for any chosen period, with probability declining monotonically as the period increases. But the key schedules originally published for AES-256 made it no stronger than AES-128. I don't know if that detail has been fixed in a revision, or if it is still no stronger than AES-128. For Wireguard, Jason chose ChaCha20. It is many years too early to determine which parts of Rust are "done". What we can say with certainty is that some that were thought done will turn out not to be, some not provisioned for extensions will end up needing them, and some defaults will turn out to be regrettable but not fixable.