3 ms·
One annoying detail of this proposal, is that it swaps the meaning of the nullness markers compared to Kotlin, which uses ! to mean "it came from Java and had n
by cesarb 2y ago
One annoying detail of this proposal, is that it swaps the meaning of the nullness markers compared to Kotlin, which uses ! to mean "it came from Java and had no nullability annotations so we don't know" and no marker to mean not nullable (https://kotlinlang.org/docs/java-interop.html#notation-for-platform-types https://kotlinlang.org/docs/java-interop.html#notation-for-p...).
- vbezhenar 2y agoThere's no "!" syntax in Kotlin for developers.
- jpgvm 2y agoCorrect. Platform types are non-denotable.
- mike_hearn 2y agoNot a big deal. The exclamation mark only appears in IDE tooltips and things, you can't express it directly. It could therefore be changed without breaking anything. If you want a 'flex type' you have to use type inference: // Java Baz bar() { return new Baz(); } // Kotlin val foo = someJavaObject.bar() foo now has type Baz! but the moment you declare the type of foo explicitly you're forced to pick, and an NPE check is done at that moment.
- drinkcocacola 2y agoIt is indeed annoying. For Kotlin, its advantage is that it had the nullability concept from its inception. For Java, they need to make sure previous code behaviour does not change, meaning that they need to add an additional marker to the explicitly mark "not null" types. Probably in some years from now once codebases exclusively use this feature, there would be a way to tell the compiler that the default type (without marker) it is a non-nullable type.
- yas_hmaheshwari 2y ago"Our colleague Alex Buckley, specification lead for the Java language and JVM, likes to say that one of the surprising things is that Java managed to get all the defaults wrong and still succeed" [Source](https://blogs.oracle.com/javamagazine/post/what-are-they-buildingand-why-6-questions-for-the-top-java-architects#:~:text=That's%20why%2C%20Goetz%20says%2C%20in,managed%20to%20survive%20these%20mistakes.%E2%80%9D) https://blogs.oracle.com/javamagazine/post/what-are-they-bui...
- pjmlp 2y agoIn that regard, I would say Java is in good company => C, C++, JavaScript, PHP.