Project Valhalla: A look inside Java's epic refactor
infoworld.com
infoworld.com
> 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.
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.
> Object identity is a good default
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.
JNI is an abomination and a cautionary tale for everyone implementing interop facilities into their language.
https://www.ptc.com/en/products/developer-tools/perc
https://www.aicas.com/wp/products-services/jamaicavm/
And to 80% market share in mobile OS market, full of JNI all over the place.
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.
By the way, MAUI folks had to rewrite plenty of stuff in Java/Kotlin and Swift, to improve MAUI performance.
If you don't, then the comment is speculative, pointless and driven by bias.
The better way is to write Swift, or eventually Objective-C, when iOS is anyway the only OS being targeted, instead of adding complexity layers, just because one fancies C#.
However, unlike the dotnet world, the JVM ecosystem provides numerous ways to do native access, if raw JNI isn't your thing. JNA has been around forever, then there's JNR as well, numerous less-used libraries, and finally Project Panama[1]. Pick the one you like... we get choices.
The dotnet people usually only ever get one option, and believe (falsely) that it's the greatest. A lot like Stockholm Syndrome...
[LibraryImport("my_library", EntryPoint = "pass_numbers")]
partial static void PassNumbers(int a, int b, int c);
For AOT compilation, you can even completely statically link[0] it into the binary and annotate with [SuppressGCTransition] - it will be as cheap as a direct call from C++ (although GC transition is just a helper stub call that is barely noticeable on microbenchmarks - 1-2ns difference at throughput).In fact, you can also do the reverse and AOT-compile C# projects to regular dll/libs which can be called from C, C++, Rust, etc. land with ease:
[UnmanagedCallersOnly(EntryPoint = "receive_c_string")]
public unsafe static void ReceiveCString(byte* ptr) { /* impl.. */ }
(there are other aspects that make this a powerful combo like being able to wrap pointers into new Span<byte>(ptr, length)'s and transparently inter-operating with most of the standard library without ever allocating)Panama may offer better UX but not the one that can match C# and only marginally improves performance over JNI[1] (which is still slow).
[0] https://learn.microsoft.com/en-us/dotnet/core/deploying/nati...