"Model 2" prototype status
simon at ochsenreither.de
Thu Aug 6 16:56:35 UTC 2015
I'm not saying that duplicating static members is without benefits, especially
when it comes to ease of implementation.
The problem with this approach is that it vastly complicates the mental model of
everyone learning or using Java.
Today, people have to distinguish between members which are per-class and
members which are per-instance.
(Java doesn't separate these members, but allows mixing them freely at
declaration site. From my experience with beginners learning to program, this is
pretty bad already.)
With duplicated members, we would put the implementation details of specialized
classes right in front of users, and force them to learn another layer.
We would have
- members per class without class-level Generics or with erased Generics
- members per specialized class artifact of a class with reified Generics
- members per instance
This is especially confusing given that the duplicated fields would only exist
for value types, while reference types would share the same member.
I've spent a lot of time in Scala working to remove things where people said
"oh, you just need to spend 5 minutes learning it, and then it will be fine!".
Duplicated statics is certainly not a 5 minute tax on every present or future
Java developer, it's probably a magnitude more.
More information about the valhalla-dev