DEV Community

Discussion on: How Blazor Is Going to Change Web Development

Collapse
 
nstefan profile image
n-stefan

I replied to a comment of yours on another article but since you probably haven't seen it, I'll reproduce it here.
Your original comment:

"Growing up on .NET, I became a bit biased. I love C# and ASP.NET core. In the meantime Angular and React took over the front-end world, and Node and Express are working to create the Isomorphic stack. If I were a new programmer I'd skip C# and Java and learn server side Javascript using Node and Express."

My reply:

"Whyever?

Latest TechEmpower results as of the time of posting this:
techempower.com/benchmarks/#sectio...
As you can see, Node.js is so far behind ASP.NET Core in all tests, it's not even a contest any more.

As for front-end C#, here's an example: n-stefan.github.io/diabloblazor
It is a port of this: d07riv.github.io/diabloweb
replacing React/JavaScript with Blazor/C#.
Being static it doesn't use a server at all, but server side prerendering (initial rendering) is baked into Blazor and can be used with sites that are hosted by an ASP.NET Core server. There's also server side Blazor, which doesn't need WebAssembly and still behaves like a SPA/PWA - no full page reloads, uses differential rendering, etc.

Edit: added further benchmarks
.NET Core/C# wins 10/10 tests vs OpenJDK/Java:
benchmarksgame-team.pages.debian.n...
At the same time OpenJDK/Java wins 9/10 tests vs Node.js/JavaScript:
benchmarksgame-team.pages.debian.n...

It should be noted that both the TechEmpower tests and these benchmarks were run on Linux. On Windows .NET Core/C# would likely be even faster."

Collapse
 
jwp profile image
John Peters

There's no doubt: the power of C# outshines all Javascript stacks in every way. (For now).

Will Blazor make it? Perhaps but there are no jobs.

There's too many questions like: Will it be the wave of the future? Is it a market disrupter? Will its eco system trump NPM and Javascript? Will MSFT start supporting thier adopters? Are they now all of the sudden loyal?

Will they rewrite VS Code in C# WASM? Never, Electron and Typescript work beautifully for millions of developers daily.

Chrome, the browser that won, will remain a Javascrpt friendly stack.

Many large corporate websites are aleady running Isomorphic Javascript stacks? Need more power? Spin up another server.

Node is making progress on CPU agnostic design. Compiled Javascript in WASM will happen.

Both Java and Javascript are more popular than C# in 5th or 6th place.

Finally, most of people who only grew up on Javascript dislike MSFT passionately. Their only view of MSFT was the inane Internet explorer and Edge. MSFT caused them as much pain as their desktop crowd.

Thread Thread
 
nstefan profile image
n-stefan

Of course there are not many jobs YET, server-side Blazor launched with .NET Core 3.0 only this September, while client-side Blazor is still in preview and will launch in May 2020, if all goes according to plan.

It is possible to host Blazor on Electron for desktop apps:
github.com/aspnet/AspLabs/tree/mas...
However, they haven't stopped there:
blog.stevensanderson.com/2019/11/0...
It does away with Chromium and Node for significant download size and memory footprint savings.

The newer IEs were arguably much better than older ones, while Edge was better still and now there is Chromium based Edge, so nothing left to complain about.

One of the main selling points of Node was a relative speed advantage: no longer true. Another was enabling same language development across front- and backend while others didn't: also, no longer true.

Hell, Python is most popular now and it's a slow, niche language, only ideal for ML/AI. Already for webapps there are many alternatives that are far better and for game development you can forget about it.

Oh yes, some people hate and will hate MSFT no matter what, and that has nothing to do with the quality of .NET Core/Blazor.

Collapse
 
kencarpenter2020 profile image
kencarpenter2020

Those benchmarks look very wrong. There is no way node is 8 times slower than ASP.NET on the same hardware.

Most likely they ran one instance of node on an 8 core machine. Node runs on a single core, while ASP.NET takes advantage of all cores.

You need to configure node as you would in production, using something like PM2 or StrongLoop Process Manager with an NGINX load balancer in front. This allows you to run 8 instances of node so that all 8 cores are used.

The results in this configuration will be very different.

Thread Thread
 
jwp profile image
John Peters • Edited

Please tell us more on how node utilizes all cores. An article perhaps? I confess my lack of knowledge on getting Node to run on all cores.

Thread Thread
 
kencarpenter2020 profile image
kencarpenter2020 • Edited

Process managers like PM2 and Strongloop PM start multiple instances of your app, each of which runs a single thread. By default, they start a number of instances equal to the number of CPU cores.

If any of the instances crash, the process manager will restart them.

strong-pm.io/getting-started/
pm2.keymetrics.io/docs/usage/quick...

You can run an NGINX instance as well to load balance between multiple instances running on a single machine or across multiple machines as well. This is only needed in production. You can run your dev instance with just PM2 or Strongloop directly if you need to test performance. You usually only need to run one instance for most dev work though, which means you can just run node directly.

There is also the node "cluster" module, which you can use directly in your node server code to run multiple instances of your app. I haven't used this recently, but there were some performance issues with it before. Not sure if this has been improved.

medium.com/skyshidigital/6-tricks-...

Node also supports manually firing up threads for whatever purpose you may have. This is often used to create worker threads for any long-running CPU-intensive tasks. The main node thread and the worker thread can communicate, if necessary, using IPC.

It is very important in node to avoid blocking the main thread since no other requests can be handled in that node instance until the work is complete. Worker threads are a good option here.

Thread Thread
 
nstefan profile image
n-stefan • Edited

They are not wrong.

Server config: 14 physical cores, 28 logical cores (HT), 32 GB RAM.
techempower.com/benchmarks/#sectio...

The Node.js plaintext code is running as a cluster of 28 processes.
github.com/TechEmpower/FrameworkBe...

So yes, ASP.NET Core really is that much faster, time to wake up.

Thread Thread
 
jwp profile image
John Peters

Excellent information Ken. Looks like I have some major 2020 studying to do.

Thread Thread
 
kencarpenter2020 profile image
kencarpenter2020

Thanks for the links @n-stefan. Good to know they are using clustering.

I still think something is not optimally configured in the node case though. I could believe a 2-3 times improvement, but 8 times still makes me very suspicious. Benchmark results are notorious for being sketchy or having one configuration optimal and another sub-optimal.

It would be interesting to see the number of requests that each node instance handled to make sure the distribution is fair. The fact that there were 89 errors makes me think that perhaps the distribution was not even, and so some requests errored out.

It would also be interesting to set cluster.schedulingPolicy = cluster.SCHED_RR; mode to see if that helps.

A comparison against PM2 or StrongLoop would also be good to see (might try this out if I have some time in the next few weeks).

Thread Thread
 
nstefan profile image
n-stefan • Edited

The difference is smaller in the 5 other tests.

You could open a PR, if it's good, they will probably accept it. I'm also interested in having Node.js (and all others for that matter) run at its (their) true potential, unhindered by bad configuration and the like.

Collapse
 
besmaili profile image
besmaili

Wake up to see what? to see asp.net is 8 times faster than node js? you better think the other way around. performance is not a only aspect of seciding about a language or framework. node js still makes sense to me even in 2021 cause the web is built around nodejs , productivity is times better in node js than ASP.NET.beeing a .NET developer for the course of years now I am a full-stack nodejs developer and am very pleased doing that. Besides ASP.NET CORE MVC is not 8 times faster than node js by any means even according to latest techempower benchmark. see below :

it's time to make change in you'r stack and get things done 5-10 times faster.

Thread Thread
 
jwp profile image
John Peters • Edited

Microservices replaces both node and asp.net. Today I recommend Azure Functions as back end development is dying. It's all cloud now, which is both infinitely scalable at click of a button.

Thread Thread
 
nstefan profile image
n-stefan

You're comparing Full (aspcore) and Micro (fastify) implementations, nice job :)
According to the latest results as of writing this:
techempower.com/benchmarks/#sectio...
asp.net core has a composite score (considers all tests) of 6,408, fastify 1,594, nodejs 1,545.
That makes asp.net core 6,408 / 1,594 = 4.02 times faster than fastify and 6,408 / 1,545 = 4.14 times faster than nodejs.
I'm productive enough with ASP.NET, especially now with Blazor, and considering the speed advantage I see no point in switching, thank you.
I can use ASP.NET to write microservices and deploy them to local/cloud Docker/Kubernetes; or to write Azure Functions; or even use it on the front end thanks to Blazor WebAssembly.

Thread Thread
 
jwp profile image
John Peters

Any numbers on these two?

  • ASP.NET in .NET 5.0 endpoint
  • Azure Function doing same work.
Thread Thread
 
besmaili profile image
besmaili

@n-stefen
lithium is in the first place, should we use it for daily web-dev jobs? I say it again and again. speed is not the only factor. If you say I am productive with blazor you most probably haven't experienced full-stack javascript.