DEV Community

Cover image for Letter to Blazor
Andrea Chiarelli
Andrea Chiarelli

Posted on

11 1 2 2 1

Letter to Blazor

Dear Blazor, I met you when you were still in your infancy. I started playing with you when you could barely stand up...

The Promise

Even though you were still frail, your ambition was exciting: to allow developers to create web, desktop, and mobile applications using only C# and Razor. Not bad at all. It was a bit like dreaming of becoming an astronaut when you grow up. πŸ§‘β€πŸš€

You started with the web, promising to dethrone JavaScript and do much better than that old-timer. You promised that developers only need to know C# and Razor to create efficient web applications, whether they run on the server or the browser. No more complications to make a SPA communicate with the server. You, developer, create your components in Razor and all the logic in C#. The framework will take care of transforming everything into an application that runs on a web server or in a browser. Don't worry. Everything will happen behind the scenes in a linear and transparent manner. πŸš€

Old Memories

Who knows why, but those promises brought to my mind something already seen: memories that I thought I had completely erased resurfaced. The promise of Web Forms resurfaced in my memory: a unified paradigm for web development, whether the application logic runs on the server or the client. The framework would have taken care of doing the right thing. This promise created quite a few disappointments at that time. Many developers who were approaching Web programming for the first time got confused. But perhaps now things have changed, times are different, we have different technologies. Blazor is not Web Forms. πŸ€”

What a Wonderful World

You, Blazor, have made it possible to create fantastic applications that run on the server and on the browser. You enabled components that can be shared between the server and the client. And your followers are not few. You have enchanted many. Not just those who hated JavaScript - that was easy - you also attracted those who were familiar with JavaScript. In short, your dream was within reach.

You enabled the reuse of the same Razor components in MAUI to create desktop and mobile applications, as you promised. Many .NET developers have started to idolize you. 😍

With .NET 8, you've gone further. Not only can developers use the same programming model to build server and client applications, but now they can decide at the level of individual components whether it should run on the server or the client. They can even decide that a component starts as a server component and becomes a client component. Crazy stuff! 🀯

A Crack in the Wall

Even though I have followed your growth, I can't say I know you well. I only played with you in a limited scope. I have a narrow view of you, I admit it. But the little I got to know about you left me a bit puzzled.

Ok. Many of the promises you made, you kept. But from what I could see, there are aspects that resemble me - no offense - more like a big deception. πŸ˜’

You promised that we wouldn't have to worry about JavaScript anymore, but every now and then there are things that you don't allow us to do. And so we inevitably have to communicate with the old man through JSInterop, and it's not a walk in the park.

You promised a unified programming model, where we didn't have to come up with tricks to circumvent programming problems that the not-so-simple coexistence of JavaScript and HTML has accustomed us to. I would have been a unified and consistent model where we create a component and don't need to worry about how and where it will be rendered and executed. The framework will handle everything.

So, we write an interactive auto component that needs to make an HTTP call to the server. Follow all the simple rules, but it doesn't work. Why? You also have to register HttpClient on the server. But why? Due to how the framework works under the hood. 😨

And what about the combination of render mode and interactivity management? How should I go about making my application today? Interactive WebAssembly or Interactive Server? But maybe it's better Global Interactive Auto, so it takes care of everything. The best way to get a headache is the day something doesn't work and you can't go back. As someone said, Blazor is absolutely amazing, until it’s not.

Then, you want to add support for authentication. A fairly common operation. Which application is without authentication nowadays? You enter a nightmare. How do I transfer the authentication state between the server and the client parts of a Blazor application? Well, just implement a few classes here and there. Why? Didn't you promise us that there wouldn't be any more need for tricks and gimmicks to do simple things? Yes, but this depends on how the framework works. 😞

Ok, now with .NET 9 you've simplified it, but only after your supporters went crazy trying to get the server and client to communicate about the authentication state. And in any case, it’s still a developer’s burden to tell you what to do to make them transfer the serialized authentication state. But wasn't the framework supposed to take care of these details?

A Big Deception?

What about the programming model you promised us? You had promised us that it was no longer necessary to know how JavaScript works, its interaction with HTML, etc. You had promised us a simple and unified model β€” a model that abstracts the underlying complications: HTTP, HTML, JavaScript, AJAX, etc.

I feel like you replaced a complex model based on standard stuff with YOUR model. Now, instead of knowing how HTTP, HTML, and JavaScript work, I have to understand how YOU work internally to create my applications. And then I wonder: where is the gain? πŸ€”


P.S. This letter is not meant to be a complaint against the work done by the Blazor team. It is merely an invitation to not trust abstractions when they are pushed too far. Not all complexity can be hidden behind an abstraction. Even if the model proposed by an abstraction seems to work, you always need to have an idea of how things work under the hood when they don't behave as expected. Be enthusiastic, yet pragmatic.

Top comments (8)

Collapse
 
pengeszikra profile image
Peter Vivo β€’

I am from a challenging direction: Z80 -> turbopascal/8086asm -> ... -> Flash -> JS -> React -> JS, but now I daily based work with other teams who is coding in .NET ( not Razor ), we are working on a real complex wordwilde insurrance applications ( tons of programs and technic ). As I saw the .NET development is really strange for my side because those guys are stick so heavy to their IDE and spending a countless hours to play with OOP concept even for a simple solution.

I know HTML/JS system is really strange compare to .NET, but this strange feeling is also true from other angle.

You are totally right until Razor try to make web development by WASM which is also can handle the DOM manipulation by JS code, that process simplicity never mach to a simple HTML/JS solution.

Also important to know in HTML world the things live cycle sometimes just a few sec. Content and layout, visuals changed by so frecuently, that why the JS dynamism win this race.

Collapse
 
nammadhu profile image
Madhu β€’

You are right man, it's been nearly 6-7 years but still didn't grown as expected... Many things are under toss...
Microsoft should make it but faster ...
Fluent -UI making it but still not enough.
I hope this can be only improved if Microsoft adresses some best scenario based use case examples addressing and let user to add more

Collapse
 
andychiare profile image
Andrea Chiarelli β€’

Honestly, I don't think this is due to Microsoft's efforts to consolidate the framework. I believe it is a problem inherent in trying to abstract something complex: client-server interaction.
In my opinion, any attempt to do so will eventually replace existing problems with new ones.
At this point, the question is: is it worth it?

Collapse
 
wezea profile image
Kristof β€’

I watched the development of Blazor with interest, but it never really clicked for me. I want to see an enterprise application built with it, as the ultimate showcase. Is there one already? Even though JavaScript gets a lot of hate these days, I am still happy with React and Typescript. .NET is running on the server and with the latest frameworks like react-router (Remix) a lot of the tricky parts of React are gone.

Collapse
 
frickingruvin profile image
Doug Wilson β€’

Thanks for sharing this! I love C# and .NET Core, but I've more recently been working much more with Java and Spring Boot.

Microsoft has proven ... unreliable/untrustworthy in the past in just the ways your article describes, trying to force developers to "lock in" to their platforms and solutions rather than just focusing on building the best platforms and solutions by remaining open and innovative.

In the Java world, TeaVM + Flavour is considered a "better Blazor". I haven't used it, but thought I'd mention it.

Thanks again, and best of luck!

Doug

Collapse
 
keyru_nasirusman profile image
keyr_syntax β€’

C# is one of the best programming languages ever created until now. It is awesome when used for web backend and Desktop Apps. But let us be honest, is C# really suitable for web frontend and Mobile Apps?

Collapse
 
andychiare profile image
Andrea Chiarelli β€’

Why not? For frontend web apps, you could use C# to mimic whatever JavaScript does. For mobile apps, what doesn't C# have that Java or Swift have?
The point here is not the programming language but the framework pretending to hide the underlying architecture

Collapse
 
stephgrino profile image
Stephane Pellegrino β€’

Try Vaadin ? (but it is not C#)