Towards Blazor
Need for Single Page Apps
Before we delve into what Blazor is and how you can use it for your potential development needs, it will be useful to understand what Single Page Applications (SPA) are and its scope. SPA or Single Page Applications is a web development technique which was coined and recognized as a distinct application architectural pattern, probably a couple decades back. SPA, as the name suggests, is a single page web application whose main intention is to run mostly on the client browser, reduce client-server communication and page refresh. SPAs have only one landing page and any user interaction on that page and all subsequent interactions does not refresh the page to process data and render results on the UI. They generally use Javascript, Ajax, Websockets, or a combination of Ajax, XML, Json to facilitate client-server data transport and communication (without browser refresh) and loading/updating the needed DOM objects/properties on the fly. This type of application architecture and related UIX is suited for web applications (to some extend, scaled down websites) where user wishes to see immediate results/changes/updates on the UI/screen based on what he/she intended while clicking/hovering/dragging/scrolling etc over an interaction element/HTML object, without refreshing the page and waiting for the server to send back the rendered HTML. Examples of such ecosystems include Facebook, Twitter, Netflix, Gmail and other platforms where traversal of user interactions is confined and controlled on the same landing page, at the same time satisfying the intended user experience.
As we saw in the introductory paragraph, SPAs are different from the Multi Page Applications (MPAs) where user interactions and subsequent information flow is structured around multiple pages based on the use case. Examples of MPAs include a complex web based business workflow application or a complex company website with hooks to its internal back-office systems, warehouse applications, e-commerce applications, intranet etc. Examples of application frameworks/technologies that you use to build MPA includes the established .NETCore based ASP.NETCore MVC, J2EE based Spring framework or PHP based Laravel or Zend frameworks. You could build SPAs using these frameworks, but you have to maintain a lot of Javascript / Jquery to bring out the intended UIX. It was at the juncture, Google realized the need for a SPA development framework aimed at modularizing their Facebook app., which is a prime example of SPA model. Hence they developed the Angular framework and ended up creating one of the foundational framework for developing SPAs. Following them, various other frameworks came into existence based on companies that spearheaded the efforts – such as React, Vue.js etc.
What is Blazor?
Blazor (Browser + Razor) is a free open-source web development framework, enabling developers to create interactive SPAs / web UIs with C#, HTML code and Razor syntax. It has the potential to compete with the leading client side development frameworks such as Angular and React. The main reasons being –
- There is huge C# developer base who will be thrilled with the introduction of this SPA development framework which allows them to code in their native language, both on the client side and server side. And bonus ! – they don’t have to rely on Javascript since Blazor allows to use C# instead of Javascript
- Front end / Client side code need not be written in Javascript or Typescript or there is no more need for transpiling code to confirm to various browsers. Blazor utilizes Webassembly (Wasm) that creates byte-code instructions which can execute at native speeds from browser/web app. without the need to convert into Javascript – it provides faster execution time, is forward looking and is supported by all major browsers.