views:

229

answers:

1

Hi,

Newbie here...can I write one program which incorporates .NET LINQ and also various Java frameworks in the same scala program? Or when I compile, at that time the decision is made either one or the other, .NET or Java

Thanks.

+4  A: 

When you compile scala you give it either -target:msil or -target:jvm-X.X (the default being java). This means that you could attempt to make something cross compilable (that would work with both targets but must be compiled separately for each).

Attempting to host both frameworks at once with functions crossing the boundaries is, while technically possible, extremely hard and would require full support at both the compiler and runtime level.

Since scala operates on top one or the other runtime it is highly unlikely that this would ever work well or that anyone with the abilities to achieve it would bother. Also a variety of .Net types have no analogue in the jvm and vice versa.

Correctly and efficiently maintaining the GC roots across both runtimes in such a system would be a topic worthy of a PhD thesis in the abstract let alone implementing it.

ShuggyCoUk