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

image

VN:F [1.9.18_1163]
Rate this post
Rating: 8.0/10 (1 vote cast)
Convert .NET Intermediate Language to JavaScript, 8.0 out of 10 based on 1 rating

Related posts:

  1. How Microsoft’s Office Web Apps were written in C# and compiled to JavaScript, maybe
  2. Here comes TypeScript: Microsoft’s superset of JavaScript
  3. Adobe targets Apple iPhone and iPad browsers with tool to convert Flash projects
  4. Speeding page load with dynamic JavaScript
  5. Google offers the web a new language called Dart – but why?

3 comments to Convert .NET Intermediate Language to JavaScript

  • 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.

  • 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.

  • 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: http://www.zdnet.com/blog/microsoft/microsoft-architect-compares-volta-and-googles-gwt/1023