|
|
|
|
|
by ki_
1218 days ago
|
|
as a language designer.. im still stuck wether ownership is a good or bad idea. I like ownership because that's how we handle things in the real world. Eg. 2 people grabbing potato chips out of a bag at the same time is a bad idea. We pass the bag along. wait turns. But for some reason, we dont do this with computer programs. So.. should we do this with computers or not? Feel free to reply. My instinct says 'yes'. But i also have a feeling that im going to run into problems that current languages dont have. Such as being forced to copy data or have complex systems like in rust to make the compiler happy. |
|
I'm unsure what you mean here. It's pretty foundational to the structuring of programs hierarchically (eg, trees own their children, functions own their variables, closures own their environments, and so on).
The classic argument against ownership as a language semantic is that it doesn't play well with graphs and circularly linked lists, where there isn't a meaningful hierarchy and therefore no one ancestor is the "owner" of any descendant. The counterargument is that these datastructures are both rare and better represented with a single owner of the data and the relationships represented through indirection even if your implementation language doesn't enforce ownership (for example, adjacency lists/matrices for graphs, vectors for lists, etc).