3 ms·
Project Valhalla will go into Java 28 (next year, and preview version). Fingers crossed I'll manage to use null type safety in my lifetime.
by arein3 17d ago
Project Valhalla will go into Java 28 (next year, and preview version).
Fingers crossed I'll manage to use null type safety in my lifetime.
- karussell 17d agoA first step of Valhalla that is ...
- rf15 17d agouniversal null type safety has sadly been discarded as a core concept of Valhalla in my Understanding; that being said, the proposals in Valhalla have null-safety as a side effect, but only under certain conditions.
- MrBuddyCasino 17d agoWhen (if) null safety ships, I‘m not sure I can justify using Kotlin any longer. Java simply got too nice.
- joe_mwangi 17d agoReally? I don't thinks so. There is a reason JEP 539 is in preview. There is a reason internal annotations exists in current valhalla jdk prototype and upcoming java 28 such as @jdk.internal.vm.annotation.NullRestricted, @jdk.internal.value.ValueClass.newNullRestrictedNonAtomicArray. Also, there is a reason value classes are allowed to be null. This is because nullness types will be a key factor to the java language.
- deleted 17d ago[deleted]
- pregnenolone 17d ago> Project Valhalla will go into Java 28 Unfortunatley without specialized generics and without the performance benefits that are supposed to come with it. They were too slow with Valhalla.
- brabel 17d agoYou really need to dare to try something else, Kotlin has been available for many years and the cost for a Java shop is super small since the same tools work with both. I’ve used also Dart which is lots of fun. Even Typescript can be a good alternative depending on what you’re doing. All have nullability guarantees and a nicer type system than Java while being in the same ballpark in terms of performance.
- retrodaredevil 17d agoNullAway with JSpecify annotations are a really good way to add null safety to Java applications. Even enforces nullability at the generic level.
- rendaw 17d agoThe elephant in the room is the standard library (collections). It isn't even type safe yet, because some methods were around before generics were added. And collections are too core for anyone to be able to agree on a 3rd party standard.
- retrodaredevil 16d agoI mean, I guess you could say stuff like get(Object) and contains(Object) aren't type safe, but I've never seen that as an issue in practice. Plus there are some ErrorProne checks that'll tell you if you're doing something wrong in regards to calling contains(Object) with the wrong type.
- vbezhenar 16d agoThey accept Object not because they're not type safe. They accept Object because key `equals` method might return `true` for unrelated classes by design, and collections interfaces have to accommodate for that. In other words, you might put key of class C1 into the map, and later use `get` with key of class C2. And if these classes happen to implement `equals` accepting each other, the collections are supposed to work. So the core issue is that `Object.equals` method isn't type safe. Collections API just follow that.