Most of the time you don't need to do this, usually its the solution for when creating a graph structure with cyclic references.
But when you do, and your data is mutable, generational indices are a legit and very useful strategy that is used in C/C++ too.
See this: https://floooh.github.io/2018/06/17/handles-vs-pointers.html