5 ms·
Generics just bake a little bit more into the runtime; there's already a lot of the type system there. And it increases interop potential. I don't understand yo
by MichaelGG 10y ago
Generics just bake a little bit more into the runtime; there's already a lot of the type system there. And it increases interop potential. I don't understand your point about Scala - they could always choose to use type erasure instead of any runtime-provided generics. F# implemented generics with erasure on the 1.x CLR, and used the runtime when on CLR 2.
And this is the first time I've heard that the JVM is easier to target for non-Java languages. .NET has had multi-language support an official design goal, the JVM is just for Java. Even simple stuff like pointers, so you can do ref/out parameters. Or unverified instructions. The CLR is simply more all-around capable.
I am pretty sure the CLR always supported variance, it was just unused up until C# 4.0. AFAIK, there haven't been any changes to the runtime bytecode since CLR 2.0, when generics were added.
The performance benefits of specialization are pretty nifty. The Mono guys ported Android to C# and got quite the performance improvement on some code: https://blog.xamarin.com/android-in-c-sharp/ https://blog.xamarin.com/android-in-c-sharp/ - so that's existing code that got a perf benefit "for free" due to not using type erasure.
Edit: A quick skim of the specialization proposal for Java[1] makes no mention of other languages. Just the general pain of integrating it in a compatible way.
1: http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html http://cr.openjdk.java.net/~briangoetz/valhalla/specializati...
- pjmlp 10y agoBrian Goetz sometimes refers to it on his presentations. As for multi-language support on the CLR, compared with the old 1.x days, there seems to be less focus on it. With C# getting most of the focus, followed by VB.NET and F# playing catchup. Also outside MSR, most researchers focus on the JVM, in spite of its caveats, and nowadays LLVM as well. ETHZ is the only one I am aware that also designs languages with CLR in mind. The Active Oberon successors, like Zonnon. There are some companies selling compilers for .NET, like Cobol, Eiffel and Pascal. Not sure how well they are doing it. Clojure also targets the CLR, but they don't seem to have a story for .NET Core.
- MichaelGG 10y agoIsn't that more a function of MS's hostility to other platforms, not technical reasons? If MS had been more open and friendly 15 years ago things might be different.
- pjmlp 10y agoI don't see that as hostility, rather political decisions, including on Microsoft's own languages, with the usual issues between language departments. For example, if everyone played the ball into the same direction, probably Longhorn could have been what UWP is becoming.
- sreque 10y ago>And this is the first time I've heard that the JVM is easier to target for non-Java languages https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=jruby+jvm+clr+type+erasure&* https://www.google.com/webhp?sourceid=chrome-instant&ion=1&e... Here's a post from a JRuby developer saying he prefers a simpler VM. In the comments section of the same post you'll see Martin Odersky, creator of Scala, saying he also prefers a simpler VM. I could probably find more examples if I dug further. >I am pretty sure the CLR always supported variance, it was just unused up until C# 4.0 Nope. They were introduced to both the CLR and the C# language in 4.0. See https://www.codeproject.com/articles/72467/c-4-0-covariance-and-contravariance-in-generics https://www.codeproject.com/articles/72467/c-4-0-covariance-... https://blogs.msdn.microsoft.com/rmbyers/2005/02/17/generic-type-parameter-variance-in-the-clr/ https://blogs.msdn.microsoft.com/rmbyers/2005/02/17/generic-...