Hello, This is my understanding of Blazor so far, plus my learning experience as a .NET developer struggling with UI development.
What is Blazor?
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
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;
- Blazor Server
- Blazor web assembly
1. Blazor Server
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
- 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.
- 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.
- 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.
- 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.
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.