Blazor .net 6 VS Phoenix

I am watching this video Enterprise-grade Blazor apps with .NET 6 - YouTube and it looks super cool.

Can you compare Blazor with the new .net 6 with Phoenix

You probably mean Blazor VS LiveView? For starters Blazor is client side technology. LiveView is comparable to Razor Components aka server side Blazor. How LiveView is implemented is much better. For example in LiveView WebSocket reconnects doesn’t need to go to same server instance. It’s also easier to create realtime apps that use multiple server because you can use Phoenix Channels on server side. LiveView is good state already and it’s getting better and better but server side Blazor feels like an after thought.

3 Likes

The biggest problem with Blazor is that you have to write C# :innocent:. .NET is pretty fast though and they’ve made a lot of effort to bring in the niceties from F#/functional programming in recent C# versions. Still doesn’t do it for me. It’s so much easier doing concurrency on the BEAM.

2 Likes

The problem for me is .NET is now proven to be man-handled by Microsoft in bad ways. I won’t touch .NET for the same reason I won’t use Oracle DB for my database needs. I have enough problems running a business and finding product market fit - why would I add licensing and lawyers into the mix?

I’ll stick with true open source tools like Elixir and Postgres.

4 Likes

IMHO, asking comparisons from “competing” technologies will always generate debates that are prone to this kind of argument. Mostly because your question of X vs Y is very open to interpretation and full of bias by definition… If I may suggest, ask the same question in a dotnet forum so you have a more centered response by filtering the extremes.

That being said, I’ve worked with C# for a long time before starting doing Elixir and I have no regrets. Microsoft made a huge step in the right direction years ago by introducing dotnet core as an open source technology and C# has evolved meaningfully as a language since then. None of this is new though, this is a collective effort from the past 5 years or so.

I started doing Elixir around the time Blazor became a thing in the dotnet ecosystem, so I can’t compare a lot of it with LiveView. But at the time, I remember seeing stuff like dotnet to WASM in the browser which made me feel that it was an overly complicated approach to that problem (and kinda hack-ish). LiveView on the other hand feels like a very simple and elegant solution to the same problem, thanks to the “Elixir Way”.

One thing that made me fall in love with the Elixir ecosystem is that frameworks and tools usually don’t change the approach to the language’s core concepts. I don’t know how to properly put this, but you usually always have a familiar feeling while working inside the ecosystem. Also, by being a statically typed language, C# brings its own challenges which I have happily abdicated to work with Elixir.

3 Likes

Blazor Server is the appropriate comparison with LV, its the only other framework that I am aware of that has stateful conversation with the server, there is a Blazor WASM option too, but then you’ve jumped back into the SPA territory - with all the associated unnecessary moving parts.

The TLDR version is that Blazor server does what it advertises, just slower and much more expensive than LiveView does.

The long version.

First time users:
Blazor is probably easier tbh (I came to it as a dotnet newbie). However if you know Phoenix, LiveView is easier.

Data modelling (this is more Ecto vs EFCore):
EFCore is slow and bloated, I found managing data tedious in dotnet - its not an OO/Functional thing, I actually prefer ActiveRecord over Ecto.
Postgres is a bit more challenging in EFCore.
Ecto 1.5x better productivity.

Auth:
Blazor is a shocker.
Phoenix plugs make this so much easier.

Javascript:
Its harder to easily do popups, notifications etc. You need to use much more JS or libraries (there is a thriving Blazor component library - presumably because its much harder to do your own).
LV wins - you get to be in Elixir 99% of the time - unless you need maps or charts.

Components:
Both relatively easy, LV seems more manageable, certainly more compact.

General Dev:
Blazor has no REPL, its slow to compile and iterate. To get changes on the screen takes 20 to 30seconds.
LiveView 5-10x better productivity.

Cost (AppService only):
Cheapest AppService is USD92 per month for fairly lacklustre and unreliable performance (see below).

Performance and reliability:
Blazor will lose the socket connection quite often - it will not reconnect successfully itself. Ever. Not Ever. Not before the heat death of the universe.
In terms of Dom diffing, UI responsiveness etc LiveView is much more responsive.
General impressions is that LiveView is at least 10x faster. Blazor runs more slowly locally than entry level Gigalixir deployment. My expectation is that no matter how many thousands you spend you will never get anywhere near the responsiveness of LV on fly.io.
LiveView 10x faster. (Erlang/Elixir/Phoenix Infrastructure - seems magnitudes better than dotnet)

Code management, iteration speed, RAD - important for me:
(Probably could assume without saying) Elixir/Phoenix/LiveView is in my experience is 5x more productive, the code is cleaner, much reduced, everything is faster (I would say the same thing about Rails - this is not an OO v Functional thing, I find Rails very productive too).
The complaints that @sergio_101 had above (and @thiagomajesk 's comment on statically typed languages) reflects my real world experience, dotnet is a bloated, turgid slow mess. Blazor is the one of the best parts of dotnet and I still suffer because everything is tediously slow. Slow iteration, slow feedback, poor performance, fragile bloated systems - obviously balanced by an amazing marketing effort which convinced many people who need “serious and reliable tech platform" to choose dotnet. I’ve yet to see any evidence that it has any USP over any other technology, Initially I was enthused by the theoretical speed of C#, its all smoke and mirrors in a real system however, as I said responsiveness with Phoenix feels 10x or more better.

YMMV of course!

1 Like