3 ms·
Except the binding always implies the object is mutated on changes, which make any form of reasoning or concurrent programming difficult.
by Kototama 6y ago
Except the binding always implies the object is mutated on changes, which make any form of reasoning or concurrent programming difficult.
- riffraff 6y agoWhy? There are plenty of OO libraries where method calls do not change the object.
- Kototama 6y agoThere is but it's mostly not how OO programs are built. And even assuming you have most of the core of your program behaving properly and clearly with non-mutable objects. What do you gain from having objects at this point?
- rbanffy 6y agoYou can always mutate objects using functions that return new objects. If you use methods of an instance you know the object's state may or may not change. If you set attributes, you know for sure they changed. If you use a function that returns a new objects you know you paid the object allocation tax.
- Kototama 6y agoI should have written almost always. You can but it's not common. It's like saying you can write functional programing in C. You can but the whole ecosystem is not doing it. If you set attributes, you know for sure that they changed at this particular place in the program but later in another position in the program, can you reason about the value of the object? You don't even who mutated it. And don't tell me "you can get its state", I'm talking about reasoning about the program here. There is a reason why concurrent programming is more difficult than necessary with objects. My point is that this implicit management of the state in "OOP" brings a lot of problems
- rbanffy 6y agoIf I were to design an idiot-proof OOP model that takes this into account, I'd force sequential processing of mutating methods - if the running method starts a mutation and there is another method doing the same, we roll it back until the previous method finishes. Performance would suck, but that's life. You can't have your cake and eat it too.