3 ms·
...this is what Java gets instead of smth actually useful like structs/records/dataclasses with pass-by-value semantics?
by nnq 6y ago
...this is what Java gets instead of smth actually useful like structs/records/dataclasses with pass-by-value semantics?
- pulse7 6y ago...pass-by-value is also coming and it will be called "inline objects". See: http://cr.openjdk.java.net/~briangoetz/valhalla/sov/01-background.html http://cr.openjdk.java.net/~briangoetz/valhalla/sov/01-backg...
- deleted 6y ago[deleted]
- enitihas 6y agoJava is getting other things, text blocks don't have to be excluded due to those 1. Records are already there AFAIK 2. Structs (Value types) will come as part of Valhalla 3. Records are the impl of dataclasses 4. Pass by value is already there for primitive types. Valhalla might bring that to structs also. Java is also getting a lot of good stuff like coroutines(Loom), and Panama(seamless FFI).
- nnq 6y agoThanks for making me curious... Cool new developments, didn't touch Java in a while! > Records are the impl of dataclasses This is ofc backwards/reverse of any sane logic that would start with value types and after invent references (eg. in this case probably would've mean introducing a new composed-primitive type)... but then again, it's Java, at least they got the strings being immutable part right from the start.
- chhum 6y agoDetailed piece on Records here: https://www.infoq.com/articles/java-14-feature-spotlight/ https://www.infoq.com/articles/java-14-feature-spotlight/
- hyperpape 6y agoRecords are still a preview feature in Java 14 (Apr 2020). Java 15 (Fall 2020) contains a second preview. They're usable, but you have to pass a flag to the compiler to enable them, and you run some small risk that the syntax will change (it's pretty simple, so I'd guess that won't happen). I'm guessing that they'll land in Spring or Fall 2021, but that's just an outsider's guess. The really important cutoff is Spring 2022, when Java 18 is intended to be an LTS version.
- J-Kuhn 6y agoYou have to pass `--enable-preview` to BOTH compiler and runtime. If you think about it - the feature may change significantly or be even removed - it makes sense to only support a preview features in one java version. Providing backward compatibility for preview features is simply not intended.
- _ink_ 6y agoLoom and Panama look really cool, but when will they make it into the JDK?