GCC 4.6.0 released
Posted Mar 28, 2011 20:43 UTC (Mon) by
HelloWorld (guest, #56129)
In reply to:
GCC 4.6.0 released by cmccabe
Parent article:
GCC 4.6.0 released
Primitive types are only a "problem" if you're the kind of person who alphabetizes his sock drawer.
Actually, Javas primitive types led to numerous problems. It made wrapper classes necessary, which in turn made autoboxing necessary as it's a PITA to use otherwise. And autoboxing leads to subtle bugs for example in conjunction with the :? operator. You also still can't say ArrayList<int>, making Java harder to teach and learn than necessary.
And there's another more subtle problem. Primitive types were introduced because using a heap-allocated object for every int variable seemed too costly at the time. But if you think about it, allocating ints on the heap wouldn't have been necessary. The Integer class is immutable, and if something is immutable, it doesn't matter if you pass it by value or by reference, so they could have made it so that integers are passed around by value instead of references to heap-allocated integers. The only reason that doesn't fly is that Integer is nullable while int is not. So, if the Java designers had thought properly about whether primitive types were really needed, they may have figured out that nullable values are a dumb idea.
Oh, and let's not mention the fact that Java still doesn't allow operator overloading (except for, somewhat bizarrely, the String class).
Perhaps most important of all, primitive types show that the Java designers just had no taste. Dijkstra was right when he said that elegance is not a dispensable luxury, but the Java designers clearly didn't grok that.
Non-nullable pointers may or may not be a good thing.
Nullable pointers are obviously a bad thing, as their effect of making something optional can be trivially obtained without a special language feature and on the other hand, NullPointerExceptions are a frequent source of bugs.
If you want to know what Java cleaned up, check out: http://yosefk.com/c++fqa/defective.html
Most of that is utterly pointless ranting about C++ being a systems programming language. That said, there are a few problems in C++ that Java doesn't have (grammar, lack of a module system). But Java fixed too few of C++'s mistakes (and introduced too many stupid mistakes on its own) to call it a cleaned-up version of C++.
(
Log in to post comments)