Blazor WebAssembly: The Future of Your Web Application Development

By July 9, 2020Articles

With Blazor moving towards a full release and, .NET 5 fast approaching, could web development that embraces .Net and WebAssembly resolve many of the challenges the expansive JavaScript environment has created? Dave Howell reports.

Think about how your company currently develops applications for the Web. For the last two decades, JavaScript has reigned supreme as the core development language for the Web. The number of development frameworks has proliferated fragmenting the development landscape and increasing complexity.

In 2019, Microsoft announced Blazor. Daniel Roth, Principal Program Manager, ASP.NET said: “A little over a year ago we started the Blazor experimental project with the goal of building a client web UI framework based on .NET and WebAssembly. At the time Blazor was little more than a prototype, and there were lots of open questions about the viability of running .NET in the browser.”

Roth concluded: “Since then we’ve shipped nine experimental Blazor releases addressing a variety of concerns including component model, data binding, event handling, routing, layouts, app size, hosting models, debugging, and tooling. We’re now at the point where we think Blazor is ready to take its next step.”

Moving application development away from JavaScript has become somewhat of a Holy grail for development teams. Could WebAssembly offer client-side technology without browser plugins? What’s more, the promise is application development using C# to target the WebAssembly virtual machine – all with the ability to run .NET code in any scenario.

The technical challenges of developing rich user experiences within the browser either on the desktop or mobile are manifold. A lack of efficiency when executing commands are often at the route of poorly performing applications.

“WebAssembly will drive a sea change in web development because it opens up client-side web application development to programming languages other than JavaScript,” commented John Gibbons, CEO, Oscore. “JavaScript has become the de facto standard over the past ten years, not because it’s a great language – in fact in many ways, it can be a nightmare to use. But it’s been the only option for client-side development and, as the web grew exponentially, so did JavaScript.”

“Next came a huge base of JavaScript client-side programmers who drove a wave of server technologies also based on JavaScript, most notably Node.js. With the advent of Blazor WebAssembly, we are likely to see the same evolution but in reverse: Given the huge success of Microsoft’s C# programming language and ASP.NET Core as server technologies, we’re likely to see an explosion of interest in using that same language and framework to do client-side programming, now that Blazor WebAssembly has made that possible.”

WebAssembly offers massive efficiency gains as WebAssembly Modules (WASM) are already in binary format; there is no need for the code to be parsed, which delivers marked improvements in performance. However, WebAssembly in its current form, must still be tied to JavaScript for API access, for instance. This could all change thanks to Blazor.

.NET on the Web

Developing for the Web is complex. Your company may have made substantial investments in backend development with a .NET stack and highly qualified developers. However, when your attention turns to frontend development, JavaScript raises its head. Forcing your C# coders into a JavaScript workstream can seem like forcing a square peg into a round hole. Wouldn’t it be great to leverage your enterprise’s existing .NET skills for frontend development?

Speaking to Oscore, Egil Hansen, Managing Architect at Netcompany said: “Blazor is remarkably simple and quick to become productive in, especially if you are already familiar with C# and ASP.NET Core development. The tooling around Blazor, while still not perfect, provides us with the File-New-Project experience that developers use to from the Microsoft platform, and allows us to get started quickly. The interoperability with the JavaScript will allow developers to utilize the many good libraries out there, and quickly enrich their applications.”

There are two flavours of Blazor: Blazor Server runs all the logic on the server, in the usual ASP.NET way. The version we’ve been waiting for, though, is Blazor WebAssembly. Single-Page-Apps (SPAs) written in .NET can run directly in the client browser. And that’s where things get very interesting.

With Blazor WebAssembly, both the client and the server code are written in .NET, allowing you to share code and libraries between both sides. Because it’s .NET code at both ends, you can reuse your existing server-side code and your existing libraries to create the client-side part of your application. So Blazor allows you to build reusable web UIs, on a stable platform, using .NET end-to-end.

Blazor also offers potentially massive performance gains. Blazor runs your client-side C# code directly in the browser, at near-native speeds – this is thanks to WebAssembly, which ships in all major browsers. No need for additional downloads or plugins as WebAssembly (WASM) is a new standard.

And Blazor is flexible. There’s an option for Blazor to run all the logic on the server-side if needed. And Blazor WebAssembly gives you a choice of languages to choose from, so it doesn’t require you to only use C# on the server-side (anyone for F#)? In fact, you don’t even need to use .NET on the server-side at all! If you already have a legacy backend written with PHP, Rails, or anything else, you can still write .NET client-side code to run against it.

A new age of Web application development

Blazor is still very much in the experimental stage – albeit in an advanced state of development. The promised ability to combine C# and HTML using Razor templates – all on the client-side – is a potentially powerful combination many developers have been hoping for since the initial promise of SilverLight. The critical difference with Blazor is that it runs within the browser sandbox with the same limitations JavaScript has.

How Blazor has been architected is the real innovation: Blazor differs from established frameworks such as ReactJS or Angular in that Blazor uses different renderers to create web-based UIs that will also run on mobile browsers. Developers will also have the ability to write once use many times a library of components that Blazor WebAssembly can be used with each new application. This offers a considerable gain in productivity over established development processes.

The question, then, is should your development teams embrace Blazor WebAssembly now? The technology is its early days, so it’s not going to replace the established stalwarts of web programming anytime soon. But it holds tremendous promise for web developers and programmers.

WebAssembly makes development so much easier, providing the shortcuts that can eliminate inefficient processes. It’s important to remember that JavaScript isn’t going to be swept away.

Netcompany’s Egil Hansen concluded: “If you dislike JavaScript and the ecosystem around it such as the build tools, then Blazor is a breath of fresh air which will offer you new capabilities that you have not had before in the C# Microsoft ecosystem. If you enjoy working with both JavaScript and TypeScript, Blazor provides another tool in the toolchain, but it also has its own advantages and disadvantages.”

Blazor offers, at the moment, a glimpse of a possible future where web application development becomes more efficient and far less complex. All eyes are on Microsoft to see how they evolve this enticing architecture.

Using .Net Core, Microsoft Azure, Cosmos DB or Power BI in a live or upcoming project? Reach out to us using our contact form, and a specialist will be in touch within 24 hours. You will also receive an email with contact details should you wish to get in touch immediately.