Home / Java Patterns and Pitfalls     frequal.com

TeaVM vs. Blazor WebAssembly

Microsoft just released Blazor WebAssembly. This is their system to generate single-page web apps from C# code. It is similar to what TeaVM and Flavour do for Java code. TeaVM has a huge head start, can Blazor ever catch up?

Summary

Blazor is an official Microsoft project to bring C# to browsers, hobbled by a fundamental architecture flaw. While they are starting to fill the feature gap with TeaVM/Flavour, performance is always going to be an issue given their VM-in-a-browser approach. It lacks threading and cross-IDE support found in TeaVM today. However, the Blazor team has implemented a few features TeaVM should consider, like localization and easy basic PWA support.

I've summarized the differences in a convenient chart

Notes from MS Build 2020 Session on Blazor WebAssembly (INT169)

Daniel Roth presented the demo, and Steve Sanderson drove the Q&A session.

Blazor justification:

They announced their 1.0 release today, first prod release.

Fundamentally, it deploys a .net runtime in a browser as a big chunk of WASM. This will always be bigger than the TeaVM method of compiling bytecode to JavaScript, no JVM needed.

Notable Features:

PWA is enabled via a checkbox at project creation time. Pretty slick. They auto-generate a service worker, but it has a big warning at the top they quickly skipped over.

Debugging in the browser let you see the original source (like TeaVM), but also allowed variable inspection.

The demo app was very slow to load, even locally, taking at least 10 seconds. Compare that to the CoronaWait 3s launch time over the internet!

The second demo showed entered data cached while offline, then synced once back within wifi range. It wasn't clear if that is built into the framework or required custom app logic.

Localization (L10N) uses rex files, the C# version of property files. Flavour should consider something like this to allow Java-native L10N.

Blazor currently lacks threading.

The Blazor team compiles the .net VM to WASM using emscripten. This is kind of like what CheerpJ does. And we've seen how that works out.

Blazor apparently supports debug and production builds. Like TeaVM, the production mode omits the source code.

Someone asked how small the download size could be, could it even get to 100KB? Answer: "Not realistic, it won't be possible" —Steve Sanderson, Microsoft Blazor team. Steve said they might be able to get down to 1.6MB. Compare that to real-world download sizes of 130KB for CoronaWait.

One comment that will resonate with TeaVM users is, "now I can add Senior Full Stack Developer to my resume".

TeaVM: When You Want To Do Today What Blazor Will Never Do.


Last modified on 23 Nov 2020 by AO

Copyright © 2024 Andrew Oliver