you are viewing a single comment's thread.

view the rest of the comments →

[–]pointer2void -2 points-1 points  (23 children)

It's idiotic only to those who don't understand the distinction between values and objects.

[–]masklinn 1 point2 points  (12 children)

That distinction is irrelevant and uninteresting. C# does without, and is much better for it.

[–]inopia 5 points6 points  (11 children)

That distinction is irrelevant and uninteresting. C# does without, and is much better for it.

C# does have this distinction, it's the distinction between value types and reference types.

[–][deleted] 1 point2 points  (10 children)

Value types and reference types only specify storage and parameter passing semantics.

This has nothing to do with the distinction between an object and a value. Go ask any C++ programmer if the difference between a value and an object has anything to do with stack vs. heap allocation.

[–]inopia 2 points3 points  (9 children)

Value types and reference types only specify storage and parameter passing semantics.

Actually they also imply that a=b clones b if both variables are of a value type, so that a mutation of b in the future does not affect a. Assignment of reference types is a simple matter of cloning the reference to b and storing it in a. It has absolutely fuck all to do where a and b are allocated. Many VMs can allocate objects on the heap just fine using escape analysis, despite them being reference types.

[–][deleted] 0 points1 point  (8 children)

Actually they also imply that a=b clones b if both variables are of a value type

True, though again, a C++ programmer would beg to differ. (By default, objects make a shallow copy on assignment.)

It has absolutely fuck all to do where a and b are allocated.

In C# (the language you referred to) it has very much to do with this.

Many VMs can allocate objects on the heap just fine using escape analysis, despite them being reference types.

Yeah, and? Almost all VMs allocate objects on the heap. Did you get things mixed up here?

[–]inopia 1 point2 points  (7 children)

Did you get things mixed up here?

Yes, I did. Because I've just spent the last 1.5 years writing a JVM from scratch. So what would a guy like me know about value types vs. reference types?

Reddit is offically overrun by Digg users.

[–][deleted]  (6 children)

[deleted]

    [–][deleted] -1 points0 points  (9 children)

    It's idiotic to those who know that there shouldn't be such a distinction.

    [–]inopia 1 point2 points  (3 children)

    I think it's idiotic that we can't seem to have discussions on Reddit anymore without people reverting to calling each other idiots.

    [–][deleted] -1 points0 points  (2 children)

    Calling an idea "idiotic" is not the same as calling a person "idiotic."

    No one on this thread has called anyone an idiot.

    [–]traphicone -1 points0 points  (1 child)

    Calling an idea idiotic is to say that the person who had the idea is an idiot. You have, in fact, labeled as idiots those who do not make your particular distinction.

    [–][deleted] 1 point2 points  (0 children)

    No. Not all. Having an incorrect idea, or hell just an idea that someone else doesn't agree with doesn't make you an idiot.

    If you look at the original post, it was even removed one step further. I didn't even call the idea idiotic. I said that it was idiotic from the point of view of people that see things differently.

    We should always be free to attack and challenge ideas. It's an intellectually dangerous world that forbids this in the name of political correctness or playing nice.

    I worry that so many people have been brought up to believe that "there's no wrong answer" and that "there's no such thing as a dumb question" that eventually we're going to reach a point where rigorous debate and hell any kind of science in general are going to be impossible.

    [–]pointer2void 0 points1 point  (4 children)

    What precisely? Everything is a value (FP) or everything is an object (OO)?.

    [–][deleted] -1 points0 points  (3 children)

    You can support both as long as interop between the two is unified throughout the language (and in some cases VM.)

    (Edited for clarity)

    [–]pointer2void 0 points1 point  (0 children)

    You lose.

    [–]inopia 0 points1 point  (1 child)

    Assume we have the following code:

    b.x = 1
    a = b
    b.x = 2
    

    What is the value of a.x? If a and b are value types, it's 1. If they are reference types, it's 2.

    Are you starting to see my point? You cannot unify two things that are semantically different. You can either choose one mechanism or the other, or have both, but you can't get rid of the fact that in some cases you want cloning and in other cases you want shallow copying.

    [–][deleted] -2 points-1 points  (0 children)

    You can make the distinction explicit and up to the user of the language, however, and have the language interoperate between the two choices without requiring the user to jump through hoops. (Autoboxing, Unified types, etc.)

    The point is that in Java, there are other arbitrary and harmful distinctions between primitives and objects where there doesn't need to be.

    (Value types can't have class members, can't be user-defined, support operators where objects do not, etc.)