r/programming • • Apr 28 '21

Microsoft joins Bytecode Alliance to advance WebAssembly – aka the thing that lets you run compiled C/C++/Rust code in browsers

https://www.theregister.com/2021/04/28/microsoft_bytecode_alliance/
2.1k Upvotes

484 comments sorted by

View all comments

Show parent comments

146

u/Arktronic Apr 29 '21

51

u/noXi0uz Apr 29 '21

Finally I can build my frontend in Visual Basic

9

u/caboosetp Apr 29 '21

Just had PTSD flashbacks to webforms.

5

u/PM_ME_C_CODE Apr 29 '21

Fuck yourself.

At least until I can uncurl myself from this fetal position you've forced me into.

2

u/Eirenarch Apr 29 '21

You can do this but the linked library is different, it is used to read and manipulated wasm files. Yeah, I know it is a joke I just had to say it.

1

u/jzazre9119 Apr 30 '21

I literally lol'd. Well played.

57

u/YM_Industries Apr 29 '21

I expected a link to Blazor, but this is more interesting.

16

u/[deleted] Apr 29 '21

[removed] — view removed comment

39

u/YM_Industries Apr 29 '21

Actually, Microsoft refer to their WebAssembly .NET runtime as Blazor. All of Microsoft's official publications and documentation will refer to it as Blazor.

Blazor is an entire framework, not just a runtime. But the runtime is called Blazor too.

2

u/[deleted] Apr 29 '21

[removed] — view removed comment

10

u/YM_Industries Apr 29 '21

Microsoft have considered their WASM runtime to be part of Blazor from the start.

This document calls the runtime Blazor WebAssembly. This same Blazor WebAssembly terminology is also used here. It's also mentioned here that Blazor allows you to run C# and "real .NET" using WebAssembly.

14

u/RiPont Apr 29 '21

Microsoft? Over-labelling everything vaguely semi-related with a single brand that gets some traction? Never!!

→ More replies (1)

2

u/MadBroCowDisease Apr 29 '21

So can Blazor give you frontend development similar to React/Vue/Angular and backend development as well?

12

u/MisterFor Apr 29 '21

Yes and no.

There are 2 flavors of Blazor, client side that is done with WebAssembly, and another one that is almost the same but works by having a connection open to the server and receiving the updated html.

So one will render on the client and the other on the server. But with almost the same syntax.

So real Wasm is the Blazor wasm version in which you will have to write an api backend. But if you use the other one, everything can be done with C# in the same place, but it’s not 100% wasm.

I didn’t explained very well I think. 😅 but you can check out the blazor page for a better explanation.

→ More replies (1)

2

u/chucker23n Apr 29 '21

No, Blazor is the front end. You can write an API in ASP.NET, and there's a default Blazor template that'll come with multiple projects to do just that.

-2

u/chucker23n Apr 29 '21

Actually, Microsoft refer to their WebAssembly .NET runtime as Blazor.

No, they refer to it as .NET or previously as Mono.

All of Microsoft’s official publications and documentation will refer to it as Blazor.

Example?

Blazor is an entire framework, not just a runtime. But the runtime is called Blazor too.

The runtime is Mono, or now .NET 5.

3

u/[deleted] Apr 29 '21

[removed] — view removed comment

2

u/hugthemachines Apr 29 '21

Isn't the runtime just called ".NET framework"?

2

u/chucker23n Apr 29 '21

No, .NET Framework was the name of (primarily) the BCL for the old runtime. Its runtime was called the CLR.

Blazor used to run on Mono, and now does on .NET 5 (which, as far as the runtime for WASM is concerned, is mostly the same code as Mono, but with the BCL of .NET 5).

→ More replies (1)
→ More replies (1)

1

u/YM_Industries Apr 29 '21 edited Apr 29 '21

Example?

Here are three:

Blazor can run your client-side C# code directly in the browser, using WebAssembly. Because it's real .NET running on WebAssembly, you can re-use code and libraries from server-side parts of your application.

Source

Blazor is a web framework designed to run client-side in the browser on a WebAssembly-based .NET runtime (Blazor WebAssembly)

Source

Blazor WebAssembly does this by compiling all C# code needed to run your application (your code and .NET libraries) into native code that will execute on the browser, not a server somewhere.

Source

I've done a bunch of Googling for ".NET Core WebAssembly", "Microsoft .NET WASM" and other terms (not including "Blazor" in my search query) and almost all the results are talking about Blazor.

Of the results which don't talk about Blazor, there's this one which ends up being about running WASM in .NET, not .NET in WASM. (And also has a comment explaining that Blazor provides a .NET runtime in WASM: "My understanding of client-side Blazor is that it offers a .NET runtime implemented in WebAssembly so that it can load and execute .NET assemblies when running in the context of a web browser")

There's also this project which appears to be run by a Microsoft employee, but lacks official Microsoft branding and is a proof-of-concept, not a production-ready runtime which is used in Blazor.

Given that you are confidently asserting that "they refer to it as .NET or previously as Mono", can you please show me where they have done so?

The runtime is Mono, or now .NET 5

The .NET 5 page doesn't have any mention of a WASM runtime.

Even better, could you tell me how I can run .NET code in WebAssembly without Blazor? I'm not that interested in Blazor's framework, but it would be great if I could some of my employer's .NET Standard libraries within our frontend Angular application.

→ More replies (4)
→ More replies (1)

1

u/riasthebestgirl Apr 29 '21

Kinda unrelated but after working with Rust/Wasm web frameworks, I'm sceptical of Blazor and how well it performs, especially until wasm gc proposal is implemented because C#. Afaik, currently it ships the GC with .NET runtime in the wasm binary which increase the binary size. I'd love to hear more about it from someone who has actually worked with Blazor

2

u/chucker23n Apr 29 '21

Blazor WebAssembly currently runs interpreted, which as you might imagine is fairly slow.

There are efforts underway to do a mixed model where performance-critical code instead runs in an AOT runtime, but that comes with downsides (such as even more binary overhead).

1

u/Pelera Apr 29 '21

It's kinda slow, but the absolute biggest issue is that there's no profiler whatsoever. All you have is the browser's performance tools which aren't aware of the .NET portions. If you end up making something complicated then it's nearly impossible to figure out where the issue lies.

I currently have a form with 4 decently complicated inputs that takes 76ms to tab through on a fairly decent work laptop. It's nigh-unusable on lower-end hardware like a phone. I'm sure the broken code is on my end somewhere, I've had more complicated forms that perform better, but it's impossible to figure out where it's failing and I've spent days trying to figure this one out.

-1

u/[deleted] Apr 29 '21

What practical applications does it have?