by BWStearns · 10y ago · 0 comments
There's obviously nothing impossible about it, since it has been done, it's just that it takes a lot more resources than you might have initially thought to do it well. And I think from an economic perspective, the vast bulk of open source projects and similarly-staffed projects are way better off putting that "lot more resources" into becoming better on their native platform than being not-quite-as-good on a lot more platforms. (I had a lengthy defensive discussion of the differences between commercial and open source resource allocation, which grew to be more than half this post, so let's just pretend I proved that I understand the difference, and I still think this paragraph is true even given those differences.)
What's more rare is a single implementation of a language targeting multiple runtimes. There's Haxe, which has like 10 different targets (and those different targets seem to be the main selling point). Unity uses C# as it's programming language, but also has HTML5 + Javascript export.
The general downside with either of these is that the runtime should actually inform the language design, and vice versa. When you target multiple runtimes, you either have to design the language conservatively such that it only takes advantage of the smalles common subset of features in the runtimes. Or you have to accept that some operations the language nominally supports will be uncomfortable on some of the target runtimes.
As a classic example of the last one, a lot of scripting languages start off with memory management based on reference counting (possibly with some kind of facility for breaking loops automatically). This means that it's very natural for the language to provide deterministic object destruction as soon as the object goes out of scope, and for the library ecosystem to take advantage of that. (Like closing file descriptors when the matching file object goes out of scope). Move to a runtime with a garbage collector, and the finalization becomes non-deterministic. And you either accept the loss of this very convenient feature, you completely cripple the GC based implementation by adding this very expensive extra constraint on top of it, or you allow the two implementations to diverge.
Then there's fracture. Imagine reading that language X is at version 3 for one runtime, but 2.5 for another runtime because "the guy who did the support of runtime B lost interest, and nobody has taken it up again".
That, and almost everything has support compiling to its original target and JavaScript these days.
Nonetheless I agree with the sentiment, perhaps because I'd love to see Scala on .NET and F# on JVM in particular. I don't know why, of all the things that have happened, neither of these ever did. Maybe too much overlap to be worth it. I'd also have to imagine that strongly-typed languages are a bit more difficult since you have to match the underlying runtime.
Curious if there were any languages and targets in particular you had in mind.
FWIW ClojureCLR is still going strong; seems to track the JVM version within a couple weeks: https://github.com/clojure/clojure-clr/commits/master It does have some warts, but I've played with it and it works fine.
It also has to be said that even their JVM implementation fell behind MoarVM now, so the second and most important reason would be lack of time and manpower.
*Yes, I know about Niecza, not the same.