3 ms·
I find a lot of the frustration with such things in rust is because people try to optimize things very early with rust, because it makes it explicit when you ar
by rcxdude 8y ago
I find a lot of the frustration with such things in rust is because people try to optimize things very early with rust, because it makes it explicit when you are opting into something which costs some performance. Many beginners try to write something with references which either won't work (and in C++ would simply crash) or requires substantial effort to accomplish without some degree of indirection, runtime tracking, or allocation.
In higher-level languages the indirection and allocation are so ingrained into the language users don't even realize it's there (how many people know that basically every class member access or function call in python involves a hash table lookup?). If you try to do the same in rust you find you need to say where you want the runtime tracking and indirection to occur, and in general this means you use less of it, but it doesn't mean you should tie yourself in knots trying to avoid it. A little more eager use of trait references, Rc, and RefCell makes for a much better rust experience, but there's a strange psychology to it which makes people unwilling to do it, even when they know it's there and how to use it (and there is a difficulty of teaching beginners that it is there and how to use it).