Link Details

Link 56622 thumbnail
User 239112 avatar

By infonote
via dlweinreb.wordpress.com
Published: Dec 11 2007 / 05:42

At Object Design, I developed code in Java for over ten years, and I worked with Java more at BEA.
  • 12
  • 18
  • 1977
  • 961

Comments

Add your comment
User 261602 avatar

rjminniear replied ago:

1 votes Vote down Vote up Reply

Some of these are good, although the statement that Java is uses pass-by-reference for object types is incorrect. Java always uses pass-by-value.

User 254602 avatar

Nick Brown replied ago:

0 votes Vote down Vote up Reply

Technically yes, except "object types" are always references, so it is effectively pass-by-reference.

User 236075 avatar

henk replied ago:

1 votes Vote down Vote up Reply

No, that's incorrect. One important property of pass-by-reference is that after passing the 'variable' to another context, this other context can change what the original 'variable' holds. In Java the variable holds a reference and the reference points to an object. You can definitely change the object being pointed too, but you can NOT change what the original variable holds.

That makes it just "passing a reference by value". It's true that the term 'reference' is confusing here. It may sounds better if you just say a pointer is passed by value.

E.g.

Foo foo1 = new Foo();
Foo foo2 = foo1;
func ( foo );

// always true, func can never change what foo1 was pointing too.
assert ( foo1 == foo2);

User 254602 avatar

Nick Brown replied ago:

0 votes Vote down Vote up Reply

Yes, I am fully aware of that. Thats why I agreed that it was "pass by value", not "pass by reference". Good job in reading my post. However, the values in Java are usually references (assuming they are objects, not primitives), so the thing that you usually want to change (the object, not the reference) can be changed.
The things you end up passing around are values of references. Thus for most purposes, it is effectively pass by reference.

User 111696 avatar

bloid replied ago:

0 votes Vote down Vote up Reply

But all these things are surely known about as you enter into the Java world (or soon after)?

I could complain that C doesn't handle Objects, or that Assembler doesn't natively do regexp, but wouldn't people label me a fool?

Also, I hate the way rain is wet

User 187417 avatar

sproketboy replied ago:

1 votes Vote down Vote up Reply

This is just a silly Lisp lamer whining about what he doesn't like about Java. I could get a list of Lisp features and write a blog about how much I hate each one. Yip-eee. He's completely wrong on many points as well.

This is what's wrong with dzone. Junk like this should not get to the front page. Only put stuff on front page that has at least 20 or 30 positive votes!

User 102928 avatar

dglasser replied ago:

1 votes Vote down Vote up Reply

Either that, or have the down votes counter-balance the up votes to some degree. The way it seems to work now is that a post can have 10 down votes, but once it gets 4 ups, it's on the front page regardless of how idiotic the referenced content might be.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.