Does compiling .NET code (including UI technology) to WebAssembly sound reasonable?


#1

Hello,

Lately I have been reading about WebAssembly. From the looks of it (as far as I understand), if WebAssembly delivers what it is supposed to deliver, it may end up being a web programming technology revolution (at least it sounds that cool to me).

Unfortunately, at this point I am still pretty fuzzy about what WebAssembly is and what it will be able to deliver (assuming it ends up becoming a reality). In order to gain a little better understanding of WebAssembly, I would like to ask you guys a couple of specific questions with the hope someone can enlighten me.

  1. Is it reasonable to think that .NET developers will be able to compile .NET core code to WebAssembly? I realize that there will be limitations since not everything that the CLR and .NET framework have to offer will be compatible with what WebAssembly has to offer but do you guys see this as something doable?

  2. If the above sounds realistic, is it reasonable to think that Microsoft or someone else could come up with a XAML base user interface (basically something similar to WPF) that developers could use to create user interfaces and forgo the whole HTML, CSS, DOM, JavaScript mess? Basically, I am thinking that the compiler could take the XAML info and generate code that draws the XAML controls in the browser, all these controls could be drawn in some kind of canvas control that would mimic a Window’s form covering the whole browser page. Does that sound crazy?

Thank you.


#2

It certainly doesn’t sound crazy. There are projects that compile C# to JavaScript already so Webassembly is the logical next step. For the UI framework based on WPF/XAML, check out Granular and its demo GranularPad (works on desktop now - mobile still needs touch support).


#3

There is a .NET IL to WebAsm chunk on the GitHub for the project.

This is still very early days and there is a great deal of experimental work.

The first target is a Minimum Viable Product (MVP) as proof-of-concept. It is not clear how .NET could fit into that (keeping in mind that it is not just IL but the CLR, the class libraries, etc.) What is being done at the moment is with the prospective MVP WebAsm being translated to JavaScript at run time. This is a nice step for proof-of-concept and checking against implementation by other means.

I tracked down the project at the W3C. It is what is called a Community Project, hosted by the W3C but not a W3C standards activity. The mailing list has negligible activity, and the IRC was quiet when I checked. The action seems to be all at GitHub, which is a good place to assess what is going on: https://github.com/webassembly and the design repository seem to be the easiest way to see what is going on.

Although WebAsm uses AST (syntax trees) as the means for conveying code, which makes them a bit LISP-like when written out in a text notation, the primitives are very low level, much like what assembly-language programming was like once-upon-a-time when processors were simple. It is also procedural although in a functional structure, and tail recursion is yet to be dealt with.

My cursory impression is that it is early days yet and we might see tension over engine approaches.

Speculating further: keep an eye on Node.


#4

Yes, it sounds VERY reasonable. :wink: It’s already being somewhat expected in the rumblings out there in the ecosphere. It will be interesting to see if this is mentioned at all in //build this week. If not then, then definitely by next year. This definitely opens the door to enabling the vision that Silverlight once aspired to fulfill, but this time it will be done in a much more friendly and agreeable manner. It’s taken five years, but it feels like we’re finally heading in the right direction again.

FWIW, someone posted about this question in a Visual Studio UserVoice vote (currently Under Review) that is talking this very topic. You can add your votes (and any additional input) here: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/10027638-create-a-ubiquitous-net-client-application-develo


#5

@DragonSpark, hey there, nice to see you again.

From the looks of it (as far as I understand), if WebAssembly delivers what it is supposed to deliver, it may end up being a web programming technology revolution (at least it sounds that cool to me).

This is my hope as well. I have been using Silverlight for years, and comparing Silverlight dev with HTML/JavaScript dev is like comparing apples with oranges. There’s no way in the universe that anyone of sound mind would choose the latter over the former unless the marketplace forced them to.

If the above sounds realistic, is it reasonable to think that Microsoft
or someone else could come up with a XAML base user interface (basically
something similar to WPF) that developers could use to create user
interfaces and forgo the whole HTML, CSS, DOM, JavaScript mess?

I asked this question here:

https://social.msdn.microsoft.com/Forums/silverlight/en-US/0d1d2e04-7092-4f38-8bc1-4365c808f873/silverlight-over-webassembly?forum=silverlightgen

For my two cents WebAssembly does look like the revolution that the web has been in dire need of since its inception. HTML was never designed to be a complex UI system. It was designed for formatting text and not much more than that. Everything that has been built on HTML since the early days is just an after thought. Running sandboxed apps inside a browser has proven to be an excellent way to deploy an application, but browser plugins have fallen out of favour recently. WebAssembly threatens to reverse all that and seriously challenge the HTML/JavaScript paradigm.


#6

Likewise! :slight_smile: I am very excited about the potential for WebAssembly. FWIW, I answered your question in the MSDN forum, but to summarize my thoughts on the matter, what I think needs to happen is:

  • Make UWP Cross-platform (.NET Core)
  • Add WebAssembly as a target platform to .NET Core
  • Rally behind Avalonia as a community and really make it a legitimate, authoritative cross-platform .NET UI/UX solution. This would involve MSFT officially providing development resource and guidance.

With WebAssembly due to release in March of 2017, there is no reason why we shouldn’t be talking about having the first version of the “new” Silverlight (via Avalonia) around this time next year.


#7

I mostly agree, but aren’t Avalonia and UWP two incompatible technologies? I mean, you either build a UI for one or the other. Of course, I’d love UWP to be compiled for .NET Core and then be deployed in to a browser via WebAssembly. But, I just can’t see Microsoft porting UWP to MacOS, Android, iOS, etc.

Avalonia obviously has a future in this space though. What’s your feeling on how long it’s going to take Avalonia to catch up with where Silverlight is at right now? Do you think Microsoft will get behind Avalonia? And if so, why doesn’t Microsoft just open source Silverlight and provide a pathway to Silverlight deployment through web assembly? Or, port the Silverlight graphics library to .NET Core?


#8

Technically. The Avalonia team is much more innovative and understand MSFT technology better than the UWP team, clearly. Of course, that doesn’t really say much as pretty much anyone understands MSFT technology better than the UWP group. This is one of the reasons why Xamarin was such an attractive acquisition. To date, it truly feels as if the UWP “leadership” has done everything they can to make UWP a product that no one wants to use, for the past five years. Can you imagine getting paid for five years for basically doing nothing? That’s the sort of cushy job you would have on the UWP team. In addition to essentially not doing anything for five years, the group is mired in secrecy, closed-source thinking (when everyone today is open-source), politics, and terrible developer relations/engagement. It is in serious need of a reboot. :stuck_out_tongue:

However, UWP still provides value as its offering is two fold: that of its client application model (which I just got done explaining is not very good at all), and that of its rendering pipeline (infrastructure).

What is useful out of UWP is its rendering pipeline, and that’s where its value lies. Again (as I mentioned in another thread), UWP can be considered part of the necessary infrastructure (road) while Avalonia can be seen as the vehicle (car) on which it depends on the infrastructure to operate properly. So, when I mention UWP, I am referencing its rendering pipeline (infrastructure/road) in particular, as its client application model (car) is incredibly, laughably inadequate.

Five years? :stuck_out_tongue: The good news is that the light is at the end of the tunnel here.

I sure hope so. It is possible that they can also create their own Avalonia, that is, a cross-platform UWP that has a much improved Xaml model and – well, everything else. I am doubtful on this though because they have been sitting on the same featureset for 5 years now without much improvement (see: cushy job).

And if so, why doesn’t Microsoft just open source Silverlight and provide a pathway to Silverlight deployment through web assembly? Or, port the Silverlight graphics library to .NET Core?

As much as I loved Silverlight, this might be a lost cause. But who knows. It might be possible if you get the right community effort around it. I would rather see something new from scratch that tries to capture its spirit. Much like the great work done from the ASP.NET team (a group that does NOT have cushy jobs – they work their butts off) around ASP.NET Core.

Btw, it’s super great to see someone sharing as much enthusiasm around this topic as I do. :slight_smile: Seems like people like us used to be everywhere, but now seems that we’re all too rare an occurence these days.


#9

Is it reasonable to think that .NET developers will be able to compile .NET core code to WebAssembly?

It is when it comes to CoreRT (which is only in the early stages right now). Also Mono may be ported to WebASM as its done more portability work in this area vs .NET Core.

If CoreRT or Mono is made to run in WebASM then the Avalonia is the most portable XAML based UI that could be ported would be my guess. As it could be made to render using standard Canvas or WebGL I would guess.


#10

for some CIL to WebAssembly see https://github.com/kg/ilwasm


#11

Yeah I think the JSIL/WebAssembly crew had a falling out and that effort is no longer active, unfortunately. The Mono team is actively porting to WebAssembly, however. Very promising stuff:

http://forums.dotnetfoundation.org/t/wasm-asm-js-plans-projects/1947/4


#12

Has there been any movement on this?

I’m dying to know if someone is going to rescue technologies like Silverlight so that building for web actually becomes feasible again.


#13

First goal is probably having a WebAssembly that implements .NET Standard.
After that we could bring Xamarin or some other technology to web!


.NET Foundation Website | Blog | Projects | Code of Conduct