Link Details

Link 46036 thumbnail
User 236075 avatar

By henk
via jdevelopment.nl
Published: Oct 04 2007 / 17:23

Some 12 years after the introduction of the Java programming language and thus some 12 years after the introduction of the NullPointerException, it remains an urban myth among some groups of people that Java does not have pointers.
  • 8
  • 7
  • 2689
  • 629

Comments

Add your comment
User 200744 avatar

johannz replied ago:

0 votes Vote down Vote up Reply

While accurate, this site doesn't actually contribute anything. It just says that many people still think Java doesn't have pointers

If this article had thoughts on how to overcome this misconception, or something constructive, I would have given it an up vote. Instead, I'm left completely neutral.

User 239525 avatar

arjan_tijms replied ago:

0 votes Vote down Vote up Reply

Johanz, I agree with you that the blog doesn't directly offer anything constructive, or introduces any new insight. But do all blogs have to be like that? The subject actually has been discussed in the past on quite a number of occasions (as I mention in the blog). Instead of repeating all those discussions in the main article my point was just about the observation that after all this time (12 years), there still hasn't been a final solution to this misconception.

Java doesn't still doesn't throw a NullReferenceException and there remains a group of people who state Java has pointers and a group of people who believes Java doesn't have them.

Nevertheless, simply observations often lead to interesting discussions, so let's see what gets discussed in the comments ;)

User 206160 avatar

NoLiveTv replied ago:

0 votes Vote down Vote up Reply

You are correct: Blogs don't need to offer insight or anything constructive.

However, I expect non-spam items that make the front page of DZone to do just that.

Perhaps if the author took the thought all the way to its logical and over-the-top conclusion--that all computer languages get converted into machin code, which is usually represented to humans as Assembly language, and everything machine language deals with is pointers (registry addresses), so ultimately there is no such thing as a pointerless language--it would have had that extra "je ne c'est pas" that would make it worthy of the front page.

I guess this one falls into the "interesting to newbies" category, which is a fine and useful category (I dread the day when the Digg "technology posts gotta be about bleeding edge, Unix, or Apple" Nazis make it to DZone).

User 239525 avatar

arjan_tijms replied ago:

0 votes Vote down Vote up Reply

>so ultimately there is no such thing as a pointerless language

There is. How a language is implemented is largely irrelevant on this level. What matters here is what semantic constructs a language exposes to its programmers. Java exposes the pointer concept and thus is not a pointerless language.

User 204894 avatar

arikthered replied ago:

1 votes Vote down Vote up Reply

"Has no pointers" is just a conversational way of saying that Java can do no pointer arithmetic (or anything else with them, for that matter). It's like the conversational phrase "survival of the fittest" to describe variation in heritable reproductive success. Taken on it's own merits, the statement is just plain wrong... but your average Java programmer will never need to know that. Moreover, I don't see what contribution such semantic arguments are supposed to make.

User 239525 avatar

arjan_tijms replied ago:

1 votes Vote down Vote up Reply

>"Has no pointers" is just a conversational way of saying that Java can do no pointer arithmetic

Then why not simply say "Java can do no pointer arithmetic" ?

Saying Java has no pointers is confusing to people who don't know about Java. Sure, Java programmers know that what's often called a Reference in Java is more closely related to the C++ pointer than to the C++ reference. The original Java designers must have felt the same way about this, hence the NullPointerException. This is not merely a typo, but reflects the thought that even if something doesn't allow arithmetic it can (and IMHO should) still be called a pointer.

Of course, I -can- do things with the Java pointer. Saying that in the machine everything is a pointer anyway doesn't make that much sense. Java actually -exposes- the pointer concept to the Java programmer. -That- is what matters. I can reassign a pointer to point to a different object and I can have multiple pointers pointing to the same object. Hence, I can even have a pointer that is nothing but a pointer to actually nothing.

Compare this with languages which may use pointers under the hood (e.g. when passing objects to functions) but in no way exposes this to the programmer. In those languages, a variable -is- the object (names the object) and there is no way to have multiple variables point to the same object.

Perhaps the whole "no pointers" hype started back when Java was marketed as the easy alternative to C++. C++ had pointers, and since pointers were supposed to be difficult, Java could not have them. Right?

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.