« first day (1795 days earlier)      last day (3140 days later) » 
06:00 - 21:0021:00 - 00:00

9:33 PM
Is the difference between a reference and a pointer, that a pointer is an actual memory location, and a reference is an ID of an object?
 
oh man, just moving that crashes my tab
that's how dangerous it is
 
@barlop that's a fairly loaded question. The differences are many and subtle, and vary by language and implementation
at a high level SEMANTIC POV:a pointer is just that. it points to SOMETHING in mem
it can point to a variable, it can point to a function, it can point to an object, it can point to another pointer
a REFERENCE, while similar, generally is a type of pointer that points to a variable and cannot be reassigned
 
I figured references in java point to objects only. Can you give me an example of a reference in java, that doesn't point to an object?
 
all java variables are passing by values, no references
 
err, so can you give me an example of a reference in java?
 
9:45 PM
There are references that do not point to an object: any reference that is null
 
int p = 1;
that points to a primitive, not an object
 
@Kylar I said a reference that doesn't point to an object, and you gave me int which is a primitive type.
so that is not an example
@kiheru good example
 
a primitive type is not an object.
 
@Kylar nobody ever said it was
 
If you were to use Unsafe, find the memory location of the reference and go look there, you would see the value, not an object
and in your view, what would a reference point to that is not an object? give me an example.
 
9:48 PM
@kiheru is there a distinction between object reference, and the variable that has it?
 
@barlop yes, because all variables stores values, not references
 
@Kylar I can't give an example, I just asked, and I suppose there isn't one.. though maybe as kiheru says. null
 
in Java
 
String a=new String("abc"); so 'a' stores a value not an object reference?
 
A variable can have a value that is a reference
 
9:50 PM
yeah I thought so
 
yep
 
i'd have thought a was storing a value,
and the value is an object reference
@Unihedron then why did you say values, not references, (as if references were not values), when you agree that references are values?
 
@barlop Because references are not values, but values can be references.
Also, I'm not agreeing to anything, I'm just stating.
 
if a value can be a reference, then how can that reference not be a value?
 
fge
@barlop again with that years old problem?
Look at C++ and see what pass by reference really means
 
9:52 PM
@barlop By definition.
 
I am not talking about pass by reference!!!
I know what pass by reference means. I used it even in Pascal.
 
fge
Then what is your problem?
Why are you trying to unearth a zombie with not even enough flesh on it to make a boxer?
 
well fge, if you start using analogies then I don't know how to explain it. But the chat shows what I was questioning.
 
@barlop to answer your specific question about : String a=new String("abc"); so 'a' stores a value not an object reference?
a stores a reference to a String object, not a value. String is not a primitive.
 
well, i'd think 'a' stores an object reference, and that object reference is a value.
 
fge
9:54 PM
Yet a is still a value on the stack to a method call
 
value doesn't have to mean primitive, does it?
 
fge
The method has no way to modify a at all
It can just call methods on a
That's what I thought
You unearth a zombie
 
I brought up something i'm not clear on and you don't like it so you call it a zombie
 
Yes, he's cranky sometimes.
 
fge
No, it's not that I don't "like" it
It's that you have still not understood what pass by reference really means
Java is pass by value
 
9:56 PM
I am not talking about methods
 
fge
And it is pass by value ONLY
 
^^^
Did you read that I am not talking about methods
I am not talking about parameters to functions. OK?
 
@barlop You won't get anywhere arguing with him. Keep asking about what you don't understand and the rest of us will try to help you :)
 
Thanks
it's just a bit distracting
 
He's often quite helpful. Continue.
 
fge
9:57 PM
OK, so with this out of the way, what isn't clear with the fact that a is just an "object reference"?
 
Try to explain what you don't understand as best you can, and keep asking.
 
fge
In Java, anything which is not a primitive is either an Object or a subtype of it
 
So kyler, you said "a stores a reference to a String object, not a value. String is not a primitive." That seems to imply that you think value implies primitive
but can't value include object references?
 
So in Java (since that's where we are, I assume that's what you're talking about) - there are two types of references.
 
fge
Unlike what happens with C or C++, you can't have a "pointer to int", if that's what you mean
 
9:58 PM
and a very clear demarcation point
ONE type of reference is for a primitive value
the other type is always a class or object reference
 
Can you define reference?
 
which is much akin to a pointer in C, although not strictly the same
 
fge
You define it
 
and can I see an example of a reference to a primitive value
 
int i = 1;
that is a reference to a primitive value
 
9:59 PM
I have never in my life seen int i, referred to as a reference
 
Java considers it such.
 
can you point to a proof of that?
 
fge
@Kylar that is a confusing way of presenting it to be honest
 
then String s = new String("abcd");
 
fge
It's just a variable
 
10:00 PM
kyle, Is it anywhere in the java language specification that it uses that terminology of int i, i being a reference to a primitive?
 
fge
I believe the fundamental problem here is the confusion between what a variables refers to and the usual definition of a "reference", the latter implying some sort of indirection
 
kyle, thanks by the way!
 
@barlop no, because it's wrong
 
Ok, let's start at the beginning
with jls language
and not the same things we've been throwing around
in Java you can declare variables
int i;
Object q;
 
@Kylar (which are wrong)
 
10:04 PM
Person p;
@Unihedron that's why I'm going to the gold standard
Nomenclature is fucked up
 
thanks, I can finally stop cringing
 
int i = 1; //this is a variable that points to a value in memory
 
fge
Erm no
 
sigh
/me waits for fge
Go ahead then
 
fge
The difference is simple enough; consider the byte code
If you declare Foo x = new Foo(), what happens is that you invokestatic a constructor
That, in turn, allocates a place onto the heap
This is the ONLY WAY by which Java "allocates memory"
In C, however, this is not the case
If you do some_struct foo = /* struct initialization here */, then this goes onto the stack
Whereas if you do some_struct *foo, then foo is onto the stack but the result of foo = malloc(sizeof(some_struct)) is onto the heap
 
10:09 PM
kylar.. ok I agree so far
 
fge
With Java, you can't do that
 
I got disconnected for a moment
My q is this.. Is an object reference, a value?
and thus, a value, can be an object reference.
 
@fge focus on being simple. You're going way off into complex land again
 
(well, escape analysis may allow allocating some things in the stack, or skip allocation altogether, but I should not confuse things more)
 
@Unihedron said "references are not values, but values can be references." <-- that makes no sense to me at all
 
fge
10:10 PM
@barlop in Java, or in anything JVM based, the answer really is: you don't care
They are there for you to use, just use them
 
@barlop Under the hood, it's likely that an Object reference is just a value. It contains information that allows the running vm to point to an object. Practically, in Java you shouldn't think of it that way.
Java abstracts all that away so you don't know.
 
@barlop then your sense must be really messed up
 
fge
@Kylar s,know,have to &,
 
$0?
 
@Unihedron well then can you give an exmaple that demonstrates what you're saying
 
10:12 PM
It's possible and even likely that an object reference is stored at some point as a value. But it's at a level that you should never ever see in Java.
 
fge
@Unihedron & works with sed
(and others)
 
vi uses sed?
 
@Kylar i'm sure i've seen something like obj@2342432
 
fge
If you talk about the vim regex engine, it understands &, yes
 
gr8
 
10:12 PM
@barlop Yes, you definitely have.
That's not a reference calue.
if you take any Object in java and print it out
 
fge
@barlop that's Object's .toString() representation, see javadoc about System.identityHashCode()
 
what happens is we call a method on that object: toString()
which defaults to printing the object's class and hashCode
 
well, toString often makes objects look pretty.. like a="abc"; System.out.print(a); will print "abc" not obj@345353
 
fge
@barlop because .toString() has been redefined! Look at the javadoc of Object
 
Yes, but that means that the programmer must have implemented a different toString() method.
 
10:14 PM
ok so when it hasn't been redefined it prints obj@4453543
 
Yes!
 
fge
Yes indeed
 
so, would I see an object reference value with this thing called "unsafe"?
 
I would strongly suggest you do not mess with Unsafe
 
fge
The number you see in such a representation is pretty much meaningless
 
10:15 PM
nope, you'll still see a value
 
until you've got 10K hours of java under your belt.
 
representing a reference
 
fge
It is certainly not the result of C's %p format if that's what you mean
 
ok so obj@435434353 is a value representing a reference?
 
fge
Don't even try to make sense out of that number; with anything JVM based, that is only a waste of time
No, it's just the default .toString() implementation
 
10:17 PM
so has anybody here ever seen a value representing a reference?
 
fge
And if you look at the javadoc of .toString() it doesn't even represent anything pertaining to memory at all
Because the default .toString() of object is .getClass() + '@' + System.identityHashcode(this)
That is all it is
 
well, Java talks about references, I didn't say reference pertains to memory
 
@barlop that question makes no sense in Java.
 
fge
And the number you see is the result of System.identityHashcode()
 
@barlop no it's a printed object
 
10:18 PM
A value representing a reference only has meaning in languages like C
 
@barlop I have, and you don't need it, so don't seek it
Fools rush to where angels fear to tread.
6
keep it on the moral wall for two weeks please.
 
OK so only unihedron has seen a value representing a reference then?
 
sigh
I've seen them lots. Why does it matter if someone has seen it?
 
fge
Why do you keep trying to shoehorn concepts which may make sense in C into Java when they don't?
 
well, i'd be interested in a java statement that prints it, if there is one
 
10:20 PM
THERE ISN'T
 
fge
You can't, and you don't want to
That's not the point of JVM based languages
 
I'm out.
 
fge, why are you saying that they don't make sense in java, but you don't disagree with anybody like unihedron who says he has seen it.
 
@fge I'm about to become the cranky one.
@barlop First learn walk, then learn fly.
 
@Kylar but I'm leaving, so there's freed up quota for good people
 
10:20 PM
@Unihedron Have a good one. TTY soon!
 
fge
@barlop did Uni ever say he saw such things in Java?
 
TTYS :)
 
@barlop you're focusing on a concept that makes NO SENSE in java
 
It seemed like that was what he was saying, yes
 
fge
In Java, which is a JVM based language, forget about that concept at all
 
10:21 PM
It's like saying "Why can't I peel tofu? I can peel a banana!"
 
Fine, just that people are talking about the value representing a reference
 
"They're both foods! Has anyone here ever peeled anything?"
 
and if nobody challenges those that say a value represents a reference, I was assuming that they can exist in java.
Clearly they can't. Fine.
 
fge
Heh
That is exactly what I said earlier
Yet again that zombie problem
 
Well how am I meant to know who to believe
 
fge
10:24 PM
People try and explain the difference between pass by value and pass by reference by the concept of "values representing references" -- which is definitely the WRONG WAY to explain pass by reference
 
well, the term "pass by value" isn't a great term..
and anyhow, i'm not talking about pass by value and pass by reference, as I said.
 
fge
It is, when you truly understand what it really means
 
And anyhow, an address can be a value.
 
fge
Sure, and that is where the explanation begins
 
but yes I do understand what those terms mean.
And i'm not talking about functions and parameters so I don't understand why you keep bringing it up
 
fge
10:26 PM
Because that whole fallacy of a concept of "value representing a reference" has been brought up by people unable to explain correctly the difference between pass by value/reference; that is why
 
I was just quoting somebody else HERE that said it (that nobody challenged), and I was pushing them for what they meant
 
fge
The only thing which exists at the programmer level is a variable, and what that variable can represent depends only on the mechanisms available to the programming language
 
if you'd see the chat log you'd have seen why I even used that expression/term
it was purely quoting somebody else that had used it and his statement had gone unchallenged.
 
fge
Well, nobody is on this chat 24 hours a day :p I have a job, and a quite busy one at that :p
 
What I was asking originally, was this. What(in Java) is the difference between a reference and a pointer? (besides perhaps the fact that pointer is an actual memory location and a reference is not, since java has a VM)
 
10:29 PM
THERE IS NO REFERENCES OR POINTERS IN JAVA
GET OVER IT
 
@Vogel612 try grepping the JLS, or are you trolling? I think you are trolling. Because if you grep the JLS you'd see references exist.
 
I'm the guy with the italics username and you're running against the same wall again and again and again
and I'm gettting fed up
so if you want to mess with me, I suggest you don't
Java doesn't work as that
and Java != JVM
GET OVER IT
now if you got a question which is not about references or pointers in java (which don't exist), ask it.
but don't waste peoples time and effort by asking the same nonsensical question comparing tofu to bananas
 
@Vogel612 Hola! And now I want a banana.
;)
 
~hands kylar a banana
 
Mmmmm. I'm a happy monkey.
 
10:33 PM
shouldn't that "peoples" have an apostrophy??...
 
@barlop if you want to know the difference between a ref and pointer in C, read this:
1277
Q: What are the differences between a pointer variable and a reference variable in C++?

prakashI know references are syntactic sugar, so code is easier to read and write. But what are the differences? Summary from answers and links below: A pointer can be re-assigned any number of times while a reference can not be re-seated after binding. Pointers can point nowhere (NULL), whereas ...

/s/c/c++/
And we're done.
/me drops the mic
 
fge
C++ is a beast
 
Dropping a note for @Unihedron ... I'm free for the next two weeks to get some shit done for JCE. Feel free to open up the repo on bitbucket for me: bitbucket.org/vogel612
 
What a language allows doing with variables of reference/pointer type depends on the language, so not all of those are relevant to java (null references are allowed, and variables of reference type can be reassigned, for instance)
 
4 mins ago, by Kylar
And we're done.
 
fge
10:38 PM
@barlop there is no such thing as a pointer in Java, and that's about the end of it; that is, if you have a variable i, you can't do &i or *i like you can in C or C++
Whether that variable i is of a primitive type or anything Object
 
This has officially become my 4th circle of hell. Right above the "unending Coldplay on repeat" circle, but right below the "stuck on the It's a Small World" ride forever.
 
@fge also needs a reminder that the discussion is finished?
 
fge
Java classical mistake #n: thinking that Runtime.exec() runs an interpreter
@Vogel612 I wish it were; this is a neverending topic, and nothing CS really clarifies the whole landscape
But yeah, it's over as far as I'm concerned
 
let's say it's finished for now and we'll put that on the hangout topics list?
 
fge
Not from me; my language landscape is too narrow for that
(and by the way I still need to do JSR 203)
That Runtime.exec() stuff too needs a hangout
 
10:44 PM
do we have a list of hangout topics?
 
fge
Not to my knowledge
 
Eh I don't care. I'll head to bed.
 
Isn't somebody with 2K rep, bossing around somebody with 50K rep, the tail wagging the dog?
 
need to work tomorrow for a change :D
@barlop depends... but if you really want to play the rep game, come to code review and we play again
also ... I have an italics username. Rep isn't relevant
on a related note: rep says nothing about actual knowledge
on another related note: Today I went bossing around a 94k rep user, so your argument is invalid anyways.
 
well, you're bossing around people with italic usernames as well
and reps 25* yours
 
fge
10:48 PM
Rep doesn't mean anything
 
well, what is a greater display of knowledge. Rep, or owning a room?
 
neither
what is greater display of power?
 
fge
Having a job and being good at it? :p
Or at least good enough that you don't get the boot?
 
I also got into a fight with people 250* my rep.... no worries, I can hold myself up. If you want to reduce me to my rep... well your loss.
since this is yet another pointless discussion I'll go to bed though.
niters
 
<- amateur programmer. No power
 
fge
10:50 PM
sigh my job is really taxing; but fortunately I like it
 
I'm back!
@barlop Intellectual speech is a greater presentation of knowledge. Nothing else matters.
 
fge
<-- professional dev for only 6 months
(no, not even that)
 
Someone who rambles nonsense and refuses to listen to advice definitely doesn't have a great scale of knowledge to display to begin with.
 
fge
By the way, how is the HTTP/2 library going? :p
 
it's on hiatus
 
10:59 PM
I'll be wise enough not to quote you then unihedron, because it was quotes of you, that people thought were rambling nonsense
 
fge
@barlop just drop it, and if you really want to do Java there are more fundamental concepts to grab than references and pointers anyway
Just study the bytecodes, maybe that'll teach you something
 
well, I must correct one thing you said there. Java doesn't have pointers.
 
fge
And see how nothing in the bytecodes allow you to "reference" anything
Indeed it doesn't
The JVM doesn't have pointers
Therefore Java doesn't have them
 
@barlop From the moment the invaders arrived, breathed our air, ate and drank, they were doomed.
 
fge
@Unihedron a pity you didn't follow on my offer, you'd have fun with the language itself, I assure you
I discovered... Stuff
And that makes the parsing all the more tricky :p
 
11:03 PM
that's fascinating
I discovered... Not actual stuff
 
fge
This is a language where when you write "if x do something", it doesn't have the same effect than when you write "if x <newline here> do something"
....
 
O.o
 
JS has that "feature" too
 
I'm not exactly sure how that's "fun"
 
fge
@kiheru eh?
 
11:05 PM
It's a recipe for surefire headache...
 
fge
@Unihedron now imagine when you have to parse the stuff
Which is why a SonarQube plugin is so useful for the language!
 
omg
don't put those words together
 
fge
This kind of mishap I can detect and warn after
 
Soo.. @Unihedron how about JCE now?
 
@Vogel612 Sure thing
 
fge
11:06 PM
@Vogel612 weren't you supposed to go to sleep?
 
But it's kind of a bad timing though, since I have to head out in ten minutes and I'm not sure if I'm quick enough for setting it up
like now
 
Bed actually.
Which is where I am. Now I'm going to sleep.
After telling Uni:
 
Sleep tight!
 
You only need to add me to the write access group on the repo. If sich a thing exists.
Such*
~drops his head and starts snoring loudly
 
fge
<-- learned today about "stable sorting" algorithms
 
11:10 PM
O~o
 
fge
And by the way, in other news, the "bug" I spotted with parallel streams really was considered a bug after all...
 
aha!
 
fge
Since 8u60, .forEach() now will not remove the ORDERED characteristic of a Spliterator if it is ORDERED to begin with; as a result, .skip() will work "as expected" in this case
 
@Cerbrus I don't understand... it just the Friday song.... ???
 
06:00 - 21:0021:00 - 00:00

« first day (1795 days earlier)      last day (3140 days later) »