Live data from Hacker News

WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

developer.chrome.com

51–60 of 88 posts

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#51

Wouldn’t it be reasonable to integrate the Dart runtime aswell?

Can you clarify?

If you mean compile Dart to WASM, leveraging WasmGC, yes that's being worked on a prototype has been available for months now:

- https://docs.flutter.dev/platform-integration/web/wasm.

- https://flutterweb-wasm.web.app/

If you mean integrate the Dart runtime into browsers...that ship sailed a long time ago. Wasm is a more flexible way to accomplish that, amongst other reasons.

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#52
post #23

Maybe I'm old but, we already had this... it was called the tag and it let you embed Java applets. We also had Java Web Start. I feel like this solution in superior to both those things but it still feels like a step backwards.

Yep. Wrote a java applet for DHL back in 2003 to process the export shipment paperwork. Used Java Web Start to deploy. Worked great. Can't remember why applets were killed. Thinking maybe it was because of Microsoft.

I also did Java development back then. Applets died for many reasons...

First, the Java plugin required a JDK installation, which was a considerable download. At the time, many apps/tools included some JDK version, but as a developer, you can't count on that. It took many years for Java to have a modular JDK, but when it happened, applets were already gone. By comparison, the user experience of Flash was orders of magnitude better.

UI programming was problematic. AWT was ugly, and Swing was too slow for the machines then. In comparison, Flash had tools to create excellent interactive games and small UIs. Also, as HTML/CSS/JS supported more and more UI patterns, there wasn't a need to use applets for complex UIs.

The JVM is sandboxed, but there are so many moving pieces and outdated JDKs installed that they become a security problem and attackers started to poke into the applet plugin bugs to find holes.

Finally, another issue shared with frameworks like ActiveX or browser plugins was DOM integration. When you mix an applet with a page, the applet feels alien. You can't navigate inside the applet without breaking the browser navigation, and using apples for small UI pieces (Sun's home page used to have a news ticker applet) is an overkill. The best use case for applets or ActiveX was video playback, but browsers added native support. That's why Java Web Start was more interesting than applets. But, at the time, Sun was spread too thin. Adobe did the same with the Rich Internet Apps and Flex but with a better execution (until the iPhone killed the RIA hype).

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#53
post #14
post #9

Earlier quoted context omitted.

> I mean sure WASM has allowed C, C++ and Rust to run on the web for awhile now but they aren’t typically languages that web developers tend to have a lot of knowledge of or interest in learning. I think that main use case is not for the web developers who already know the tech needed for web development but actually vice-versa. E.g. you're a C/C++/Rust developer and you want to expose your product as a browser servi…

Already possible with PNaCL and CrossBridge in 2010, but yeah we needed to have it as a standard and delay everything for a decade.

Emscripten has been around since 2012, originally targeting JavaScript.

But if you’re comparing to proprietary examples, you could go all the way back to ActiveX in 1996.

Or, since today’s news is about Java, you could go back to Java applets in 1995. (At least those were somewhat secure, unlike ActiveX.)

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#54

Earlier quoted context omitted.

> E.g. you're a C/C++/Rust developer and you want to expose your product as a browser service - you transpile it to wasm and with a bit of JavaScript you integrate it into the end service Speaking as someone who worked for two companies that tried to do exactly that, it's not that simple. The "bit of JavaScript" ends up requiring huge amounts of work, and the user experience feels un-browser-like, because you're fitt…

You can leverage normal HTML though? Blazor does this with C#, you don't write it all to a canvas element, you just use C# to modify the html itself, basically replacing the 'react' part of the UI.

Yes, but it's important to think about the bridge/shim between your application code (the web assembly module) and the host (the browser). If you have a C++ game which draws to the screen with SDL, then you can use a shim to convert SDL calls into html canvas calls [1]. But if a backend engineer wants to compile their java swing application to web assembly, there is a larger impedance mismatch from Java Swing => react html, then from Java Swing => html canvas.

If your application is built upon a web framework which already has this translation layer, like Blazor, then the amount of harness/shim-glue code you need to write goes down.

1: https://web.dev/articles/drawing-to-canvas-in-emscripten

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#55
post #53
post #14

Earlier quoted context omitted.

Already possible with PNaCL and CrossBridge in 2010, but yeah we needed to have it as a standard and delay everything for a decade.

Emscripten has been around since 2012, originally targeting JavaScript. But if you’re comparing to proprietary examples, you could go all the way back to ActiveX in 1996. Or, since today’s news is about Java, you could go back to Java applets in 1995. (At least those were somewhat secure, unlike ActiveX.)

Yeah, I left those out on purpose, because Java Applets did not support C and C++, although there were later compilers for the JVM, and ActiveX were straight COM x86 binaries.

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#56
To be able to use WASM as a universal runtime, I'd love to see a new WASM-only JavaScript implementation that takes advantage of WASM-GC and does parsing at compile time.

Current JS-in-WASM approaches compiler a whole runtime like the SpiderMonkey interpreter to WASM then use that to run JS source. That leaves a ton of performance on the table, though it sounds like it can start up sometimes faster than a JS VM.

But with WASM GC, we should be able compile JavaScript to WASM (disabling eval() and new Function()) and not ship JS source, or even bytecode. The compiled output would be like the first compiler tier in V8 - very unoptimized, but still better than an interpreter running in WASM.

Maybe you could even use profile-guided optimization (or TypeScript?) to output optimized fast paths.

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#57
post #16

OCaml has not one but two WASM/WasmGC targeting efforts in development: https://discuss.ocaml.org/t/announcing-the-ocaml-wasm-organi... https://discuss.ocaml.org/t/an-update-from-the-ocaml-wasm-or...

Seems like a bad thing? Why are there two separate workstreams?

It's the ocaml way.

Re: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

#59

Wouldn’t it be reasonable to integrate the Dart runtime aswell?

Can you clarify? If you mean compile Dart to WASM, leveraging WasmGC, yes that's being worked on a prototype has been available for months now: - https://docs.flutter.dev/platform-integration/web/wasm . - https://flutterweb-wasm.web.app/ If you mean integrate the Dart runtime into browsers...that ship sailed a long time ago. Wasm is a more flexible way to accomplish that, amongst other reasons.

Your first assumption was correct, thanks for the links!
Post reply on HN