In November 2018, when Blazor was still an experimental project, I presented it at an office event. To everyone’s surprise, my PowerPoint was created using Blazor, a detail I revealed at the end of the presentation.
I followed the evolution of this experiment, which later became an officially supported product, culminating in the release of Blazor WebAssembly in May 2020. This was followed by a presentation at Blazor Day in June, which I delivered on three more occasions that year, as well as several episodes of the Bracket Show covering the topic. Since then, I’ve worked on a full-time Blazor project starting last June.
I’ve also spent quite a bit of time raving to my colleagues about how wonderful Blazor is and why it’s a game-changer in web development. Today, I’d like to share why I believe this technology is revolutionary, but I’ll steer clear of the deeply technical aspects (we cover that on the Bracket Show).
History of the Blazor Web Framework
In November 2018, I presented Blazor when it was still an experimental product at an office event we hosted. To everyone’s surprise, my PowerPoint was created with Blazor, a detail I revealed at the end of the presentation.
Since then, I have closely followed the framework’s progress. Blazor transformed from an experiment into an officially supported product, culminating in the release of Blazor WebAssembly in May 2020.
After that, I presented at Blazor Day in June, and continued discussing Blazor in three additional conferences that year, along with several episodes of the Bracket Show. By June, I started working on a full-time project utilizing Blazor. During this time, I constantly shared with my colleagues how advantageous it is to use Blazor and how it enhances productivity.
Fast forward to November 2023, Microsoft introduced “Blazor United,” a version combining the best aspects of “Razor Pages,” “Blazor Server,” and “Blazor WebAssembly.” This merge allows developers to seamlessly switch between different rendering modes or mix them within the same page. Essentially, Blazor United creates a unified framework for all web UI scenarios.
- Blazor Server: Similar to React’s Server-Side Rendering (SSR), Blazor Server delegates much of the processing to the server.
- Blazor WebAssembly: Utilizes WebAssembly to run real .NET code directly in the browser, taking full advantage of client-side performance.
In this article, I want to share why I believe this technology is a major revolution, but without diving too deeply into the technical aspects (I’ll leave that to what we do with the Bracket Show).
What is Blazor?
For those unfamiliar with Blazor, let me break it down.
Blazor is a framework designed to build single-page applications (SPAs) using only C#. While JavaScript is still available, it’s no longer the primary language as it is with popular client-side frameworks like Angular or React. And unlike Silverlight, Blazor doesn’t require any browser plugins, thanks to WebAssembly, an open web standard that allows binary code execution within the browser.
In simple terms, Blazor allows developers to write compiled code that runs directly in the browser without being transpiled into JavaScript, making it a highly efficient alternative to traditional frameworks.
Fun fact: the name “Blazor” comes from combining “Browser” with “Razor” (the ASP.NET page-generating engine). Blazor enables developers to build interactive, client-side UIs using C#, offering a robust alternative to JavaScript.
Is Blazor Worth Learning?
One of the main benefits of Blazor is that it simplifies development by allowing you to work with a single programming language—C#. This streamlines the development process, especially for full-stack developers who are familiar with C#, MVC, and ASP.NET. They can jump into Blazor development with minimal learning curve since they already have most of the necessary skills.
Of course, staying up-to-date with new technologies and learning new languages is important. However, when given the choice between mastering a single toolset or juggling multiple frameworks with varying levels of proficiency, most developers will choose the one that offers greater efficiency. For C# developers, Blazor presents that very opportunity.
Advantages of Blazor
Avoid Errors with a Single Programming Language: C#
Then there’s the programming language, namely C#. This is obviously a matter of personal preference and a business choice, but in my opinion, the advantage lies in its strongly-typed nature.
With JavaScript and TypeScript (I mention these given their common use in web development), it’s easy to introduce errors in our applications simply by making a mistake in the name of a property or variable. You only realize it when running the application, and it’s not always obvious where the error originates.
And even if it is, we have to admit that we should have caught that error earlier, before even executing our application. This is where Blazor, and C#, stand out.
Strongly-Typed Programming Language
By using a strongly-typed language, you can’t make mistakes with the name of a property or variable—the application simply won’t compile. You can’t decide to add a property on the fly to an object—the application won’t compile.
This provides security in the application’s functioning (even before we talk about unit tests to ensure proper functionality), and saves us from having to go back into the code to fix a typo that caused everything to break.
Avoid Code Duplication
Another important point in favor of Blazor is code duplication, or rather its elimination.
Throughout my career, which began with VB6 Windows applications, I’ve always been told to avoid duplicating code. “You should extract a function to avoid duplicating code,” or “You could use polymorphism to avoid repeating code common to your objects,” and so on. Then one day, I worked on a project with C# on the server side and Angular with TypeScript on the client side. That’s when I started hearing phrases like:
“For the model exposed by your API, you’ll need to create an identical object on the client side. And don’t forget to update it when you make changes.” or “Validation should be done on the server side. However, you also need to do the same kind of validation on the client side so the user can’t input just anything.”
We ended up duplicating code, which we had been avoiding for years! It didn’t make sense to me, and this kind of setup obviously adds the risk of forgetting a change, which you’ll only realize when testing the application.
With Blazor, this problem simply disappears. Blazor allows libraries to be shared between the client and server, meaning we can easily centralize communication objects between client and server, as well as validation logic. No more repetition, which boosts productivity, standardizes behavior, reduces the risk of errors, and above all, avoids maintaining the “same code” twice.
In short, I believe Blazor presents four main advantages:
- Use of C# and .NET: Developers can leverage their skills in C# and .NET to create web applications, reducing the need to learn JavaScript or other front-end frameworks like React or Angular.
- Performance: Thanks to WebAssembly, Blazor WebAssembly applications can deliver near-native performance, making it ideal for resource-intensive applications.
- Security: Blazor applications benefit from the inherent security and robustness of the .NET ecosystem, including authentication, authorization, and protection against common vulnerabilities.
- Shared Code: Blazor allows code sharing between front-end and back-end, avoiding code duplication. This greatly facilitates maintenance and improves code consistency.
Comparing Blazor to Other Frameworks
When compared to other frontend development frameworks like Angular, React, or Vue.js, Blazor stands out by allowing developers to use C# and .NET for client-side development. While the aforementioned frameworks primarily rely on JavaScript, Blazor offers a robust alternative that appeals to .NET developers who prefer to work within a familiar ecosystem.
Blazor: The Future of Web Development?
I hope this article has sparked your interest in Blazor. It’s an innovative framework, and it’s here to stay. With ongoing efforts to make Blazor the go-to language for web, mobile, and desktop applications, the likelihood that you’ll use Blazor in the near future is high—especially if you already develop in C#.
If you’d like to learn more, feel free to check out our Bracket Show YouTube channel for in-depth videos.