“Software objects are conceptually similar to real-world objects: they too consist of state and related behavior” (What is an Object — The Java Tutorials) オブジェクトの概念は現実世界の物と似ている。それ (オブジェクト)も状態と、関連する振る舞いでできてい る。
“Simula is considered the first object- oriented language. As its name implies, Simula was designed for simulation” (Simula — Wikipedia, Free Encyclopedia) Simulaは世界初のオブジェクト指向言語だと考えられている。その名前の通り、 Simulaはシミュレーションの ためにデザインされた。
Do objects correctly model real-world objects?
Things I used to point out which I do no longer ● RWOs have no knowledge about their usage ○ A book can be used to hit people ● RWOs do not respond to messages ○ Boxes do not answer when we ask them its heights ○ Instead, an external intelligence has to measure them These mismatch become trivial if we imagine a city that everything has a micro computer embedded into it.
One moment please...
What do we do?
History-preserving objects seem like a natural transition from traditional objects. ● Make every instance variable immutable ● Make every method return a new object with a reference to the current object
A problem: Q: Won’t this model eat up memory? A: Not as much as you would think but Yes. Since every object is immutable, it can be made persistent. ∴ a new state would require a lot less space than a full-copy. However, memory usage grows linearly over time. A more compact representation is needed.
History of an object (i.e. snapshots of the past) doesn’t have to be contained within itself (i.e. current snapshot) ... if we could express a 4D object directly
Persistent Data Structures Snapshots Recursive Functions Objects
In practice, what gets folded would be a stream of events instead of ticks of a clock.
I call them Minkowski Objects
Modifications to make MOs practical ● Event Stream = Blocking Queue ● Folding function writes to its neighbors’ event stream Side-effects propagate through various MOs’ event streams
Minkowski Object Oriented Programming fill coffee (fold (^ e s s’) brain [...]) (fold (^ e s s’) cup [...]) get excited
drink coffee get smarter (fold (^ e s s’) mouth [...]) eat fish (fold (^ e s s’) fisher [...]) fill coffee (fold (^ e s s’) stomach [...]) catch fish (fold (^ e s s’) fish [...]) fill pee (fold (^ e s s’) toilet [...]) add water provide oxygen
(fold (^ e s s’) river [...])
Conclusion ● Mutable objects aren’t representing anything in real-world 破壊可能なオブジェクトは現実世界のなにも表現していない ● Functional programming can provide a more concise analogy for real-world objects 実は関数型の方がより正確に物体を喩える事ができる ● OOP probably is too weak to make SciFi come true オブジェクト指向は SFを現実にするには弱すぎるのかもしれない