Jeremy: java.lang.NullPointerException
I remember back in the mid-90s when Java first came out. I actually read the Java 1.0 language spec. The whole thing. It was cool. One of the folks who was telling me about it (just before I read the spec) endorsed it by saying "it's like a cleaner C++ with no pointers!" I've heard the "you don't make pointer mistakes in Java" bit a lot over the years.
Despite all that, I'm still able to convince Java to throw a java.lang.NullPointerException at me. Every time I get one (which is pretty often right now) I have to laugh just a bit because this is the a language without pointers.
Charles: NullPointerException:
Jeremy Zawodny has discovered the NullPointerException, and laughs because he's been told that Java is "the language without pointers". Claiming that Java is a language without pointers is, of course, rubbish. All variables that refer to objects are references (i.e. pointers) to that object, which resides somewhere in the heap.
What Java lacks, is pointer arithmetic. The only operation that is permitted on a pointer is dereferencing (the '.' operator), which allows you to perform actions on the object being pointed to. There are two reasons for this. Firstly, it frees the JVM to do memory-management how it wants, and not have to be a slave to the "pointer equals memory address" thing. Secondly, and more importantly, it prevents a large class of memory-corrupting, security-destroying, application-crashing bugs that can result from direct manipulation of pointers.
Which brings us to null. Null is the value for a reference which means "this reference does not point to any object". If you try to dereference null, you get a NullPointerException.
Some languages treat null differently. Objective-C's nil is a reference to the null object, which responds to any message you throw at it with nil. This makes an unassigned reference something like a black hole, you can send anything in but you'll get nothing back. Smalltalk gives you both worlds: nil is a singleton that passes every message to doesNotUnderstand. In development environments this throws up the debugger when it's reached, but common practice is to redefine nil to observe the Objective-C behaviour in production.
Fascinating, I never knew that.
Also check out a little more on this by Kasia.
Update: read more on LtU. Ehud makes the point I was thinking as I wrote this post, and he says it well:
It should be noted that this issue is quite relevant to teaching programming. Some people assume that by using language like Java you eliminate the need to teach students about pointers. This is a rash conclusion.
Nice is a nice language which uses Java and compiles to a VM. By default a reference in Nice cannot be null, so NPEs anymore. If you want nullable references you have to declare a reference nullable.