Using WebAssembly from .NET with Wasmtime
hacks.mozilla.org
hacks.mozilla.org
You should leave your prejudices aside and give it a try if you haven't yet.
Is there any way to isolate those code blocks and import them?
EDIT: To answer my own question, this appears to be the solution:
https://www.telerik.com/blogs/using-a-code-behind-approach-t...
If your files in the solution explorer end in .razor, you are using the correct item type. If your files end in .cshtml, you are going to have a bad time and everything will seem very wrong. At first, I was using the "Add->Razor Page" context menu option assuming this was what I wanted, but it will give you the wrong type of item.
Are you reading the same HN as I do? In the last couple of years, I see a lot more positive than negative comments whenever Microsoft comes up. From what I see, Google is the company that gets the most hate on HN.
Of course, Microsoft isn't universally loved. There are a lot of people that don't trust them based on their past behavior, and the fact that Windows and Microsoft Office are still an entrenched monopoly. That might not apply to ASP.NET Core, but not everyone is going to let MSFT off the hook.
When the client were enrolled? Surprise! You can't sign apps for in-house distribution for another two weeks. Not mentioned anywhere when you sign up.
I talked to Apple support and they told me to pound sand. My last enquiry to Tim Cook's customer complaints inbox went unanswered.
People know what Microsoft is doing, the good things and Open Sources. They dont use it not because of hate, I think it is
1. It isn't good enough to make the jump into another ecosystem or language yet.
2. Not hating doesn't mean loving them. IE era, that is IE 5 - 6 if you aren't old enough ( Yes, some people still bash WebKit as the new IE and thinks IE era meant IE7... ) along with the pain on early Windows days still hurt a bit, they will have to try harder, and doing so continuously to win those people back.
The thing about Apple isn't hate as in Google or Facebook. It is people have high expectations of Apple and demands quality from them, and when they are not up to that high bar, people complain.
However, if MS does something that could remotely look like Embrace, Extend, Extinguish then a lot more hate is thrown around. This is occurring a bit more as MS pushes outside of it's Windows world.
It seems to me their general plan has changed to Embrace and Host
If those two things never bothered you, then you might not understand the benefit, and you can continue to use what you like.
In practice, sending the .NET libraries over the network is the major burden of the approach Blazor takes, since the first load will be slow and bandwidth-intensive, even though everything will likely be cached for subsequent visits.
However, as the WASM tooling and standards improve, the library sizes will shrink, and less libraries in general will be necessary to accomplish stuff that has been solved at the level of web standards.
Additionally, it requires that your front-end team feels comfortable working in .NET technologies. Ours certainly doesn't, and it would be very hard to sell my director on anything that doesn't maintain the traditional backend/frontend split.
That was the one comment I was searching for.
People are always talking about replacing JS, but then pump code to the client like nobodies business.
But think internal applications, legitimate SPA (webmail, trading platform), PWA.
You bind your backend to your frontend and SignalR communicates all changes.
But there are some things you should be aware of. Because the frondend and backend are integrated it's very easy to 'leak' your data layer to the frontend. Always use viewmodels.
1. You can have all the benefits of a static-strongly typed language such as C#. Which implies: better tooling, less prompt to type errors, and more suitable for enterprise software.
2. You get the full power of .NET in the browser
And, if you are already using ASP.NET for your backend:
3. You can reuse a lot of code. This means almost no class duplication (like when you work with TypeScript).
Extra:
4. Blazor is pretty similar to Angular +2, so the learning curve is smooth if you either have experience with Angular or C#.
https://wiki.qt.io/Qt_for_WebAssembly
And if you wanted to build your own wasm + canvas GUI toolkit, CanvasKit might be a good place to start:
Client-side currently suffers from large download size and startup time (since the wasm .net runtime still interprets all the DLL files) on every run. It's still in preview so expect this to get better eventually. Client-side also still requires HTTP calls to the backend (since that's the only thing available in the browser) but you can use the `HttpClient` with all the shared classes and included JSON facilities instead of maintaining a separate version in JS.
Server-side means all the components run on the server, with updates and interactions run over SignalR websocket connection. This is best suited for internal apps, enterprise SaaS or other highly-interactive apps that would need a real-time connection anyway. The fact that all the UI logic runs on the server means you save a tremendous amount of effort by skipping all the view models, serialization, http calls, and everything else that's necessary. You can have database calls right in your component. This makes complex interactions incredibly easy. If you fit this scenario, Blazor is an fantastic tool compared to what we had before.
Also it's important to note that you don't need the whole app to be in Blazor. You can easily use MVC or Razor pages and just include an interactive component somewhere on the page. We use this for a normal server-rendered site that has some pages that require complex logic and just have that part powered by Blazor server-side as well. It's seamless and even supports server-prerendering so the first-load of the page is fully composed before the real-time connection starts up and takes over the state.
Given how bad an actor they were I guess some people have a hard time forgetting the past.
So big deal and yawn. MS has a new management, it was "infiltrated" by the right folks in the early to mid 2000's who educated MS from inside and began to set MS on the right track. It takes time, like steering an oil tanker.
But MS are a capitalist corporation, just like all the others, they will all do some evil at some point in time on behalf of their bottom line and shareholder dividends, if they think they can get away with it.
In my experience, it is not possible to completely eliminate JS from the equation with Blazor. I've had to write a single .js file which I currently use for 3 things: Reading a cookie, writing a cookie and focusing an arbitrary DOM element. The focus concern I could probably alternatively handle with an autofocus attr which is dynamically inserted into the razor component, but somehow this seemed easier. Cookie or local storage interop requires JS. This is a very simple bit of code to write, and I would strongly recommend implementing it yourself to become familiar with Blazor component lifecycle events (i.e. how you make sure this JS shim is loaded into DOM before invoking its methods).
I've been wanting to create a public GitHub repo with a more practical Blazor boilerplate app that might help others get started with this kind of concern a lot faster. Perhaps something like an LDAP-authenticated business operations dashboard. Seeing an actual cookie session token read/written and how all of the code flows for session management purposes can save days of frustration. I already see some options out there for Nugets that claim to handle Blazor session management for you, but in my experience these almost always get in the way and force techniques upon you that you really didn't want to work with. If you find yourself reading the documentation for a CookiePolicyOptions or ClaimsPrincipal type, you probably went too far down the rabbit hole.
You do need to be careful with requirements before choosing this tight binding. If you want single source, that's a great idea. If you need single source for mobile web + mobile app, you will be duplicating code. There are other reasons for API and business logic remaining server side.
> . If you find yourself reading the documentation for a CookiePolicyOptions or ClaimsPrincipal type, you probably went too far down the rabbit hole.
How do you suggest performing method authorization without claims?
I am not sure what sort of authorization schemes you are concerned with. All I use the cookies for is looking up an active user session via whatever SHA256 token is stored there (if any).
It reminds me of the ole UpdatePanel/AjaxControlToolkit/ViewState world where big/complicated/bloated frameworks with big runtimes were trying to solve super simple problems.
The tooling is a little wonky at times when it comes to blazor. Hopefully they will turn this into a flagship product.
I didn’t see any reference to existing work in this area in the article, I’m curious to know how this differs from projects like WasmerSharp by Miguel de Icaza released a few months ago.
This software (Wasmtime) allows you to run webassembly code from within .net.
Though I agree it could be a nice way to make software avaiable on all platforms.
Kind of like using Google translate to go from English -> Something -> English. In theory a perfect translation would give you back your original input exactly.
Of course this should be more feasible with programming languages than with human languages.
Last time I looked, blazor compiles c# to MSIL just like normal, but also provides a wasm runtime for MSIL.
At least that is part of what was communicated so far.