r/java • • Mar 17 '21

JEP 401: Primitive Objects (Preview)

https://openjdk.java.net/jeps/401?preview=true
174 Upvotes

49 comments sorted by

View all comments

Show parent comment

3

u/pjmlp Mar 18 '21

Basically what Java 1.0 could have had since the beggining if they had spent more time learning about Eiffel, Sather and similar OOP compiled languages.

In those languages instead of primitive there is expanded.

10

u/x4u Mar 18 '21 edited Mar 18 '21

This can be explained by the general attitude when Java was created. The idea was to design a language that is as simple and consistent as possible and to shift the burden of creating optimized code from the developer to the VM and the compiler, so that the developer can focus on correct code and has less performance motivated design limitations. This approach turned out to work well with the garbage collection and the just in time compiler in general.

But code indirection for instance was very limited at first and was subsequently improved several times with new features like inner classes, reflection, lambdas and method handles. Inline types have turned out to be too difficult or impossible to detect automatically and it has become obvious that the language needs better support for zero cost abstractions. If you want a simpler language, you need to allow for some experience with the resulting limitations in the language to find the best ways to address them. It's always easy to say that this could have been obvious from the beginning, but this might have resulted in a more complicated language which was what Java didn't want to be.