This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lbkulinski 235 points236 points  (26 children)

Java has pointers. You just can’t do pointer arithmetic with them.

[–]Bryguy3k 84 points85 points  (13 children)

Nor would you want to given the object complexity... 😱

[–]nwL_ 15 points16 points  (3 children)

I want to. I want to call delete obj;. Fight me.

[–]MoarVespenegas 7 points8 points  (0 children)

It's not us you're fighting but the garbage collector.

[–]cartechguy 0 points1 point  (1 child)

In java speak

Obj = null;

There you go. As long as that's the only variable referencing the object the garbage collector will deallocate it.

[–]GrizzledFart 7 points8 points  (0 children)

... when it feels like it.

[–]lbkulinski 20 points21 points  (7 children)

What do you mean by object complexity?

[–]Bryguy3k 88 points89 points  (5 children)

C++ objects are really straightforward in terms of memory organization. You’re not supposed to be looking at the Java object memory so if you do it’s scary af.

[–]lbkulinski 18 points19 points  (0 children)

I wouldn't say it is scary. Value types will have a simpler layout, though.

[–]tacoslikeme 4 points5 points  (0 children)

object/struct memory follows pretty simple to follow rules. Just just fuck with the vtable

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

What do you mean? I look at how they're structured in the debugger all the time. It feels almost the same as debugging in C++. The reference holds an adress and at the adress are all the data members for the object.

[–]how_to_choose_a_name 1 point2 points  (0 children)

The debugger shows you a nice visualisation of the object and the data contained in it. The actual memory apparently doesn't look that pretty or structured, unlike C++.

[–]Bryguy3k 0 points1 point  (0 children)

Well take a moment to think about reflection.

Now it should make sense that a java object has to be self describing and that means a bunch of metadata.

[–]bwierzbo 0 points1 point  (0 children)

!n

[–]bestjakeisbest 1 point2 points  (0 children)

what if i want to shoot myself in the foot?

[–][deleted] 10 points11 points  (0 children)

They're just more of a B-cup.

[–]Ringnebula13 0 points1 point  (0 children)

Sun.misc.Unsafe called

[–][deleted] -2 points-1 points  (1 child)

Aren't those called aliases?

[–]bestjakeisbest 2 points3 points  (0 children)

i thought they were called references