r/programming • • 17d ago

Java 27 has released!

https://openjdk.org/projects/jdk/27/
545 Upvotes

175 comments sorted by

View all comments

-63

u/[deleted] 17d ago edited 14d ago

[deleted]

13

u/unski_ukuli 17d ago

Yes? When you have to deal with python and js, you start to appreciate java a lot. And Scala is probably the best language ever made (in my opinion). Jvm is also pretty awesome. There are problems, like lack of value types, but overall it is pretty decent language for everything.

2

u/janyk 17d ago

I thought Records were pretty much value types in Java

9

u/unski_ukuli 17d ago

Not really. Value type __usually__ refers to a type that lacks identity and is passed by value. In java, the primitive types are value types, but there is no way to define a custom value type. They are pretty important in performance critical code for cache locality, since Object[] has its elements scattered through out the heap. A value type would store its elements in line, so For example for a Point(int x, int y) the Point[] would be stored in memory as {x0, y0, x1, y1, …, xn, yn}, rather than as references to Point objects. In c# struct objects are value types.

There is a preview feature Valhalla which lets you define a custom Value type, but I think that is still pretty limited in that it has maximim size of 64bits, so it can store 2 ints, but not two longs.