4 ms·
I don't think the problem with lifetimes is that they are complex, it's that other languages handle lifetimes for you, but Rust outs to onus on you to manage th
by EamonnMR 6y ago
I don't think the problem with lifetimes is that they are complex, it's that other languages handle lifetimes for you, but Rust outs to onus on you to manage them. C++ also has complex object lifetimes but if you don't invoke that complexity you don't need to deal with it.
- theon144 6y ago>C++ also has complex object lifetimes but if you don't invoke that complexity you don't need to deal with it. I would tend to disagree? In C++, I regularly ran into issues where I "invoked" the complexity with memory/object management completely incidentally, and as the saying goes, shot myself in the foot (or rather, both feet, because lifetime management issues often result in heisenbugs and other really nasty phenomena). Rust makes that complexity explicit, which is really an analogous argument as with static/dynamic typing; it's not that the dynamic languages "handle typing for you", and "static" simply requires more work. Rather, you're forced to deal with it at the very start, instead of down the road. Then again I'm rather new to Rust, so I might misunderstand you?
- EamonnMR 6y agoYou're quite right, but it's worth being mindful that for many projects, down the road never comes. It's a very expensive insurance policy.
- Ygg2 6y agoThe only way to handle lifetimes is: A) Introduce burden on programmer B) Introduce burden on runtime (GC basically) You just get to pick your poison. Do you want the upfront cost in syntax (Rust) or do you want the down the line cost (C/C++).