4 ms·
This was more interesting than the average "rewrite in Rust" blog post. Specifically I thought the part about how having compiler-enforced memory safety allows
by dry_soup 7y ago
This was more interesting than the average "rewrite in Rust" blog post. Specifically I thought the part about how having compiler-enforced memory safety allows for the use of patterns that would otherwise be difficult to use safely interesting.
- epage 7y ago> compiler-enforced memory safety allows for the use of patterns that would otherwise be difficult to use safely I have to say, this has been amazing. For context, I'm a C++ developer who has had minimal run-ins with the borrow checker because I was already used to thinking about ownership. I refactored a large-ish Rust crate I maintain to use references for a fundamental type. I would have considered it irresponsible to do that with a C++ codebase unless absolutely required. Even if I did the upfront analysis to make sure it was safe, I'd need to re-do that exercise for every architectural change, at least. Instead with Rust, I just tried it on a whim, knowing the borrow checker had my back.
- pjmlp 7y agoIn C++ you can have some help via static analysis. Unfortunately very few care to actually use them. https://www.bfilipek.com/2019/12/cpp-status-2019.html?m=1#what-additional-tools-do-you-use https://www.bfilipek.com/2019/12/cpp-status-2019.html?m=1#wh... As I learned since Turbo Pascal days, if it isn't part of the language, it seldom gets used.
- roca 7y agoThat's quite right. But also there is a big difference between "the static checker will probably catch errors of this kind" and "the compiler will certainly catch errors of this kind". The latter is far more liberating.
- Avshalom 7y agoworth pointing out, i think, that that was the original justification for rust: that by building a safe language that still gave you the level of control you'd expect from a C(++) they could experiment with all sorts of otherwise difficult and subtle concurrent code to figure out what would actually work/help. Much like Erlang's concurrency fell out as a consequence of needing to be confidently write high availability code, Rust's general safety falls out of needing to write concurrent code fearlessly.
- masklinn 7y agoOddly enough that was not the original justification, Rust was initially conceived as something closer to Swift. It’s really the accretions community which saw the possibility to fulfill a need and ran with it, and of course Grayson Hoare & co which accepted / allowed it. Rust used to have split stacks and green threads for instance, and had special syntax for GC’d values (and unique pointers TBF).