I haven't read the article fully, but can anyone please explain why value types seem so much more complicated in the JVM than DotNet, where they have had it for a long time?
Project Valhalla, Simple as it can be, but not simpler
21–30 of 33 posts
Re: Project Valhalla, Simple as it can be, but not simpler
#22I haven't read the article fully, but can anyone please explain why value types seem so much more complicated in the JVM than DotNet, where they have had it for a long time?
First, .NET structs are flattenable but they're not value types, which are immutable and so pose further problems. But the two main challenges for adding any new big feature to Java are forward compatibility and simplicity. 1. Forward compatibility: While backward compatibility means that old code continues to run and so is easy to do (add the new feature "on the side"), forward compatibility, or migration compatibil…
Which to me was always ironic that they get perceived like that, given that C++ was born at Bell Labs alongside C and UNIX, and CORBA was born on UNIX, IBM and Apple were equally pushing for C++, and Borland always had better C++ tooling (to this day even as Embarcadero) than Microsoft has done during the last 30 years.
Now it is certainly true that WinDev is pretty much a C++ shop to detriment of anything else, including .NET.
Re: Project Valhalla, Simple as it can be, but not simpler
#23https://www.youtube.com/watch?v=XL2zzFaybdE&ab_channel=EduMa...
Re: Project Valhalla, Simple as it can be, but not simpler
#24From the start I was wondering if there's no way for the JVM to solve this with less cruft on the bytecode level. Of course, that doesn't mean I was aware of the challenges, just an intuition. I do think they must have had similar intuitions in the beginning. Then identified big challenges with that and that what would be needed to overcome it more streamlined is some set of features or optimizations. It seems though…
Discussion on the mailing list: https://mail.openjdk.org/pipermail/valhalla-spec-experts/202...
Re: Project Valhalla, Simple as it can be, but not simpler
#25I haven't read the article fully, but can anyone please explain why value types seem so much more complicated in the JVM than DotNet, where they have had it for a long time?
Value types was in the CLR(_Common_ Language Runtime) from day one as the runtime supported (variations of) C/C++,etc. Iirc proper generics didn't appear in version 1 of C# but since the foundation was there generics could become an addon in terms of new collection classes that could be properly parametrized. Java generics took a shortcut by reusing the old classes and just layering them on in the language but erasin…
This alone lets one do things like freely copy/share/modify them, that directly allows for flattening.
Re: Project Valhalla, Simple as it can be, but not simpler
#26Re: Project Valhalla, Simple as it can be, but not simpler
#27I haven't read the article fully, but can anyone please explain why value types seem so much more complicated in the JVM than DotNet, where they have had it for a long time?
Re: Project Valhalla, Simple as it can be, but not simpler
#28Earlier quoted context omitted.
I’d say that it’s backwards compatibility. My understanding is that moving from 1.1 to 2.0 (that introduced reified generics) required work from developers of libraries. It was also done in relative infancy of the ecosystem. But I trust some c# oldtimer to tell me how it actually was as I only remember that some tools I used insisted to have older .net runtime installed.
Value types (structs) were in C# 1.0, and they’re used e.g. in native code interop. Java generics use erasure, and they are backwards-compatible with non-generic-using code. You can still say `var l = new ArrayList();` in the latest Java versions; you’ll get a compiler warning, but the code will compile and run as well as code using `ArrayList ` would. C# uses reified generics (which are faster, saner, and more expre…
I wouldn’t go as far to claim that, e.g. it is often claimed to be the reason behind why the JVM has a blooming language ecosystem, while the CLR, not so much.
Generics have language-level semantics and they may decide to do it differently, in which case erasure gives better results.
Re: Project Valhalla, Simple as it can be, but not simpler
#29Earlier quoted context omitted.
Value types (structs) were in C# 1.0, and they’re used e.g. in native code interop. Java generics use erasure, and they are backwards-compatible with non-generic-using code. You can still say `var l = new ArrayList();` in the latest Java versions; you’ll get a compiler warning, but the code will compile and run as well as code using `ArrayList ` would. C# uses reified generics (which are faster, saner, and more expre…
> reified generics (which are faster, saner, and more expressive I wouldn’t go as far to claim that, e.g. it is often claimed to be the reason behind why the JVM has a blooming language ecosystem, while the CLR, not so much. Generics have language-level semantics and they may decide to do it differently, in which case erasure gives better results.
CLR languages throw it away in the runtime, JVM languages throw some away in bytecode, and Haskell throws it all away in the compiler.
Re: Project Valhalla, Simple as it can be, but not simpler
#30Earlier quoted context omitted.
Value types (structs) were in C# 1.0, and they’re used e.g. in native code interop. Java generics use erasure, and they are backwards-compatible with non-generic-using code. You can still say `var l = new ArrayList();` in the latest Java versions; you’ll get a compiler warning, but the code will compile and run as well as code using `ArrayList ` would. C# uses reified generics (which are faster, saner, and more expre…
> reified generics (which are faster, saner, and more expressive I wouldn’t go as far to claim that, e.g. it is often claimed to be the reason behind why the JVM has a blooming language ecosystem, while the CLR, not so much. Generics have language-level semantics and they may decide to do it differently, in which case erasure gives better results.