What is Blazor?
How We Used to Develop Web Applications
A while back, we only built applications that ran on the server. These applications generated HTML files to be pushed out to the browser using technologies like ASP.NET, PHP, etc.
It’s funny how we view PDFs using our default browser today. This was sort of the feeling for how web applications were back in the day.
Disadvantages of Server Side applications
Server side applications were great for it’s time. But of course as new technology emerged, the old started to become obsolete or no longer maintained. Whenever technology isn’t maintained, bugs and security issues rise up extremely fast.
Let’s talk about some disadvantages of server side applications. One disadvantage is that the server needs to be configured with the proper software to run the web app.
Runtimes have to exist on the server. Most of the processing power is on the server, which can essentially make page load times very slow. Connection speeds and latency can play a big role on how applications are processed and transported.
Since it’s server-side processing, page post back can introduce processing overhead that can decrease performance and make the user wait for the page to be processed. Now a days this will most definitely be a negative experience. We are in the era of user experience, we can’t be having this issue.
How Are We Developing Now?
I have worked with various cloud applications in my time. We are truly moving towards a future where enterprise companies won’t have the need to have physical servers. Cloud and infrastructure engineers are making developer’s lives much easier.
This is a significant improvement on what we used to do before when applications were completely server side. Now we can have applications running in the browser, without pure reliance on the server.
Blazor improves on how we are developing now a bit further. It offers two main ways to develop with it. The app and component models are the same in both these hosting models.
Let’s take a look at one of the ways to develop Blazor: WebAssembly. Blazor uses WebAssembly which is in all major browsers at this point. But what exactly is WebAssembly?
WebAssembly is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.WEBASSEMBLY
You can execute calls to .NET from within the browser, and it’s a fully-fledged application in the browser. It is wild to imagine that you can run C# in the browser without specific server side software that is limited to a certain range of operation systems.
WebAssembly: The Good ?
- You can use C# to develop rich front-end applications.
- Various .NET components can be reused in your application.
- Best of all in my opinion, you can use Microsoft tooling and debugging. I absolutely love the debugging you can do in C#.
WebAssembly: The Bad ?
- We can’t just write code and run it out of the box. You will need to download and install the .NET Framework and other run time files at least once.
- You are restricted to the limitations of the browser
- Not all .NET Framework components are compatible
Luckily we aren’t just limited to this option. There is another option we can utilize to develop Blazor applications!
Blazor Server Benefits
- App can take full advantage of server capabilities.
- .NET Core on the server is used to run the app, so debugging works as expected.
- Blazor Server apps work with browsers that don’t support WebAssembly.
- The app’s .NET/C# code base isn’t directly server to the clients.
Downsides to Blazor Server
- It can be very slow depending on connection.
- It cannot be support offline, meaning if the connection breaks the app just stops working.
- An ASP.NET Core server is required to serve the app, you can’t serve the app from a CDN (Content delivery network)
Which one to use?
Well if you want powerful client-side applications which will run offline then you should go with Blazor Web Assembly. If you want the full power of .NET and want to run it on all kinds of browsers that aren’t limited, then you should go with Blazor Server.
My Personal Thoughts on Blazor
In my personal opinion, I predict WebAssembly will be the future out of these two hosting options. Sure it has it’s advantages and disadvantages, but it truly pumps out powerful client-side applications.
Speed is a very important factor in a decision to utilize any technology. I want to wait for more Blazor development in order to assess whether or not Blazor stands a chance against popular frameworks and technologies today.
I absolutely ❤️ the C# language, and just thinking about C# in the browser makes me so excited. When .NET Core was first announced, I knew one day it would make huge strides.
Cross platform technologies go well with developers who wish to save time and not have to work out two separate code bases. This is why I think Blazor Server isn’t quite there yet as it has to be hosted on an ASP.NET CORE Server. If it ever gets to the point where you can serve it from a CDN, it will become very powerful.
Thank you for taking the time to read this article! If you want to get started with Blazor, see the links below. These will kick you off on the right track.