359 points · by octopoc · 6y ago · 197 comments
...loads 8.1 MBytes compressed (32 MBytes uncompressed) until the login button appears.
This simple calculator:
https://calculator.platform.uno/
...10.1 MBytes compressed, 53.8 MBytes uncompressed. Needs a splashscreen and 10 seconds to start (on a 50 MBit connection)
It's one thing to "simply" port some cross-platform-code to WASM and make it run in the browser, but making it a proper web application takes some actual effort. I feel that "efforts" like this just give WASM a bad reputation. Sorry to be blunt.
BUT, putting Mono out there let everyone else in the community start developing tooling (that Microsoft will take the best ideas from before politely acting like the community didn't keep the whole idea afloat.)
For context, the Blazor team started with their own interpreter compiled to WASM (via emscripten) instead of using either Mono or CoreRT - because shipping and getting user feedback is really important, and you can't do that while waiting for the ideal tech to be ready. It was swapped out later.
CoreRT is pretty cool tech but I rarely encounter anyone using it. Hopefully that will change in the future. The only CoreRT-based production app I know of is Streets of Rage 4 and it's a very recent release.
I agree that getting early user feedback is really important, but IMO it would be better if a limited version of Blazor WebAssembly (that would support only subset of .NET features, but have usable runtime size) was released on CoreRT tech and then slowly add more features. Blazor WebAssembly at it's current state, even though it supports all features, is too big to be really usable.
Spreading development resources thin between old tech like Mono and future tech just means future tech will be delayed even more. And when they figure out that in order to get the size down to a competitive levels, it would be better, if some features were kept out of the WebAssembly runtime (eg dropping reflection and relying on code generation instead), it will be too late, because it'll break compatibility with released Blazor WebAssembly projects.
Otherwise many devs will just look into alternatives (D, Go, Java (GraalVM)) even if that means lousing the benefits of the .NET eco-system.
Fair comment.
Here are some other live Wasm apps examples: https://github.com/unoplatform/uno#live-webassembly-apps.
Note that .NET for WebAssembly is still in its early stages and the .NET team is likely to continue working on AOT compilation in the coming months, and the Uno team is going to help. This will be improving the payload size and performance that is currently very much lacking in that mode. Interpreted IL mode (the UADO app) is used where the AOT engine is not yet working properly, providing a base to get the framework itself progressing, while the infrastructure rest is improving.
Many of the .NET constructs are expecting exception handling (https://github.com/WebAssembly/exception-handling), which has to be emulated as it is not yet available in WebAssembly, adding significant code to the payload. Same for other features like null reference checking or indirect invocations (some may know more on that last one). Other features like lazy WebAssembly loading (for more than 4KB at least) and Interface Types to remove any Javascript (https://github.com/WebAssembly/interface-types/blob/master/p...) will also improve the actual and perceived performance significantly.
The immediate goal of the project is to provide the ability for new and existing C# apps (and not Web sites, not yet at least) to be available for non-walled garden environments. We expect the field to progress significantly in the coming years on many fronts, making this kind of apps more useful and viable.
Finally, you'll find that the Windows Calculator port to Uno is actually stretching thin the browsers resources because of the size of the Wasm payload (browser's memory and CPU is going really high because of the internal WebAssembly management). Yet, once the tiered compiler has cached the result, the load time goes down significantly.
Yet, this simple fact that a WebAssembly app needs to download everything its needing to run puts it at disadvantage with Javascript (you download a browser with all the base libraries only once, and that's not lightweight).
For now, WebAssembly apps (in general and not just .NET ones) are more similar to mobile apps than websites, just because of this significant difference.
But then, I don't understand why you wouldnt just make it with web tech to begin with and 'port' it to native platforms with Electron.
source: been involved in quick and dirty UIs in a business for the past decade
The same logic applies now and it's even more compelling since the tooling and performance are better now with the full LLVM WASM toolchain and more robust C# AOT compilation available, vs the dark ages when people had JSIL, Saltarelle and Bridge to choose from.
I'll also note that every major company I'm aware of that made a C# -> Browser move for their tooling eventually regretted it and started shifting away to something better, partly due to platform churn and partly due to how much was outside of their control. Electron may change the equation there enough to be good enough, we'll see - I don't know of any companies that have taken that route yet.
I don't think this is intended for public facing, low bandwidth/mobile websites.
https://floooh.github.io/sokol-html5/
These are also "write once, run anywhere" but with more focus on keeping the binary size small (both in WASM and for the native versions).
These demos start at 23 KBytes compressed and go to 537 KBytes compressed for the biggest UI sample (over half of those 537 KB is embedded TTF font data though).
At the same time, if I'd be using Qt instead of Dear ImGui to create the UI, the resulting WASM size probably would be similar to the UNO samples,
Writing cross-platform code that also works well on WASM really needs a different mindset from the ground up IMHO.
(yours top, Qt version bottom - I tried to match the font sizes visually but did not manage to decipher your code to find out exactly what they should be x) )
Sometimes you just want for code to be able to run at all, even with a sizable download, if it means you don't need to do any porting work. For example if you have many years of work on a codebase, and you can run it on the web with almost no effort, that can be really useful.
I agree that we want most things on the web to be optimized for the web. But sometimes business or other reasons matter more than code size.
Part of including unicode package itself (transitively or otherwise) has a ton of package-level vars that bloat the WASM. Also, they slow down init because a bunch of code has to be run to initialize them. Also, due to the fact that WASM doesn't have arbitrary jumping, in order to support coroutine yielding and resumption, Go's WASM support puts big br_tables[0] at the top.
A while back, I brought up some efficiency concerns w/ data size and init instruction count[1] but they were dismissed as WASM concerns not Go ones and there weren't any easy/obvious wins. Also a while back, I used an interpreter to run the Go WASM up until actual main, then bake in the data that was initialized and remove init for packages where I didn't need their values[2]. I kinda gave up on using Go and WASM after all of that, but there is real room for improvement there.
0 - https://webassembly.github.io/spec/core/exec/instructions.ht...
I see WASM more as an "accelerator". The big chunk of code continues to be Javascript that can consume WASM modules.
I dont think this case of whole complex applications in WASM will fly. It looks like ActiveX 2.0 all over again.
Of course some things will happen as full apps in WASM, but they are mostly tools people already use outside of the Web, so that particular crowd just want to reach the tool, it doesnt matter the medium.
So it's no better than Electron? I'm primarily interested in the cross-platform desktop part.
The way Unity solves this is by creating their own C# dialect, compiler and minimal runtime (without GC etc). Sort of a brute-force approach, but until the standard .NET ecosystem solves the bloat problem it would have been better to build on a different language ecosystem.
To put it another way: Adobe can ship Photoshop using Emscripten, and big companies can probably eventually ship their internal C# business apps using Uno or Blazor, but you're not going to ship either of those using Unity's stock approach without building out all of the platform APIs they stripped out and adding back runtime features that were removed. The decisions they made were perfect for games, but people building general-purpose platforms can't cut all those corners.
They do take the IL generated by Rosyln and convert it to executable code using their own custom transpiler.
I think this is a fine tradeoff for certain contexts and usages, but I don't think the general usecase for WASM is to build general web applications in C# and ship all of the CLR for things like gmail.
Consider yourself lucky. It doesn't do anything on my machine except show the splash screen.
macOS 10.15.6 / Safari 14.0
The Safari Support for large WebAssembly binaries is not particularly great at this point. We hope that the Safari team will improve the performance aspects of WebAssembly, but it does not seem to be a priority at this point (see the Wasm feature map here: https://webassembly.org/roadmap).
For the iPad, the iOS built version of the same app works lots better (https://apps.apple.com/us/app/uno-calculator/id1464736591).
Accessibility is high on our feature list; we have added aria base support in recent builds of Uno, which the calculator will start using soon (the iOS https://apps.apple.com/us/app/uno-calculator/id1464736591 and Android https://play.google.com/store/apps/details?id=uno.platform.c...) versions of the same app are screen-reader enabled). The Linux one (Snap https://snapcraft.io/uno-calculator, AppImage https://github.com/unoplatform/calculator/releases/tag/1.2.4...) is not yet enabled, but will also be.
The WinUI framework provides great accessibility support, and we intend to port it fully in the coming months.
If anyone else is interested, I found the relevant GitHub issue: https://github.com/unoplatform/uno/issues/1141
e.g.
https://blah.com/dashboard (web assembly) (not indexable)
https://blah.com/dashboard.data (common format for representing data) (what the DOM currently tries to do)
Then somewhere in your <head> you point it at the pages data representation.
I'm going to bet something like this will happen and be a stepping stone towards the future.
It will have a million or so problems to solve such as accessibility, but I'm convinced all we do in programming is reinvent wheels but reduce the friction to speed as we go.
Search engines have been dealing with black hat SEO for a while now. I'm a bit persuaded that Google knows whats up.
As in, I think it's just one of those inevitable technical challenges of castle defence.
Build better walls, they build better trebuchets, ad infinitum.
I think it's already happening in a little different form with Structured Data [1] and schema.org and it's using for example JSON-LD [2].
But a separate endpoint might also be an evolution. Right now this could be the sitemaps and robots.txt as an entrypoint for spiders.
Although the one drawback that comes to my mind with a separate endpoint is that it'd have to be kept in sync with the normal page and that might vastly enlarge the costs for maintaining it. So keeping it close to the DOM seems to be reasonable
[1]: https://developers.google.com/search/docs/guides/intro-struc...
[2]: https://json-ld.org
I think for anyone who wants to pioneer this idea, the costs will be noticeable, but that's what bandwagons and the youth are for =D
Ultimately I think there will be a reduction in costs (bits, process, maintenance)
To steal from React lingo, UI represented as state, that is more or less what any web page is.
Wrapping it in a meta layer like the DOM just adds overhead which I think can be optimized.
I'm undecided but still entertaining the idea.
At first XAML feels really nice because you've got the nice GridView and other UI components, but the moment you want to start customising these everything falls down. I was really disapointed by it's lack of more flexible layout semantics (like flexbox or display: grid), and instead offloading that all into writing custom C# code to lay things out at pixel locations.
What was just a single line in css - grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) - ended up being many lines of custom layout code to achieve something much less performant.
I find the codegen/bindings situation to be really weird and XAML as well. Making custom XAML components/reusing code is trickier than it should be. React really got it right with JSX being just a thin layer of syntactic sugar on regular JS (I'm unsure how this would work for a static language like C#)
The inconsistency of the web platform is a nightmare compared to my pain-free experience with XAML.
XAML and C# allows a single developer to get a functional modern application going quickly.
I had zero problems with extensibility as long as I followed the patterns. Using MVVM, convertors, triggers, events, and behaviors where needed. The Blend tool is ridiculously cool, but I'm not artistic enough to make great use of it. But it reminds me of how Flash made me feel early on. As a kid I could make cartoons without issue in Flash.
Almost everything is open source or has an open source replacement available.
Making new UserControls is trivial. Much easier than any Web Components nonsense.
I still don't know how you're supposed to properly update data for a grouped List/GridView without causing the entire view to rerender. I'm so used to React's functional approach to building UIs that mutating collections seemed extremley alien and cumbersome to me.
I still never found a good way to achieve this a in in XAML, a grid layout where the cells will expand to fill remaining space on the row, and then wrap. Multiple components got kind of close, but always lacked 1 aspect https://codepen.io/joshhunt/full/qBOdYjj
By telling your views what was updated.
For updating sets of items, see INotifyCollectionChanged interface, implemented by ObservableCollection<T> from the framework.
For updating properties, see INotifyPropertyChanged.
> Multiple components got kind of close, but always lacked 1 aspect
Find a panel that does it best, then either copy-paste and patch, or inherit and override.
The entire layout model is implemented in just 2 methods, MeasureOverride and ArrangeOverride. They are virtual, i.e. designed to be user-replaceable as you inherit from framework classes.
WrapPanel
> for building responsive layouts?
There're two kinds of them. On the web it means arranging stuff to only have vertical scrolling but not horizontal. On desktop you often don't want any scrolling, no amount of auto-wrapping is going to do that regardless on the GUI framework.
If I wanted to make a website, I'm more than confident and productive with HTML/CSS/JS/React to build out what i need.
- wasm source takes around 2 MB
- loads up quickly and it is fast even in mobile browsers
- great codebase!
- compiles in under a minute (41s on my laptop) inspite being written in Rust
Still needs a lot of work to be usable:
- missing UI features like proper layouting, configurability etc.
- imo font rendering still needs a lot of work; but there are already project in rust which do font rendering right, for instance: (git clone github.com/linebender/druid && cd druid && cargo run --release --example=text)
- no animated transitions of UI components
Makepad doesn't strive to be UI toolkit, but judging by the way it works already and dedication of the founders it looks really promising.
Right now I'm studying how Flutter has achieved this using Skia. I'm also following JetBrains Compose, but as of the moment it only seems to support desktop native apps. How is this one different from Flutter/JetBrains Compose?
Under normal circumstances I dismiss any new Microsoft UI framework like uwp or winui3 out of hand because I know in two years or so, some other product manager will take over and will need to make their own stamp on the organization, so they will introduce yet another UI framework and Winui3 will be stagnated just like silverlight was.
I use F# Fable right now for web applications with intentions to learn Avalonia and eventually trim down my use of good old winforms when I'm writing desktop only applications.
Having said all that, I do like the idea of being able to write code in one code base and have it be compiled via xamarin to other runtimes.
Does this platform deliver on that promise?
Is anyone who has a few battle scars using this tool able to give a small review?
You do realize that the 3 implies it is the 3rd version of a project? WinUI 3 is just the "third version" of the UI component library used inside UWP originally, but now with bonus compatibility with WinForms and WPF.
To me that's the opposite of "stagnated" or "deprecated every two years". The UI parts of UWP and WinUI3 are more the same thing, just versions over time, than they are different. It just continues to evolve with each new versions that include new features (such as the new "Now with much better WPF and WinForms support" features for people in brownfield applications).
You should be excited about WinUI3 because it lets you dip your toes in what UWP added to the UI framework from your WinForms and WPF development. You'll probably find it feels a lot more like WPF than you'd think given how demonized UWP's UI framework has been. (It's not WPF, of course, and there are compatibility breaks to learn/deal with, but it's still XAML-based UI design with a lot of very similar controls and tools in the toolkits.)
Checking on wikipedia shows that winforms was introduced in 2002 and wpf in 2006. This makes me feel very old.
This might lead to a unified style across platforms but as it does not use the same rendering logic/code on every platform I'd doubt that it's pixel perfect. Building a text editor would probably expose a lot of these close but not similar scenarios.
On the other hand this adds the benefit of getting native behaviour of text boxes maybe ?
Avalonia on the other hand does custom rendering using Skia and therefore really has pixel perfect rendering across platforms. This also means that it does not use the native controls and behaviour differs.
If I had to write a cross platform app (and had the budget) I would probably use Xamarin and just write platform specific UIs. If there are heavy UI components these could still be shared.
If on a budget something like this seems fine. Would probably go with avalonia UI tho tbh.
- Uno uses the UWP API and XAML, whereas Avalonia uses a derivative of WPF
- Uno renders using the underlying platform, uses native controls whenever possible, particularly for input controls. Avalonia focuses on using its controls, not native ones (although support for native controls is WIP I think)
- Uno is based on WinUI, so in theory WinUI components should be usable in Uno apps
- Uno supports WebAssembly, but not Linux and MacOS natively
Links:
This line remembers a constant pitch i see here on HN, where people ask for native controls to be rendered for multi-platform UI sdk's that i think go on the "faster horse"(Ford) sort of misdirection.
The problem with the 'faster horse' paradox is that the only way to make people forget about wanting a faster horse is by showing them the car.
I think a platform like Flutter get this right, as do HTML/CSS/JS, because theres no way to get really consistent if you have to use the platform native controls. It will also be messy for the developers, requiring a lot of effort and money to make things partially right.
I bet with you that most of these people asking for this use a Mac, and while Apple is more or less half of the market of US, in the rest of the world Apple have much smaller deploy base.
So sometimes, you need to be careful because even HN can suffer from a bubble social effect, that will misguide people that actually listen what they are asking for.
In the long term there's already a multi-platform UI paradigm there is set to win, and its called HTML..
Native UI platforms had a sort of comeback because of the iphone revolution, but in the long term, they will not be the winners, because Apple is doing the same mistakes they did in the eighties.
All those cross-platform app frameworks fail at the same point: Meeting the user expectations since they are different on different platforms. It always feels off if the platform specific experience is not fine tuned to the platform and at that point why just don't go native and have all the shiny things that the platform has to offer.
Flutter is the platform that provides excellent experience here... Not on web yet, but its coming close.
The web browser is the equivalent of a WinForms or WPF application that interprets the HTML content and turns it into a visual presentation. CSS and JavaScript basically came along to help web browsers better present HTML content in fancier ways. But at the end of the day, it isn't a framework and HTML is still just structured content, if not bastardized to force a certain UI presentation.
You can't have fancy web applications without a web browser, just like you can't have a native desktop application without a GUI chrome framework. When you speak to the overall footprint of a web application, the web browser and the functionality it provides has to be taken into consideration, when comparing to native desktop applications.
It really comes down to the classic client/server problem - How much functionality is the client going to handle vs. the server? There is always going to be a compromise of size/complexity/performance when off-loading to the client, among other concerns. It really doesn't matter what the client technology is, Flash, SilverLight, WebAssembly, Java, etc., they all will run into that same basic structural design issue.
If you're building the GUI for some local tool TCL/TK is a lot better IMO.
I hate Java. I really do. But when it comes to absolute same experience on cross-platform is the only programming language so far. None else is in the same league as Java. A distant second would be Free Pascal/Lazarus but their richness of libraries is like 10% of Java's. And please do not come with Xamarin, that monstrosity must be killed.
In case of Android-only I would actually rather use C# and Xamarin than Java.
Why do you feel Xamarin is a monstrosity that must be killed?
The problem is that if we're talking about UIs, then Java is only cross-platform for the platforms you care about.
From a UI perspective, JRandom app using Swing won't work as expected on an Android phone. That's not "absolute same experience on cross-platform". That's instead a portability problem that you must solve explicitly by adapting your codebase to support two different UI frameworks or planning ahead for every possible porting target.
https://www.kickstarter.com/projects/c-smile/open-source-sci... (check the logos)
Con: The calculator demo takes waaaaaay too long to load. The long load time might be acceptable for a very rich web application.
To paraphrase - what's the selling point of using Uno vs using .NET 5 and .NET MAUI (the successor of Xamarin.Forms) directly?
WinUI being the UI platform that Microsoft seems to be pushing on windows these days.
WinUI doesn't sit well with me - it has the same problem that all the other "user-mode" UI frameworks have: it isn't a system-service, so once your app ships it's frozen in time and won't benefit from new features added to native widgets and controls (e.g. if you run a well-designed MFC EXE last compiled for Windows 2000 - but tweak the embedded manifest resource file to load the updated CommonControls and Windows 10 compatibility - it will still look good today and fit-in with an MFC program created new last week (I note it will look "good" - not "amazing" - because Microsoft decided to take Windows 10's native widgets downmarket since Windows 8, ugh...).
Could be worse - at least it's not Java AWT or Swing. What on earth was Sun thinking when they designed that?
Give me raw Win32 over Xlib/Athena/Motif any day of the week.
I haven't used Xamarin.Forms, what's the problem with it?
In any case, MAUI is Xamarin.Forms extended to the desktop, the name changed for marketing purposes.
https://devblogs.microsoft.com/dotnet/net-core-releases-and-...
It appears to be built on Xamarin.
What we have here is cross-platform for .NET developers.
- It needed to show a loading spinner on a 250 Mbit connection
- It hung the browser while 'booting' the page for a solid 3-5 seconds
- It downloaded 4.39 MB in 50 requests
- Opening web inspector in Firefox while reloading the page was sufficient to cause the boot process to hang indefinitely
- Page looks pretty, but at this point it barely matters
We could conclude either that the project's attention to important details is low, producing this experience, in which case what else might we discover once committed, or alternatively we could conclude that it is high, in which case, this is the best possible experience for any Uno app.
Instant pass
Sorry to any dev at Uno, but that's terrible.
And even for webassembly, 4.39 MB is not prohibitive for some use cases. Specially with caching. I bet the average medium blog loads more than that.
I wouldn't be so quick on dismissing a solution.
4.39 MB in 50 requests is a showstopper on any mobile network, especially when alternative solutions do not have that problem. It is fair to assume some first time experiences will involve 7.5 seconds or more additional latency on 3G networks, double that for a poor signal areas.
It's still an instant pass
All the top reviews are talking about how slow it is. A calculator app.
That others are just as wasteful is immaterial; the fact that it's multiplied by every single user makes it downright hostile to everyone except those who are profiting from bandwidth use.
Every single "cross-platform solution" I've seen is basically a sub-optimal experience on every platform. Personally, I'd rather have fewer native applications than the wave of quantity-over-quality not-quite-right-anywhere that stuff like this tends to encourage.
Every time I see pixel-perfectness claimed I immediately approach it with a lot of caution.
I take it it's now legal according to Apple's term? Because IIRC there used to be (and maybe still is, but it doesn't look like it) an issue regarding generated code / automated porting tools for iOS? I think I remember it was a concern for people making tools allowing to do automated cross-platform porting to a variety of platform.
If anyone knows/remember what I'm talking about and where the situation's at atm, don't hesitate to chime in and tell me when things changed or what I remember wrong.
And the components in flutter are of very high quality. Pixel perfect copies of ios and material design.
Sounds more like a React-Native competitor to me.
What's the business strategy here? Providing support and training?
What about Flutter?
Not to nitpick, but https://i.imgur.com/xzfrim8.png
I consider React Native a dead man walking, Flutter kicks its ass in almost all aspects.
I just hope they manage to make Flutter also viable for web, improve its perfomance, I honestly believe it is going to change the landscape in the startup world..
P.S. I love the name.
Also I would like to avoid using anything Microsoft, if I can avoid it.
Usage, cpu/mem bloat, dependencies, ethic, will all be all wrong...
But these 2 solutions for GUI are not prime candidates for users on Linux.
Compared to a c#/mono app, Electron can be relatively light in term of dependencies to run.
And as you can easily notice, very very few "java" GUI applications are successful on Linux computers.
Users would use a java application only when there is really no other program available for a purpose.
The only thing I had to do was installing some fonts in order to make pdf generator works.
Mem usage is generally between 100-300MB for I'd say 98% of the time (sometimes somebody wants to generate not-small Excel files and it spikes). Of course it says nothing because you don't know what the app does, but it's just some reference point.
You can try it out here[0], too. I open sourced it.
And "hello world" binary download size is 10 Mb for Windows.
I can't swear that it will really be the case, but here are some examples of kind of thing that I expect:
- Icons, window decoration, style, not matching the system.
- Copy paste issues, for example the middle click not working.
For "dependencies", not considering the real dependencies, you will have to force your user to install mono and its own dependencies. As the application will run on this, in a similar way that you would have to install a JVM + classpath for Java apps. And this one is really fat an ugly.
For "cpu bloat", even if JIT can be more efficient on the long run, there is usually a higher cost at startup. For GUI application that you start often, like a calculator, that could be annoying.
For "ethics", the code will have to run on the mono(ie .net) kind of jvm and so you are dependent of this engine to run your code. And this engine, even if mono is the open source one, is controlled by Microsoft. They control the language, they control the features, and it is not the spirit that built the linux community to rely on "base components" controlled by Microsoft. It is a little bit like the control that Oracle has on Java even if not completely similar.