News

Next for Blazor: AOT for 'Massive Speed Gains'

When it comes to Blazor, Steve Sanderson is The Man, helping to take the red-hot project -- enabling web apps with C# instead of JavaScript -- to new frontiers, such as Progressive Web Apps (PWAs), mobile, desktop, native and more.

Officially listed as a "developer on the ASP.NET team," he's the guy who even used Blazor to create Flutter apps as a demonstration of its capabilities, though that's not something Microsoft is officially planning.

This is all done by changing the rendering target from the default, web, to those other areas.

As Microsoft's point person for Blazor, Daniel Roth (officially principal program manager for ASP.NET), said last year, "Blazor was architected from the beginning so that its renderer was extensible. The default renderer in Blazor renders HTML, and that's why you use Blazor to build Web applications, not too surprising there, but the renderer can be replaced. In fact you can replace it with a different renderer that renders to whatever you want like. You might render instead to native controls."

Since then, Blazor -- whose client-side component, Blazor WebAssembly, was just released in version 3.2 -- has targeted PWAs along with native mobile apps

At this week's online Build developer conference, Sanderson covered some of those in a presentation titled "Modern Web UI with Blazor WebAssembly."

Blazor Capabilities Demonstrated at Build by Steve Sanderson
[Click on image for larger view.] Blazor Capabilities Demonstrated at Build by Steve Sanderson (source: Microsoft).

After demonstrating a project that included Blazor capabilities such as authentication, code sharing, JavaScript interop, PWAs, in-browser data storage, offline support, localization, responsive layouts, and more, he provided a peek at what's ahead.

"So maybe you are wondering what the Blazor team spends its time doing these days?" he said. "Well, the answer to that is, we are already hard at work on the next major release. We've got some big enhancements to Blazor planned for .NET 5, which includes some general component programming model improvements, which have been requested by the community, as well as some major items like hot reloading and CSS isolation."
Blazor Improvements Planned for .NET 5 in November
[Click on image for larger view.] Blazor Improvements Planned for .NET 5 in November (source: Microsoft).

Prominent in the list of planned improvements is ahead-of-time (AOT) compilation, something developers are eagerly awaiting. In fact, in response to our article announcing Blazor WebAssembly titled "Blazor Finally Complete as WebAssembly Joins Server-Side Component," a developer commented, "The AoT problem needs to be solved before they can decorate themselves with 'Complete.' "

The Uno Platform actually claimed an industry first with WebAssembly AOT in February, but it's on Microsoft's list as well as indicated by this GitHub issue: AoT compilation #5466 It was opened by Roth way back in January 2018, and this January he commented on it:

Yes, there has been progress. There is an implementation of AoT compilation to WASM in the https://github.com/mono/mono repo and the runtime has been updated to support executing a mixture of .NET IL and compiled WASM files. However, the AoT support will not be ready for the upcoming May release. We will revisit shipping it for .NET 5.

In announcing Blazor WebAssembly 3.2 preview 4 in April, Roth followed up:

The .NET runtime used by Blazor WebAssembly is doing IL interpretation – there's no JIT – so this does affect the performance of CPU intensive workloads. For .NET 5 we are looking at adding support for ahead of time (AoT) compilation that we enable precompiling hot paths to WebAssembly as a way to improve runtime performance.

Sanderson, in this week's presentation, offered more: "There are also some WebAssembly-specific enhancements that we're looking at, which includes the ability to pre-compile your dotnet code all the way to WebAssembly bytecode ahead of time, which can lead to some pretty massive speed gains." Those WebAssembly-specific improvements also include a multithreaded runtime and lazy loading.

In fact, those items and many more such improvements is presented in the Blazor Roadmap for .NET 5 GitHub issue.

It states:

This issue is going to list the big deliverables the Blazor team is considering for ASP.NET Core 5.0 release. While we hope to deliver all of these issues, there are still many unknown and things will change as we go. Please note, that these are the major investment areas and in parallel work will be happening to bring in many smaller fixes and enhancements including community contributions.

It lists:

.NET 5, of course, is shipping in November, though some planned functionality has been delayed because of the COVID-19 pandemic.

Overall, developers commenting on Sanderson's presentation are excited about the coming improvements. Of course, eliminating JavaScript reliance is high on the list of .NET developers coding in C#, with comments like:

  • "The day Javascript is dead, buried and forgotten the better.. it's a shame browser vendors *cough* google are so attached to it. Everything that has been built around keeping it relevant and just barely usable is just rubbish. Something better needs to fully replace Javascript completely and be supported in the browser properly. WASM"
  • "JS is a devilish evil, and Angular is hell ;-)"
  • "Thanks for the great presentation, hope you guys make genuine effort into making Blazor a complete replacement for js libraries so that i can stop learning new js libraries every week. if you guys actually push Blazor wasm , a large community will start using it and it could be the next react js or bigger. wasm ftw."

Reflecting the overall kudos for Sanderson's presentation, one developer chimed in: "Game changer! Fantastic job! Thank you!"

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube