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 for Converge360.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube