top | item 32325875

(no title)

jdc | 3 years ago

Java's value types will be ready soon enough: https://openjdk.org/projects/valhalla

discuss

order

coder543|3 years ago

I hope it happens soon!

But, if I understood correctly, that design both requires you to explicitly mark a type as a value type when you define it and it doesn’t support inheritance, so I’m skeptical that it will see any real adoption for a long time.

Java hasn’t had decades to develop a culture around this feature the way that C# has, and neither are like Go where everything is value typed unless it is one of the built in pointer types, or you explicitly put the value behind a pointer. (The pointers themselves are values, of course, but I think few people are interested in that distinction here.)

Go isn’t perfect by a long shot, I just don’t think adding the millionth keyword is going to be a silver bullet for Java’s predisposition towards GC pressure.

kaba0|3 years ago

Java’s standard lib has been planned with value types in mind for some time now, plenty of classes will be able to take advantage of them. Also, inheritance is not rampant in Java, at least not in classes that are so numerous that value types would help them.

Also, Java is an exceedingly small language, so the millionth keyword comment is unwarranted.

morelisp|3 years ago

They'll be ready soon I guess, but "soon enough" would have had to be 5-6 years ago when we started shipping.