[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Using Mono to Compile C# to WebAssembly

Using Mono to Compile C# to WebAssembly

Jan 30, 2018 1 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

Since all major web browsers now include support for WebAssembly, developers can now look to having a new platform for which they can target their applications. The standard toolchain provided by the WebAssembly group will compile C/C++ to WebAssembly which doesn't help developers using other languages. Fortunately for C# programmers, the Mono Project is working on two different approaches to support WebAssembly.

The first approach utilizes the Mono IL interpreter to run managed code (like C#) at runtime. The goal of this approach is to support rapid prototyping and development. This second method would be best used when an application is ready to be shipped to a customer. This approach uses static compilation to produce a WASM file that for native execution by a browser that supports WebAssembly.

To create these WASM files, the Mono project has introduced a new tool, mono-wasm. It takes C# assemblies as input and generates LLVM bitcode for use with the LLVM WebAssembly backend. The resulting WASM file produced by mono-wasm includes all of the dependencies needed for the C# program's execution, including the mscorlib.dll, C library, and the Mono runtime. Since the LLVM linker recently added support for WebAssembly, mono-wasm supports incremental compilation. This greatly reduces compilation times as code that doesn't change (mscorlib.dll, Mono runtime, etc.) does not need to be recompiled while developing your application.

A lot of work has been accomplished by the project, but primary developer Laurent Sansonetti does point out that it is still pre-alpha. In the new near term, outstanding goals include fixing garbage collection and preparing a formal alpha release. Longer term the project will look at shrinking the size of WASM executables (the "hello world" example is 10 megabytes), updating the Mono compiler so that it can target WASM32 directly, and improving C#/JavaScript interoperation.

While this project is very much under active development, curious developers or those seeking to contribute can find the project's current code on GitHub.

Rate this Article

Adoption
Style

This content is in the .NET topic

Related Topics:

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /