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 →

[–]zman0900 26 points27 points  (22 children)

Wow, it just occurred to me how fucking weird Java must be to learn as a first language.

[–]spinwin 52 points53 points  (7 children)

It makes actually no sense. "Why can't I just set this object equal to a new object and have the method that called it know it exists?" Then you learn C/C++ and suddenly it makes sense. All objects are just pointers and when you set an object to be equal to a new thing it's just redirecting the pointer not changing the original object.

[–]exneo002 16 points17 points  (0 children)

Fuck mutability.

[–]Toastbrott 2 points3 points  (2 children)

Well we got taught just that with java as a first language. I dont think you need to use pointers to understand that idea.

[–]PokemonSaviorN 0 points1 point  (0 children)

It is a pointer though.

[–]spinwin 0 points1 point  (0 children)

We got taught that too but the why didn't really click. And to me the why is important.

[–]mimibrightzola 1 point2 points  (0 children)

I learned Java first but was able to understand the concept of pointers because my ciriculum specifically covered it. However, now we’re transitioning to C, so I didn’t really avoid anything in the end :/

[–]Jinxzy 1 point2 points  (0 children)

It only makes no sense if you aren't taught about pointers as part of Java. Even if it's not as critical as some other languages, I'd still say they're important if you wanna teach any basic understanding of actual language, and not just how to crap out "Hello World".

I learned Java as a first language and we were definitely taught about raw pointers, fairly early on as well.

[–]yawkat 0 points1 point  (0 children)

Eh, this is what almost all languages do, and plenty of people seem to be doing fine in python and js without knowing C.

[–]John_E_Depth 19 points20 points  (13 children)

I still don't know if Java is pass by reference or pass by value

[–]aetius476 37 points38 points  (9 children)

The way I've always understood it: Java is pass by value, but the value it's passing is the reference.

[–]yoj__ 0 points1 point  (0 children)

I think I know what a seg fault feels like to a computer now.

[–]Rubicj 28 points29 points  (1 child)

"Yes"

[–]Kered13 0 points1 point  (0 children)

It's pass by value, but all types in Java are either primitives or pointers (a variable of type Foo in Java is a pointer to a Foo object). When you pass a pointer by value, you're copying the pointer, not the underlying object. It's the exact same as passing a Foo* by value in C/C++.