ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  10 Reasons We Need Java 3.0
Subject:   primitive types are awesome
Date:   2002-08-02 18:05:07
From:   codemonkey
The author mentions that primitive types are a top-10 drawback to Java, but really they are great in their simplicity.


Using Objects, as the author suggests, with inheritance and all is terribly slow. The fastest Smalltalk even using small integers is at least 4x slower than Java and more like 100x slower for floating point despite cutting huge corners that cause unexpected results (10 == 10 but 10^9 != 10^9 in some Smalltalks). The performance difference is a *huge* factor, not a minor side-issue like the author suggests.


Using values with inheritance, as in Eiffel, can cause totally bizarre effects where
b = (tmp = a)
results in b != a and !b.equals(a) for some types -- totally unexpected, bizarre and wrong.


What is needed is an *Object based* system of user defined *value types*. In other words, C structs with methods. Value objects that do not have inheritance. Inheritance is incompatible with value types. Combine with auto-boxing to 'holder' objects where method calls on those cause a new value to be created (ie don't operate on the object itself) and the method called on it.


Also, the author seems confused what a classloader is. It is perfectly right that A implements B not be an instance of B from another classloader; the entire security system depends on this concept. Classes are identified by their name and classloader, so there is no "A" class in the JVM.



1 to 1 of 1
1 to 1 of 1