News for hackers. Stuff that matters.
Re:How Class-based Programming Sucks (2011) by danenania on Friday December 13, 2013 @07:19AM (#6900159)
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.

Re:How Class-based Programming Sucks (2011) by arethuza on Friday December 13, 2013 @07:24AM (#6900172)
"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.

Re:How Class-based Programming Sucks (2011) by wcummings on Friday December 13, 2013 @11:22PM (#6904600)
I 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."
Re:How Class-based Programming Sucks (2011) by w0utert on Friday December 13, 2013 @08:52AM (#6900441)
>> 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).

Re:How Class-based Programming Sucks (2011) by Mikera on Friday December 20, 2013 @10:23AM (#6941774)
It 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...
Re:How Class-based Programming Sucks (2011) by theseoafs on Friday December 13, 2013 @07:24AM (#6900174)
I'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?
Re:How Class-based Programming Sucks (2011) by tomp on Friday December 13, 2013 @07:33AM (#6900192)
Yes. 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.
Re:How Class-based Programming Sucks (2011) by pmahoney on Friday December 13, 2013 @08:35AM (#6900371)
Most 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?

Re:How Class-based Programming Sucks (2011) by tomp on Friday December 13, 2013 @09:17AM (#6900544)
Yes. I was half joking, half explaining why immutability actually is better to model the universe.

In practice, replace Special Relativity with Network Problems.

Re:How Class-based Programming Sucks (2011) by eloff on Friday December 13, 2013 @09:32AM (#6900623)
So what you're saying is the universe is mapped COW, and everytime there's a new observer, UniverseOS runs it with fork().
Re:How Class-based Programming Sucks (2011) by evanspa on Friday December 13, 2013 @09:21AM (#6900562)
Check 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-comput...

Re:How Class-based Programming Sucks (2011) by SamReidHughes on Friday December 13, 2013 @07:28AM (#6900182)
No need to apologize. With immutability you have to explicitly model temporal changes.
Re:How Class-based Programming Sucks (2011) by dustingetz on Friday December 13, 2013 @05:44PM (#6903324)
Immutable 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.
Re:How Class-based Programming Sucks (2011) by hcarvalhoalves on Friday December 13, 2013 @04:39PM (#6903059)
> 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.

Re:How Class-based Programming Sucks (2011) by collyw on Friday December 13, 2013 @09:59AM (#6900771)
"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.

Re:How Class-based Programming Sucks (2011) by homami on Saturday December 14, 2013 @12:27AM (#6904750)
We 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.

Re:How Class-based Programming Sucks (2011) by mrkhwrd3 on Friday December 13, 2013 @06:58PM (#6903634)
A 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.

Re:How Class-based Programming Sucks (2011) by matjazmuhic on Saturday December 14, 2013 @07:32AM (#6905519)
You 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