6 ms·
Project Valhalla: A look inside Java's epic refactor
- brundolf 3y agoTo what degree do these features translate to JVM changes, vs just Java language changes (I know the two are fairly tightly coupled)? Eg will this mean new bytecode/optimizations that could be used to optimize other JVM languages which already have similar features?
- quantumwoke 3y agoYes, you can read more about the JVM changes in this blog post: https://openjdk.org/projects/valhalla/design-notes/state-of-valhalla/03-vm-model https://openjdk.org/projects/valhalla/design-notes/state-of-...
- brundolf 3y agoNice. So for example, it looks like Kotlin already has a nearly identical feature at the language level, which will be optimizable when Valhalla ships: https://github.com/Kotlin/KEEP/blob/master/notes/value-classes.md https://github.com/Kotlin/KEEP/blob/master/notes/value-class... > In the future, in a Valhalla-capable JVM, JVM primitive classes will enable efficient representation of Kotlin value classes with an arbitrary number of underlying fields on JVM.
- pjmlp 3y agoExcept it will mean that the semantics will be observable between JVM, ART, and all remaining Kotlin targets.
- tarasglek 3y agoas long as they dont have real first class functions, still behind modern languages
- kaba0 3y agoIt has had those for a decade now.
- fulafel 3y agoThe Java 8 additions are sugar for OO interfaces that help doing things similarly as if you had first class functions. But like before, only primitive types and objects are actually first class things.
- kaba0 3y agoTo mark it as non-first class, you have to provide something it doesn’t support.
- vasvir 3y ago> Objects, by contrast, are resistant to this kind of optimization because they have an identity distinct from their value. This is what .equals() tests for: the object’s location in memory. AFAIK equals() test for equality not identity in Java.
- brundolf 3y agoYeah that looked like a typo (the exact opposite of what they meant to say)
- mrkeen 3y ago> AFAIK equals() test for equality not identity in Java. In an ideal world, == would test for equality. In a worse world, equals() would test for equality. But we live in a Java world: Equals() is predefined as an identity check on Objects, and it's up invididual implementations to override that check with something better.
- kaba0 3y agoArguably, equality has no default, meaningful implementation. Object identity is a good default, while data-like objects=records should have the trivial equality in place. But a connection is not equal to any other, even if their internal state is equivalent.
- The_Colonel 3y ago
- grandinj 3y agoHmmm, int[] now being a subtype of Object[] is going to cause some odd bugs in code that does lots of reflection - eg. some of the frameworks that doing Rails style magic in Java.
- bhouston 3y agoIs this mostly adopted what C# has had single the early 2000s? C# always out performed Java for specifically this reason. It is why Unity standardized on C#.
- neonsunset 3y agoLook what they need to mimic even a fraction of C#'s power :)
- pjmlp 3y agoC#'s power can always be worked around with JNI, for those that don't have issues with polyglot codebases. Also lets not forget that Java (even if in a different flavour), powers 80% of mobile phone market, that power alone wasn't enough to keep Windows Phone going, mostly written in C++ anyway (COM/WinRT). Or the real time Java implementations used by the military, like PTC.
- neonsunset 3y agoIt takes some degree of ignorance to claim that Java can be used in scenarios which require proper structs and object interior pointers. JNI is an abomination and a cautionary tale for everyone implementing interop facilities into their language.
- pjmlp 3y agoMy ignorance takes me to places you can only wonder about. https://www.ptc.com/en/products/developer-tools/perc https://www.ptc.com/en/products/developer-tools/perc https://www.aicas.com/wp/products-services/jamaicavm/ https://www.aicas.com/wp/products-services/jamaicavm/ https://www.microej.com/ https://www.microej.com/ And to 80% market share in mobile OS market, full of JNI all over the place.
- neonsunset 3y agoThat's a rather damning prospect, that the mobile OS market has. Luckily, it's not all Android and I will be happily calling Swift directly out of .NET with upcoming interop changes and never have to touch this embarrassment of an API again that is JNI.
- pjmlp 3y ago
- Dudester230602 3y agoWhy not abandon the entire thing?
- Koshkin 3y agoOn the contrary - looking at the Java ecosystem I sometimes think, one must be insane not to use Java.
- projectileboy 3y agoAgree. At this point the JVM ecosystem is pretty mature. Complaining about it is a bit like complaining about Unix. The question isn't whether or not it's good compared to an ideal; the question is whether or not it's good compared to existing alternatives.
- pjmlp 3y agoThe only real alternative is .NET, hence why I use both platforms, :)
- sillywalk 3y agoFor second I thought this was OpenBSD's OpenSSL Valhalla Rampage https://opensslrampage.org/ https://opensslrampage.org/