Convert .NET Intermediate Language to JavaScript

Whomever called JavaScript the assembly language of the web was a true prophet.

Compiling .Net code to JavaScript is not new. I have heard that Microsoft’s Office Web Apps, browser-hosted editing of Office documents, are built with Script#.

The difference with JSIL is that it compiles .NET Intermediate Language (IL), and therefore works with any .NET language – though note that:

JSIL is still in development. You will hit bugs

The screenshot says it all


3 thoughts on “Convert .NET Intermediate Language to JavaScript”

  1. Technically that’s neat, but what’s the point? I can understand compiling C# to JS for its high-level constructs, type safety, and IDE support. But compiling IL to JS?

    If you were to translate existing assemblies that rely on the regular .NET Framework you’d have to pull in absurd amounts of libraries before the result works without a .NET installation. You’d also have to sort out any platform-specific code in the BCL. On the other hand, if you’re happy translating only specially written IL then you could just use Script# and directly translate from C#, skipping the intermediate .NET compilation step.

  2. Good questions, Chris:

    There are a surprising number of real apps that only rely on small portions of the BCL. So as a result I only have to implement those portions to get the app working. The pay-off there works out pretty well.

    In the long run my strategy is to compile the Mono version of mscorlib (and related libraries) to JS so that you will only need a custom implementation of things that can’t be translated – unsafe functions, internal runtime calls, etc – which will make it possible to run more sophisticated apps.

    And finally, while I can’t comment in detail on how to compare Script# and JSIL – I haven’t used Script# in depth – the fact that Script# has to implement C# compilation seems to be a downside. Last time I checked, it still did not have complete support for features like generics, ref parameters, overloading, nested types, using, and goto. I’m not sure I would want to write C# if I had to give up all those features.

  3. The true prophet you refer to is Microsoft’s Erik Meijer.

    At a small .NET language developer’s summit held in Redmond WA in August 2007, Eric was circulating the idea that JavaScript was really just an assembly language of the web. He invited me to give a presentation on the similarities between JavaScript and Intel x86 assembler: ubiquity, typlessness, difficult to work with at scale, etc.

    At that summit Eric also demo’d technology developed by Microsoft Research that decompiled or transcoded .NET IL assemblies into JavaScript. That was later made public as the Volta project:

Comments are closed.