Saturday, November 28, 2020

Blazor Webassembly notes

Blazor Notes

I believe that Blazor Webassembly apps are now the only sensible way for .NET developers to write web applications. My recent experience with the officially released Blazor Webassembly platform confirms that it is the most productive way of writing apps to run in the web browser. I estimate I can write a typical business app in Blazor about 10 times faster that an equivalent server-side ASP.NET app, and it probably takes about one tenth the amount of code. A similar app created with a JS framework like Angular would require millions of lines of library code, special skill training and tools that are foreign to the .NET ecosystem.

The most stunning advantage of Blazor apps the fact that they are alive inside the browser and have a stateful lifetime, which frees us from the dreadful burden of the primitive request-response pipeline associated with server-side apps like ASP.NET. The server-side request-response model is as primitive as an old CB radio ... send → receive → send → receive ... over and over with a complex pipeline of events and all sorts of tricks required to maintain state and interact with JavaScript on the client.

The Blazor development and runtime model is so simple that I will never write an ASP.NET app of any sort again, they are dead to me. I also hope that JS frameworks will quickly become a footnote in the history of IT under the heading "Idiotic Fads of the 21st Century".

If you need a crash course on Blazor then I highly recommend the set of videos on Carl Franklin's Blazor Train website.

My own hobby app Blazing Hoarder browses the contents of the Nancy Street Collections Database. This app has grown from the very first working Blazor app I ever wrote back in January 2018. The first version was working after a few hours of experiments on a Sunday afternoon, which is much less time than it took to watch the 9 hour long Pluralsight video course on AngularJS (actually, I only watched the first 4 hours before giving-up in disgust at the complex idiocy of it all). The reason I could write my first Blazor app so quickly was because I was using highly familiar tools like Visual Studio, Razor syntax and C#.

Blazor has been officially released for 6 months now (at time of writing), and I can sense the rapid change in public awareness as more and more videos, articles and discussions are appearing and increasing Blazor's popularity.

There are even discussions about the Webassembly virtual machine running on practically any computer or device, which I find a bit troubling, as it wasn't invented for that purpose. I would rather see .NET become a cross-platform standard, as it's far richer and more mature.

Web Services

A Blazor app will typically need to talk to a web service of some kind to do useful work. REST style services are the most popular, and for several years I have been creating them using the Visual Studio ASP.NET Web API project template. However, I hate Web API projects for the same reason I hate ASP.NET app projects: there is a huge amount of repetitive plumbing code and countless mysterious conventions to be followed.

Azure Function Apps with HTTP triggers are an attractive alternative to web services because they are much simpler to write and deploy. They are effectively a group of service endpoints with serverless hosting.

No comments:

Post a Comment