News for hackers. Stuff that matters.
Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @01:41AM (#14235785)
A definition of objects that rules out immutable objects doesn't seem viable to me.

Furthermore, your definition merely requires mutability, which is a feature of Java and C++ objects, so I'm not sure what you think is lacking. Your definition reduces to "objects undergo state transitions".

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @02:21AM (#14235915)
Objects require at least an identity. Immutable data structures necessarily don't have identity (well, to say identity isn't meaningful because aliases can simply be seen as copies). There is more to it than identity, and you can always use a mutable variable or rebound parameter to recreate an identity for an immutable object (I.e. the world as an input and output).
Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @10:30AM (#14237676)
I disagree. Encapsulation is the only universal property of object oriented abstraction (see Will Cook's papers on OO vs ADTs).

Identity is merely a property of some objects, not all objects.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @11:20AM (#14238204)
I disagree with that and that particular paper. We must think of objects from a design perspective, not a technical one, and the one thing that distinguishes objects is their ability to be "things" rather than just constructs.

42 is not an object because the value can reproduced easily. John Smith, on the other hand, is not just a value, but has a name and an identity, is not exactly the same person everyday, and so on. 42 can be used in equational reasoning (it never lies) while John Smith cannot. John Smith, on the other hand, can be attributed with semi-autonomous behavior while such notion isn't meaningful for 42.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @11:25AM (#14238259)
> We must think of objects from a design perspective, not a technical one

Why? Why should objects exclusively get this distinction when every other programming language paradigm is analyzed technically?

> 42 is not an object because the value can reproduced easily.

So?

What's the point of making "object" synonymous with "identity" when we already have the term "identity" to designate the relevant property?

Survey a bunch of programmers and ask if they agree with the phrase "objects respond to messages, and the only way to interact with an object is to send it messages". I'd wager a majority would agree with this statement. Which means procedural abstraction/encapsulation, wherein no details about object internals can leak to clients, is the only meaningful property of objects. 42 can then take on many representations, as long as they all respond to the same messages.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @12:09PM (#14238755)
> Why? Why should objects exclusively get this distinction when every other programming language paradigm is analyzed technically?

Who is analyzing? I definitely don't analyze other paradigms technically. You should know me better than that. I'd rather all paradigms be analyzed based on how they are used to write programs and how they influence program designs. The technical details are just details.

> What's the point of making "object" synonymous with "identity" when we already have the term "identity" to designate the relevant property?

Again, it is how you design your programs: are you relying heavily on equational reasoning, or have you divided things into a bunch of nouns with behavior.

> "objects respond to messages, and the only way to interact with an object is to send it messages".

They might indeed, but it is a vacuous statement to begin with. It is extremely sad how little design is considered in programming languages. That an entire paradigm could be boiled down to such a true but useless statement.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @12:28PM (#14238952)
> I definitely don't analyze other paradigms technically. You should know me better than that. I'd rather all paradigms be analyzed based on how they are used to write programs and how they influence program designs. The technical details are just details.

The technical details define how programs are structured. I don't see how you can separate these questions if that's what you mean by "design".

> Again, it is how you design your programs: are you relying heavily on equational reasoning, or have you divided things into a bunch of nouns with behavior.

Sure, but this doesn't preclude immutable objects from being used in subprograms that don't depend on state transitions. For instance, object factories may or may not be immutable, but if they are, they're suddenly not objects anymore? That distinction seems pointless.

> They might indeed, but it is a vacuous statement to begin with.

I agree that many people might take virtually anything to be a message, but when you try to specify with technical precision what that phrase actually entails, you get meaningful constraints, and I think Cook did a pretty good job distilling those properties.

For instance, "the only way to interact with an object is to send messages" means that no information can be revealed than what the object volunteers, ie. encapsulation, and this voluntary disclosure can't be captured statically to enforce stronger properties as with ADTs.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @12:44PM (#14239120)
Design is like what does my program look like when I use X vs. what does it look like when I use Y? What are the implications of those two choices? I see objects and functions are pure design abstractions: you can easily emulate one or the other in a language that doesn't provide them as first class constructs, and even when they are provided as first class constructs, you can always use them in ways that are poor for the designs they support.

That "objects communicate via messages" leads to absurdities like numbers being considered as objects. It is completely blind to their benefits and drawbacks as anthropomorphic entities.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @01:03PM (#14239296)
> That "objects communicate via messages" leads to absurdities like numbers being considered as objects.

It's only absurd if you're implicitly ascribing properties to objects that haven't been explicitly justified.

It seems perfectly reasonable to me that numbers would be objects, because numbers have a multitude of representations, all of which we'd like to be interchangeable. For instance, machine registers vs. arbitrary precision numbers. With ADTs, we'd have to explicitly define overloads for addition that handle the various permutations of parameters for addition of various number types, but a Cook-like object language wouldn't need this at all. Any representation of a number would be interoperable with any other implementation, automatically. That's neither vacuous or absurd, and these properties follow directly from taking that phrase describing objects to its logical conclusion.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @02:30PM (#14240159)
When we come down to this, it is clear we just have very different of what objects are or are supposed to be. Interoperability (polymorphism) is at the center of the definition that you are using, and it is nowhere near as important in my definition of object, where polymorphism is possible with values and not related to their objecthood (it is a technical detail in how values can be made polymorphic).

We are talking past each other because we don't possess compatible meanings of the word object.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @03:49PM (#14240859)
I don't think we're talking past each other, as I think we both understand the differences in each of our definitions, ie. I understand you think identity is central but I disagree, and you understand that I think procedural abstraction is central, but you disagree.

Where we differ is which definition ought to deserve the label "object", in the pure sense the way we have a definition for "function".

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @04:17PM (#14241131)
Even function has a definition in the philosophical sense unrelated to even the technical details of the lambda calculus. Especially when the function is pure and/or continuous, these are really useful distinctions in a design vs. using a bare bones definition that talks about a function being a pointer to some code.
Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @06:11PM (#14242179)
> Even function has a definition in the philosophical sense unrelated to even the technical details of the lambda calculus.

Agreed, "function" has many concrete definitions, but arguably, there is some essence of what it means to be a function that we see reflected in each instance, and so virtually all of them are interconvertible in some real sense.

For "object", I see this essence as procedural abstraction. Every discussion of objects features access to data mediated by arbitrary code, which is how they implement behaviour. Object factories and numerical abstractions (fixed, rings, arbitrary precision, etc.) simply don't fit into your narrative of objects, so defining objects as requiring identity is immediately refuted in my mind.

Certainly you could argue that your approach to objects is better for software construction, but I don't think that means other approaches are no longer object-oriented, in the way that we can say that C permits you to violate the essence of functions.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @09:21PM (#14243273)
I see objects as being completely unrelated to procedural abstraction, especially in its purest anthropomorphic form where objects have their own independent actuators and sensors (e.g. As in Kodu without any procedures at all, but also heavily used in etoys, scratch and of course Simula). In that case, they are just little entities (with identities of course) doing their own thing and communicating only through their environment.
Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Tuesday May 02, 2017 @11:02AM (#14246903)
Sounds like actors, not objects.
Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Tuesday May 02, 2017 @03:46PM (#14249898)
Actors are objects, of course. Do you want to ask Hewitt? :)
Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Tuesday May 02, 2017 @10:19PM (#14252505)
I think this thread is long enough! But I agree actors are objects, I just don't think all objects are actors.
Re:“A closure is a poor man’s object; an object is a poor ma... by DougBTX on Monday May 01, 2017 @12:21PM (#14238876)
It sounds like you're using "object" and "not an object" in the same way I would use "entity" and "value". I think this is Java terminology that gets used in C# sometimes too, I'm mostly thinking about NHibernate.

A value like 42 is fixed throughout time, it is always 42, and any 42 is indistinguishable from any other 42.

An entity on the other hand has an identity over time, so John Smith is always John Smith, even if he gets married and changes his name to John Brown.

Obviously it is confusing having different groups using the same words with different meanings, but that's just the way language works.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @04:18PM (#14241142)
Language is always overloaded in the object-oriented sense. In the functional programming world, definitions are defined much more precisely, but then words have much less flexibility in how they can be used.
Re:“A closure is a poor man’s object; an object is a poor ma... by ratmice on Monday May 01, 2017 @11:17AM (#14238175)
I don't really agree as well,

Modula-3 (although i'm not terribly familiar with the language) has partial revelation (a rather nuanced form of encapsulation), and branding where structural transparency does not preclude nominal identity... I tend to view the whole thing as a false dichotomy.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @11:23AM (#14238234)
I'm not sure what you're disagreeing with specifically. "Partial revelation" sounds like a feature of ADTs they mixed into objects, which all modern OO languages have done, so I'm not sure what you think is the relevance to objects specifically.
Re:“A closure is a poor man’s object; an object is a poor ma... by ratmice on Monday May 01, 2017 @11:46AM (#14238499)
I was kind of disagreeing with 2 things:

that encapsulation must be all encompassing, and that identity is not meaningful or useful for transparent immutable data...

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @11:59AM (#14238656)
> that encapsulation must be all encompassing

If we're trying to characterize "objects" in its purest sense, it must have some all-encompassing property. Mixing in other properties for pragmatic reasons doesn't seem relevant here.

> that identity is not meaningful or useful for transparent immutable data

No one claimed it wasn't useful, simply that it's not necessary to have objects.

Re:“A closure is a poor man’s object; an object is a poor ma... by ratmice on Monday May 01, 2017 @12:11PM (#14238778)
>No one claimed it wasn't useful, simply that it's not necessary to have objects.

"Immutable data structures necessarily don't have identity (well, to say identity isn't meaningful because aliases can simply be seen as copies)."

I read saying that it is necessariy for them not to have identity, and that giving them identity isn't useful or meaningful.

If it said "don't necessarily" instead of necessarily don't, I would agree

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @12:37PM (#14239051)
My point here was whether they had identities or not wasn't meaningful, since they are (well, should be) purely judged by their value.

I didn't make any value judgements about the usefulness of immutable data structures.

Re:“A closure is a poor man’s object; an object is a poor ma... by ratmice on Monday May 01, 2017 @01:32PM (#14239577)
Exactly what I thought you were saying, and disagree with.

I consider it fine to say "Objects require identity", without identity a fully encapsulated object is nothing more than an anonymous black hole.

When you turn this around to "Only objects require identity", or "identity is not meaningful for data", a hash code is one example of data which could benefit from identity, since you do not want to mix hash codes made by different hash functions. The positive integers 0,1,2... differentiated between the set of nonnegative integers are another simple

to preclude identity from data, is to preclude the ability to differentiate these on anything but the value level. surely a simplification, but by no means necessary.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @09:27PM (#14243292)
Hash functions on values don't depend on identity and collisions are accepted as part of hash's definition. A GUID (and MD 5 hashes) for all practical purposes are identities.

Identities really mess up equational reasoning which is why they are basically missing from pure functional languages like Haskell. A lot of clever solutions like FRP involve solving what are otherwise straightforward problems without resorting to the use of identity.

Re:“A closure is a poor man’s object; an object is a poor ma... by ratmice on Tuesday May 02, 2017 @01:01AM (#14244067)
Identities do not mess anything up, the commonly employed implementations of identity however do...

again check out modula-3 and more recently the paper at http://drops.dagstuhl.de/opus/volltexte/2015/5231/

Apologies I meant the identity of the hash algorithm e.g. MD5, attached to the bits produced by running the hash algorithm on an object, while hash collisions are absolutely accepted, mixing hash values produced by different hash functions is generally frowned upon.

Identity at the structural level is very much either you care about the identity, or you do not (in which case "this one"...), maybe 99.9% of the time "this one" suffices, however the takeaway from this should be that identity of structurally transparent objects should be ignorable, rather than structurally transparent objects should not have identity should one care to acknowledge it.

Re:“A closure is a poor man’s object; an object is a poor ma... by lacampbell on Monday May 01, 2017 @03:55AM (#14236169)
I don't follow why objects need an identity, as you define it. How does not having an identity make something un-objectlike?
Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @09:33AM (#14237323)
I would say identity is core to objectness. Without identity, something is purely structural, only its value is relevant because it will not transition to another state later. Objects must be things you can manipulate. They have a presence beyond their values.
Re:“A closure is a poor man’s object; an object is a poor ma... by lacampbell on Monday May 01, 2017 @05:43PM (#14241976)
I use objects that can't transition from one state to another practically every working day. It's a strange view point to me that because something is immutable, it's not really an object. But a view worth thinking about.

To me the important thing is hiding internal state and sending high level messages instead of something like "change internal field x to y". Whether that internal state you're hiding is immutable or not seems irrelevant to me.

Re:“A closure is a poor man’s object; an object is a poor ma... by seanmcdirmid on Monday May 01, 2017 @09:29PM (#14243306)
If you have a variable X that is pointing at different immutable maps over time, then X is the identity of your object that is implemented with multiple immutable maps.
Re:“A closure is a poor man’s object; an object is a poor ma... by spdionis on Monday May 01, 2017 @09:46AM (#14237393)
Because objects are supposed to hide their internal state and the actions you do with them are heavily dependent on that state. This means that an object must have an identity to be sure you're working with the right object.

If you don't have identity it means that you must know yourself what state you're working with. This defeats the definition of objects that says that their state is hidden.

Re:“A closure is a poor man’s object; an object is a poor ma... by naasking on Monday May 01, 2017 @10:33AM (#14237711)
Encapsulation is not identity. Immutable objects are still perfectly encapsulated, but they don't have identity, which is what the OP was asking about.
Re:“A closure is a poor man’s object; an object is a poor ma... by lacampbell on Monday May 01, 2017 @05:45PM (#14241997)
I do come across the view a lot that immutable objects aren't really OO. It's something I really don't understand - state that changes over time doesn't seem like a key ingredient to me at all.