5 ms·
OOP actually doesn't model the real world well at all. It seems to on the surface, but it completely ignores time. In the real world, everything is a process.
by danenania 13y ago
OOP actually doesn't model the real world well at all. It seems to on the surface, but it completely ignores time.
In the real world, everything is a process. Nothing ever stays the same or stands still. No object is the same object from one millisecond to the next.
Immutable state isn't just a formal exercise--it's a more authentic model of the world.
- arethuza 13y ago"everything is a process" To me that's as bad as saying "everything is an object". I'd rather try and understand where each approach is best rather than picking a single approach and dogmatically applying it in every scenario.
- wcummings 13y agoI think his point is that the real world is concurrent states, not context switching. To loosely paraphrase Joe Armstrong, in the real world, data isnt shared, it's communicated. In this sense, the process as a fundamental abstraction more correctly models "the real world."
- theseoafs 13y agoI'm sorry, are you arguing that immutability models the world more well than OO because no object in the real world ever stays the same?
- SamReidHughes 13y agoNo need to apologize. With immutability you have to explicitly model temporal changes.
- tomp 13y agoYes. Due to Special Relativity, different observers perceive events (changes to object state) at different moments, the state of the whole universe is not consistent. Therefore, we model the universe using a sequence of immutable universe snapshots, with different computational agents independently moving through the (branching) timeline of snapshots, so that each and every one of them views the universe consistently.
- pmahoney 13y agoMost events humans care about happen in plain old classical physics, and no computer is moving at some large fraction of light-speed relative to any other computer. If you maintain synchronized clocks, everyone can agree on the exact same order of events (which would not be true in a relativistic situation). Now it turns out to be difficult to maintain synchronized clocks, and Lamport timestamps and vector clocks are alternatives. The end result looks similar to a relativistic situation, but (and I'm not a physicist), it seems wrong to claim this situation is because of Special Relativity. Thoughts?
- tomp 13y agoYes. I was half joking, half explaining why immutability actually is better to model the universe. In practice, replace Special Relativity with Network Problems.
- eloff 13y agoSo what you're saying is the universe is mapped COW, and everytime there's a new observer, UniverseOS runs it with fork().
- evanspa 13y agoCheck out the first 20 minutes or so of this SICP lecture. In it, Abelson specifically mentions special relativity as a way for us humans to "model" the real world as immutable values over the continuum of time (in contrast to a mutable world that fits with OO). http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/6a-streams-part-1/ http://ocw.mit.edu/courses/electrical-engineering-and-comput...
- dustingetz 13y agoImmutable doesn't mean unchanging. It means no mutation. I can throw a ball in the air and model it as a function of time without mutation.
- deleted 13y ago[deleted]
- w0utert 13y ago>> In the real world, everything is a process. Nothing ever stays the same or stands still. No object is the same object from one millisecond to the next. Been reading up on Heraclitus lately? While this is an interesting statement for a philosophical dialogue, it doesn't really make much sense in the context of programming, where many things are constant, many things are not processes, and there are plenty of use cases for both mutable and immutable state (which is exactly why I always get really defensive reading articles like this one, that pretend all problem domains would be best modelled by a single programming language/paradigm/model of computation).
- Mikera 13y agoIt makes a lot of sense in the context of programming when you look at the big picture. I think Rich Hickey articulates it best: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey http://www.infoq.com/presentations/Value-Identity-State-Rich...
- collyw 13y ago"OOP actually doesn't model the real world well at all." Surely that is in part due to the developer. Poor developers will choose the wrong abstractions, and have a poor OOP model as a result. Better developers will choose the correct abstractions, and have better models. Obviously the domain you are modeling will make it easier or harder to model things, and in some cases OPP may not be a good choice at all. In my day to day work I use Django. I start with a data model - based on an ER diagram. I code that in the Django model classes. Is that OOP modeling or ER modeling? I don't know. I don't really care too much. It works fairly well for most things I am doing.
- hcarvalhoalves 13y ago> OOP actually doesn't model the real world well at all. It seems to on the surface, but it completely ignores time. This is important, and something almost everybody ignores. Get an OO codebase, and try to implement a time-dependent feature, like snapshots, or even a simple undo. The abstractions fall apart.
- mrkhwrd3 13y agoA criminal tells the arresting police officer: - You're wrong, officer. It was yesterday-me who committed the crime but you are trying to arrest now-me. How wrong are you! I bet the authorities around the world don't like your time-inclusive-dimenstion view much.
- matjazmuhic 13y agoYou do realize that there's a difference between an object with identity (ddd names it entity) and the one without it (ddd names it value object). No matter what you do, identity does not change. You commiting a crime yesterday was an event that included you as an object with identity and today you have the same identtiy so you are clearly responsible for what you did yesterday. GUARDS! :P
- homami 13y agoWe can think the state of the world is immutable. When the state changes, it's a different world. If space-time is discontinuous, then we can think any change of state, like motion, as a set of discrete changes. If we think the motion of a particle from one energy bin to another is immediate (meaning the particle cannot be found on the border between the bins, or one moment the particle is in Bin A, next it is in Bin B) then we can think the particle was destroyed in Bin A and another one was created at Bin B. And this is what we call motion from A -> B.