by titzer · 3y ago · 0 comments
I would say that the JVM and CLR were not designed to support many languages. The JVM has one master, which is the Java language, and other languages that want to run on the JVM do so with a burden that increases as the distance from Java's type system increases.
Wasm is lower-level than most of the above bytecode formats. Even with Wasm GC, which adds statically-typed structs and arrays, and the function-references proposal which brings typed functions. With Wasm GC, there is also explicit support for tagged pointers (i31ref).
All of the above makes Wasm GC more general (by virtue of being lower-level) than the efforts you listed.
But CLR stands for Common Language Runtime and had three official languages shortly after release (VB.NET, C# and J#, offhand).
In fairness, both Sun and Microsoft advertised what they were shooting for in the name.
The generics in .NET 2.0 were the first big compatibility break, and I think async/await was the second and even bigger one that killed off the bulk of alt-langs.
The async/await language support in C# is basically a Monad transformer, building a generator-like asynchronous state machine. (The output of an async/await function in C# is rather similar in concept/implementation to the output of a generator function using yield syntax.) This is also why F# has never had a tough time with async/await because it has even more generic Monad transformer support ("computation expressions").
Any "alt-lang" could make use of the TPL whether or not they could transform their own similar syntax, and there's nothing stopping them from building a similar syntax. As far as I saw that wasn't a killer of languages.
CLR is not really common -- the "tells" are VB.NET and PowerShell.
VB6 was a very popular and useful language, and VB.NET broke everything in that ecosystem, turning it into a variant of C# with different syntax.
Does that sound like a multi-language VM?
If so, why not compile VB6 to it?
PowerShell is likewise best described as C# with a horrible shell-like syntax.
It's not really a shell in the original sense, because it doesn't talk to the kernel directly -- it runs on a VM, which mediates all access to the kernel.
fork() is a syscall that shells rely on critically, which is problematic for almost all VMs.
Some notes on "interior" (VM-based) vs "exterior" (OS kernel-based) shells here:
Those examples point to a differing design philosophy at Microsoft rather than some inability to write a language on the CLR. The design philosophy was clearly to do Java-ish typing across the board, supplanting VB6's loose typing and bash's text based mindset.
I don't really like the approach. I think shell scripting succeeds because it allows ad-hoc programming and I don't think Java-ish weak but static typing is some perfect ideal to be used everywhere, but you could certainly implement a more loosely typed language on the CLR.
The abstract syntax tree is then traversed and
encoded into a stream of symbols from the evolving
vocabulary. The encoder processes whole subtrees of
the abstract syntax tree at a time; these roughly
correspond to statements on the level of the source
language
If I'm not wrong, this technique originated in Oberon and was polished by the paper authors (disciples of Wirth)Hm...CLR stands for Common Language Runtime. I think it was explicitly created to support many languages.
The CLR's support for functional programming is better than the JVM partly because of the reified generics and partly because Microsoft developed F# and thus had skin in that game and worked hard to make it better.
The JVM's support for functional programming has always been weak; invokedynamic and the additional MethodHandle framework reduces boilerplate but is not really the right feature for FP, but a very clunky and heavyweight OO view of FP.
Reified generics need additional support, and if you're using type erasure you didn't need any support. What's missing then when it comes to supporting mainstream languages - HKT?
There's a reason Go isn't mentioned in the blog post: the GC is a leaky abstraction.
https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers
https://pkg.go.dev/runtime#Pinner
I think it's also worth pointing out that the main Go implementation has a non-moving GC (at this time), and all kinds of fecal matter may impact a rotary ventilation device if and when that changes. Like, are we supposed to pin byte arrays we pass to syscalls? Nobody does that, right now, for short-living calls.
They are typically as fast and sometimes faster than their standard counterparts (e.g. can't find the announcement now but mastodon runs much faster on GraalRuby than on JRuby, and JRuby is pretty fast). I have personal experience with GraalJS being very fast.
So I _think_ that you could now say that the JVM can now properly support multiple languages. There are still limitations, mostly related to language libraries that have native bindings so it's not all flowers and chocolates. But still worth considering. But as a general purpose multi-language platform I think you could say it's viable now.
But I share the scepticism - is this really the point of WASM? Whether it is or not, it does seem to be the general direction
https://www.graalvm.org/latest/graalvm-as-a-platform/languag...