3 ms·
You 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.
by polio 2y ago
You 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.