|Blazor .NET In The Browser|
|Written by Mike James|
|Monday, 12 February 2018|
Microsoft has yet another way to create web apps, as if we or it needed one. Blazor could be called .NET in the browser and this might make you think of Silverlight, but things aren't quite as simple.
With Silverlight Microsoft had it all - it was essentially Windows in the browser. The problem was that in-fighting and lack of a clear vision of anything much, coupled with the growing feeling that browser plug-ins were a bad, bad thing, killed Silverlight. A similar attitude seems to have affected the whole of the .NET system with only the languages being kept on, but only if you couldn't rise to the challenge of C++. Today we still have .NET desktop applications, but we also have the fairly useless Universal Windows Platform and the much misunderstood Xamarin framework. We also have so many flavors of ASP .NET that it is difficult to know what exactly is a modern current ASP .NET technology.
Now we can add to the list Blazor.
This has a certain technical interest, even if you aren't interested in .NET, because it gives us some ideas for what could be just down the road because of WebAssembly.
What is WebAssembly?
The good news is that at the moment most of the modern browsers support WASM. The bad news is that the tools to create WASM are in their early days. If you want to create a WASM program then you are probably going to have to code in C/C++ and use a command line compiler. Blazor is roughly speaking a way to write in C# or any .NET language and run in the result in the browser using WASM..
The idea is a bit like Silverlight in that it lets you use C#, but that's about where the similarity ends. It is not a plugin and nothing it makes use of isn't a web standard. From a programmer's point of view the biggest difference is that it doesn't use XAML, or any part of the .NET UI. As this is one of the big attractions of working in .NET, this makes Blazor less interesting.
The whole project depends on the Mono team's porting of the Mono runtime to WebAssembly. This allows .NET code to run in two possible modes. You can take the Mono runtime as a WebAssembly binary and give it your program compiled to IL (Intermediate Language) and let the runtime interpret it.
Alternatively you can compile the .NET code to WASM and run everything as a WebAssembly binary.
This copies the way that things work on the desktop with your code being interpreted at run time by the .NET runtime or being run as native code if you run it though the ngen/CoreRT tool.
If the browser isn't able to run WASM then the compiler falls back to asm.js, which isn't going to be as fast.
You might think that the full compile is the best way to go because of speed considerations, but according to Microsoft this isn't quite so obvious because interpreted code runs fast enough and IL code is more compact than WASM.
So much for the code that does the work - what about the UI?
There are a new set of UI components, which are based on the ASP .NET Razor syntax, for combining markup and C#. It is essentially .NET's reinvention of the way PHP does the job - a terrible idea. This is not a good way to ensure separation of concerns.
Is Blazor a game changer?
At the moment it is difficult to see why anyone would choose to use Blazor. If you have an ASP.NET site and want to extend it with a single page app then there is some synergy, but apart from this the only advantage is being able to write in C#, F# or VB and run on a browser. If you are already in a hole that Microsoft has dug for you, then you might well find Blazor a useful tool.
This is not Windows in a browser. Microsoft had that in Silverlight and threw it away.
Of course it is early days. Blazor is not even alpha and although there is a GitHub page, Blazor is open source with an Apache 2 licence, using it is only for the adventurous. I can imagine many things that could be added or modified to make Blazor very attractive - getting rid of Razor and using XAML for example - and this means that my conclusions are also not even alpha.
Summer SALE Kindle 9.99 Paperback $10 off!!
or email your comment to: email@example.com
|Last Updated ( Tuesday, 26 June 2018 )|