Thus I was interested in a little tidbit of information resulting from yesterday's GitHub "Ask Me Anything" (AMA) event with Scott Hanselman from Microsoft's Web Platform Team.
It concerns Blazor, an open source Visual Studio extension (hosted on GitHub) described as "An experimental Web UI framework using C#/Razor and HTML, running client-side via WebAssembly."
Here's the Q&A that prompted Hanselman to mention Blazor:
Hanselman: Yes https://github.com/SteveSanderson/Blazor.
Going to that link presents Blazor's README.md file:
"The arrival of WebAssembly creates the possibility of building client-side Web applications using languages and runtimes that are more typically used for native app development. Blazor runs .NET code in the browser via a small, portable .NET runtime called DotNetAnywhere (DNA) compiled to WebAssembly.
"The programming model will be familiar to anyone who's worked with Razor (the C#/HTML page format used by ASP.NET MVC and ASP.NET Pages)."
is an open, new-age format standard -- with an initial version that has reportedly reached cross-browser consensus -- described as "a new portable, size- and load-time-efficient format suitable for compilation to the Web."
The Mozilla Developer Network notes that it's experimental technology, and describes it like this:
The UK-based Steve Sanderson, part of Microsoft's ASP.NET team, has put WebAssembly to work in his own personal Blazor project, a Visual Studio extension that can be downloaded from the GitHub site. It's not production-ready and isn't available in the Visual Studio Marketplace.
The project leans heavily on Dot Net Anywhere, an interpreted .NET Common Intermediate Language (CIL) runtime that lets .NET software run on resource-constrained devices that can't handle a full .NET runtime, like Mono.
The Blazor GitHub project has received contributions from four developers, earning 1,085 stars.
It provides a project template to create a standalone Blazor app, not hosted on an ASP.NET server. "The idea is that ultimately you could deploy your client-side Blazor app as a set of purely static files that could be served from any web technology (Rails, PHP, a static file host, etc.)," Sanderson says on the site. "Therefore, server-side prerendering is not supported in this mode."
Using it requires installations of NET Core 2.0 preview 3 or later and Visual Studio 2017.3 or later.
The project has its own Q&A, including:
Could something like this really be practical? How big would the apps be to download?
Yes, it could be practical. A "hello world" app that runs Razor in the browser with this template is around 300KB, which is smaller than typical apps from some other single-page-app (SPA) frameworks. That 300KB includes everything: the small .NET runtime, core libraries, application code, and wrapper libraries needed to bootstrap and interop with the WebAssembly code.
That's before any real optimization attempt. If there was a proper attempt at code stripping to remove all non-called corlib code, it could get smaller.
What about browsers that don't support WebAssembly?
Is this actually .NET in the browser?
It's not the regular .NET Framework or .NET Core runtime. It's a third-party .NET runtime called DotNetAnywhere, which has been updated and extended in various ways to support being compiled to WebAssembly, to load and run .NET Core assemblies, and with some additional functionality such as basic reflection and so on.
Can I build a real production app with this?
No. It's incredibly incomplete. For example, many of the .NET APIs you would expect to be able to use are not implemented.
Why isn't there an issue tracker? How do I file issues?
You don't file issues. There's no support for this. It's experimental.
If you would like to contribute, you can submit a pull request though.
Why does this exist?
To see how well such a framework might work, and how much anyone would care. Note that it's a personal project rather than an official Microsoft project.
More information on Blazor can be found in a July podcast on .NET Rocks! and a Reddit discussion. For more on WebAssembly, check out the brand-new blog post just published today, titled "WebAssembly: A New Hope."
David Ramel is editor in chief of Visual Studio Magazine and Application Development Trends Magazine.