News for hackers. Stuff that matters.
Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @12:20PM (#18610302)
My understanding is that the problem was, more specifically, that they couldn't easily get Scala's types mated to .NET, and that was in turn an implication of the decision to use IKVM to run the Java binaries for Scala's standard libraries on the CLR.

Which I could see being a problem, because then you need to figure out how to smoothly marshal data back and forth between (type erased) Scala collections and .NET functions, which typically expect reified types these days.

If they had gone with producing a .NET native version of Scala's standard libraries, they might have had easier success. But it also would have been a Pyrrhic victory, because you'd have lost the ability to run any existing Scala code, which would have scads of dependencies on other bits of the JDK as well, on Scala for .NET. At which point, what's the point?

I expect that porting F# to the JVM would encounter similar problems. And I expect that which platform you want to blame them on depends on which one is your home platform.

IMO the real story here is that the two big managed platforms are effectively walled gardens, by virtue of having VMs that implement such very high-level bytecode. Both of them effectively demand that all languages running on them can interact with, in effect, a thoroughly object-oriented ABI. There being approximately as may flavors of OOP as there are OO languages, that creates a situation where, if your language isn't set up to play nice with that platform's particular brand of OOP, you're going to have a bad time.

Re:Type erasure and reification by seanmcdirmid on Wednesday December 05, 2018 @12:36PM (#18610454)
I agree with most of what you said, but porting an erased language to the JVM is not very hard. Porting a reified generic language to the JVM would be challenging because genetics would have to be reified perhaps inefficiently, while clean interop would be impossible.

The JVM was never meant for other languages, that just happened, and most of the non-Java languages were designed to live nicely in the JVM world. The CLR is a bit more ambiguous, but I think it’s safe to say at this point that it is even less suited to other languages not designed specifically for it.

Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @01:03PM (#18610735)
I think it's safe to say that was the case before .NET 4 introduced the dynamic language runtime. Afterwards, I'm not so sure - it seems like the story there was that the .NET team put a whole lot of work into building support for IronRuby and IronPython, but the languages themselves failed to take off for other reasons. Lack of community need/interest, for one.

To me, the more interesting test is, could you do a useful port of a language like C or Pascal or ML to the JVM or the CLR, while having it remain the same language. My instinct is that it's equally unworkable for both platforms. Requiring erasure vs reification is a small difference compared to the major demand that both platforms make, which is that any languages targeting them need to be at least partially object-oriented.

Re:Type erasure and reification by int_19h on Wednesday December 05, 2018 @05:02PM (#18613091)
> To me, the more interesting test is, could you do a useful port of a language like C or Pascal or ML to the JVM or the CLR, while having it remain the same language.

Yes, you could. In fact, for C, this is experimentally proven - if you compile your C or C++ code with MSVC using /clr:pure, you'll get pure IL as output. This is by design - CLR is powerful and flexible enough to map any C construct, including raw pointers, unions etc, precisely because compiling C++ to it was always a requirement. Of course, the result isn't verifiably safe - but unlike JVM, CLR doesn't require verifiable code to be able to run it!

Consequently, if you can compile something to C, you can compile it to IL, and run it on CLR. In fact, there are even things that you can't compile to C that you can do in IL - for example, it has a tailcall opcode, which performs guaranteed tailcalls. So, yes, you would be able to compile Pascal or ML to it.

The reason why languages still adapt to CLR is because they don't just want to use it as a VM - they want to interop with other code that runs on it. In theory, it would be possible for two languages both hosted on CLR to use the equivalent of the C ABI to interoperate, but in practice nobody does that, and of course the .NET standard library is nothing like that. So if your language wants to be able to use .NET libraries, it has to support the .NET object model - and it is at that point that you get language dialects like C++/CLI.

Re:Type erasure and reification by seanmcdirmid on Wednesday December 05, 2018 @01:46PM (#18611168)
The DLR was only going to ever work out for dynamic languages, and even then I think it was pretty limited to class-based ones like Python and Ruby.

Unfortunately, the DLR seems to be pretty much deprecated at this point. Its a shame, I was able to do great things with the run-time generation API (which now defaults to an interpreter in UWP).

Re:Type erasure and reification by benaadams on Wednesday December 05, 2018 @03:18PM (#18612085)
> Its a shame, I was able to do great things with the run-time generation API (which now defaults to an interpreter in UWP).

That's more to do with UWP being a AOT platform than it being deprecated; it should still work fine with .NET Core?

Re:Type erasure and reification by pjmlp on Wednesday December 05, 2018 @03:57PM (#18612462)
They are rebooting the .NET AOT story after the 3.0 release.

It was discussed during this week Connect(), on the ".NET today and tomorrow" Q&A session.

https://channel9.msdn.com/Events/Connect/Microsoft-Connect--...

The video is not yet available though.

Re:Type erasure and reification by seanmcdirmid on Wednesday December 05, 2018 @03:41PM (#18612303)
I have no idea. I’ve mostly been interested in UI work anyways, and not being able to move to the new UI stack really sucked for me. Now it’s all just a bunch of bad choices.
Re:Type erasure and reification by int_19h on Wednesday December 05, 2018 @04:54PM (#18613011)
The DLR goes beyond running dynamically typed languages on CLR, though. For example, there's the Python.NET library, which lets you embed regular Python (not IronPython!) into a .NET app - and it still uses "dynamic" etc.
Re:Type erasure and reification by eeperson on Wednesday December 05, 2018 @04:39PM (#18612864)
> But it also would have been a Pyrrhic victory, because you'd have lost the ability to run any existing Scala code, which would have scads of dependencies on other bits of the JDK as well, on Scala for .NET. At which point, what's the point?

Wouldn't it be in the same boat as scala-js? There are quite a few libraries that support scala-jvm and scala-js.

Re:Type erasure and reification by dtech on Wednesday December 05, 2018 @12:28PM (#18610379)
> But it also would have been a Pyrrhic victory, because you'd have lost the ability to run any existing Scala code, which would have scads of dependencies on other bits of the JDK as well, on Scala for .NET. At which point, what's the point?

Ask the parade of JVM languages porting themselves to native and JS runtimes.

Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @12:35PM (#18610439)
Those are both very different use cases.
Re:Type erasure and reification by tutanchamun on Wednesday December 05, 2018 @05:41PM (#18613446)
Why are they very different? They port the language over to another platform and need to interop with it.

For example scala.js can call js libraries through facades (similar to typescript typing files) but can also be called from javascript.

Scala.native can call c libraries (I have no idea about the other way around).

Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @07:37PM (#18614266)
Targeting native because it's fundamentally a less thorny issue. To an approximation, all you do is take the JIT compilation pipeline and use it to do an AOT compilation instead.

Targeting JavaScript because people expect different things out of it. The goal there is to transpile some portion of your code to run on the browser. There's not the same expectation that you'll be able to truck Spring or Akka along with you. The expectation is that the transpiled code is mostly only going to interact with the DOM and other JavaScript libraries, plus maybe whatever subset of your business objects you feel the need to have on both the client and server side.

By contrast, the only real use case I can see for porting Scala to .NET is so that you can bring a bunch of pre-existing Scala libraries with you and then interface them with some pre-existing .NET codebase. If you're not looking for that, you'd probably be willing to satisfy yourself with either F# or the JVM.