Haron Rono
Haron Kipkorir

Haron Kipkorir

Blazor .NET

Haron Rono's photo
Haron Rono

Published on Sep 3, 2020

4 min read

Subscribe to my newsletter and never miss my upcoming articles

Hello, This is my understanding of Blazor so far, plus my learning experience as a .NET developer struggling with UI development.

What is Blazor?

It's a .NET UI framework that allows .NET developers to make full stack single page web applications using .NET. Think of it as the way NodeJs is to JavaScript, it allowed JavaScript developers to run JavaScript on the server. Blazor is partly enabled thanks to WebAssembly.

What is WebAssembly?

According to Wikipedia's post on WebAssembly

WebAssembly (often shortened as Wasm) is an open standard that defines a portable binary-code format for executable programs, and a corresponding textual assembly language as well as interfaces for facilitating interaction between such programs and their host environment.

You didn't get that? Yeah, me too. But let me quote this, still from Wikipedia

In order to use Wasm in browsers, users my use Emscripten SDK to compile C++ (or any other LVVM-supported language such as D or Rust) source code into a binary file which runs in the same sandbox as regular JavaScript code.

Now, that definition or quotation kind of makes sense. In essence it means, that if any language can compile their source code into a WebAssembly binary-code format, then it can run on any modern web browser that supports WebAssembly. A good example of a language that I think has excelled so far in the implementation is Rust. Thanks to Blazor, .NET now also has support for WebAssembly.

Enough of that and back to Blazor,

Blazor is currently offered in two ways;

  1. Blazor Server
  2. Blazor web assembly

1. Blazor Server

This was the first to be released last year, with long term support. Here, all the code runs on the server as the name suggest. When the user initially requests the server, .NET will set a SignalR enabled real time connection with the server. Depending on what the user does, an event will be triggered that only affects the selected component. Describing this makes me think of React, because it's the only JavaScript framework I've tried to use successfully and they share the same idea about components.

2. Blazor WebAssembly

This was released this year, that is the long term support version of it. Here, all the code runs on the client, i.e. the code is compiled into DLL files and sent to the client all at once. It works almost the same as the Blazor Server except for little differences.

What is the difference between Blazor Server and the Web Assembly

  1. In Blazor Server the code gets compiled on the server and HTML page or section of a component sent to the client, while in Blazor WebAssembly, all the UI logic is done on the client, all responses to event triggered by the user run on the clients device.
  2. Since Blazor Server runs on the server, the user cannot access the C# code, but this is not the case in Blazor WebAssembly where the user can access all the C# code with the right decompiler.
  3. In Blazor Server, you can access the database directly, but in Blazor WebAssembly, it's not safe to access the data directly and one needs an API in order to do so safely.
  4. Blazor Server has scale issues since all new user to your site, adds another SignalR real time connection with the server, while in Blazor WebAssembly there's no performance or scale cost, since the user downloads all the file once, and the User runs those UI on his/her device. This said, Blazor Server can support up to 20,000 sessions at a time on an average Server.

Summary

I have enjoyed using Blazor so far, I actually love it! A short story, I was to use Blazor last year actually but I didn't know ASP.NET at the time, so I decided to study ASP.NET first, because they technically work together. But ever since I decided to use Blazor, I think my learning experience has been easier comparing to the struggle I faced using JavaScript. I think if I spend more time doing it, my UI will improve significantly and I'll be one step closer to becoming a true full stack web developer, if that is even a thing.

Thanks for taking time to read this. Comment or start a conversation about this post, I'm not sure what hashnode offers for that. You can also tell me posts that you want to see me write.

If you love this post, you can always: Buy Me A Coffee

 
Share this