3 ms·
There's a bit of a higher abstraction ceiling in Rust so in theory if you are successful rewriting a thing in Rust then you now have a codebase that's easier to
by rtpg 2y ago
There's a bit of a higher abstraction ceiling in Rust so in theory if you are successful rewriting a thing in Rust then you now have a codebase that's easier to change confidently.
This sort of property is nice to have in huge codebases where you really start losing confidence in shipping changes that don't subtly break things. But of course a huge codebase is hard to rewrite in general...
- taneq 2y agoSounds like a perfect situation for a strangler pattern? Wrap or transpile the original code into a language with stronger refactoring support and the rest should become incrementally easier.
- kvdveer 2y agoThe advantages of rust only come when you actually use the rust-provides abstraction, especially those around allocation and concurrency. Even if transpiling is possible, the code would still not be structured I the rust way, and you wouldn't have any of the benefits. Same goes for wrapping.
- nsajko 2y ago> There's a bit of a higher abstraction ceiling in Rust Compared to C, yes, but not compared to C++.
- tialaramex 2y agoThis isn't really true. Rust has a much better type system. When writing generic code the impact is enormous. C++ doesn't have a real Empty Type, and it thinks Units have non-zero size. In practical terms this makes it incredibly wasteful and in terms of a clear abstraction it encourages you to come up with a hack that's unclear but efficient.
- saagarjha 2y ago…or you can just waste a few bytes? It's not a big deal.
- polio 2y agoYou can, but that makes the type system worse. Also depending on how these few bytes are used, they can add up and drag down performance.
- saagarjha 2y agoNo, my point is that it doesn't. If your zero-sized types are big your type system is not any worse: it's just less efficient.
- tialaramex 2y agoIf you're focused on just the theoretical correctness of the type system, go back to my first critique: C++ does not have Empty Types. So immediately a whole class of problems that are just a type system question in Rust are imponderable, you can't even say what you meant in C++
- samatman 2y agoCopying a bunch of stuff because the borrow checker won't let you share it can drag down performance as well. Yes, I do understand why one might conclude that tradeoff is worth it. But it is a tradeoff.
- tialaramex 2y agoThe original topic was the abstraction ceiling. There are a bunch of abstractions which C++ just can't express.
- estebank 2y agoFunnily enough, because the borrow checker is so strict I feel more confident writing complex borrowing logic that I wouldn't dare attempting in C or C++ because even if I were to get everything right (a big if), there's no assurance that a later refactor wouldn't subtilty break the code. The borrow checker sometimes makes you copy data that you thought you didn't, but more often than not it is enforcing an actual edge case that would have been a bug, had the borrow checker not be present. If the copy is indeed so critical, you can also ease your pain with runtime checks instead using Rc/Arc, but that's another discussion.
- deleted 2y ago[deleted]