11 ms·
A world to win: WebAssembly for the rest of us
- shaunxcode 3y agoSpritely Goblins renews my faith in the future of circuit society.
- JenrHywy 3y agoAdmittedly I only scanned the article, but I didn't see any mention of C# or Blazor. I've only fiddled with it, but it seems that (when targeting WASM) Blazor loads a (partial) .NET runtime in WASM and then happily lets your execute C# code - which seems in stark contrast to the article's claims about GC.
- fulafel 3y agoIt doesn't claim DIY GC is impossible: The article first talks about difficulties a ship-your-own-GC faces, and enumerates workarounds for them (slide "GC and WebAssembly 1.0 (3)" and coupe of next ones). Then it starts talking about the planned GC support extension in WebAssembly and decides to go with that.
- JenrHywy 3y agoSure, but I thought that a successfully implemented CG'd language running on WASM would have been something worth noting.
- antonvs 3y agoBlazor isn't unique in that. At least some of the "non-mainstream" languages that the article mentions have WASM solutions. But, because they have to ship a non-trivial runtime as part of each app, they tend to suffer from the same kind of problems Blazor has, which is what the article was addressing.
- deleted 3y ago[deleted]
- fulafel 3y agoThat's true. Besides Blazor, the WebAssembly Go port[1] does this as well. [1] https://github.com/golang/go/wiki/WebAssembly https://github.com/golang/go/wiki/WebAssembly
- baq 3y agoThe article references browsers and JavaScript, so that’s the context. Nevertheless I found it quite interesting.
- JenrHywy 3y agoMaybe we read different articles? I thought the context was how it was hard to do GC in WASM currently, which is why we don't have many language choices. With that context, C# running on top of WASM seems pretty relevant?
- flohofwoe 3y agoGarbage collected languages have been running in WASM for a long time already, but they had to "bring their own garbage collector" to run in WASM, which increases the size of the WASM blob. Garbage collection can now be delegated to the WASM runtime instead (e.g. see the short description here: https://chromestatus.com/feature/6062715726462976 https://chromestatus.com/feature/6062715726462976)
- kevingadd 3y agoDIY GC is definitely harder in WebAssembly than on most targets due to, among other problems, the lack of stack-walking
- jillesvangurp 3y agoThat's so far the strategy. There are all sorts of garbage collected and interpreted things that run fine in wasm. But at the price of having to include a heavy runtime; which bloats the binaries. Not a showstopper for some things; like enterprise applications running in a fast network. But a bit of a blocker for normal websites. Firefox and Chrome actually have support for the new GC and threading support in wasm. That's behind a few feature flags. But e.g. Kotlin's new wasm compiler depends on that and manages to ship binaries that are quite small. That compiler is also being used for a new experimental target for compose multiplatform, which is based on Google's Android Jetpack Compose and extends it to other platforms (IOS, Desktop, and Web). Web now comes in two variants: html & kotlin/js and canvas + wasm. The latter renders using the same graphics libraries used on Android and IOS but compiled to wasm. None of this stuff is ready yet because the tooling and frameworks are pre-alpha quality and it requires feature flags to be set by the user. But, this is starting to look like a nice alternative stack to things like flutter and react native for cross mobile, desktop, and web development. The feature flags are likely coming off fairly soon. Safari is a bit behind. 2024 is going to be interesting. I'm guessing there will be a whole lot of activity around this in most commonly used languages and stacks.
- toyg 3y ago> The latter renders using the same graphics libraries used on Android and IOS That's annoying. I was hoping WASM would be a way to break out of the js/java/swift/ObjC stranglehold, not another baton to enforce such tyranny. It would be cool if they were targeting toolkits like QT instead.
- flohofwoe 3y agoWhat does one have to do with the other though? You can use any programming language where the compiler supports WASM output, and any cross-platform graphics library that also has a (Web)GL or WebGPU backend. (also not sure how Qt fits in here, but it also has WASM support: https://www.qt.io/qt-examples-for-webassembly https://www.qt.io/qt-examples-for-webassembly, but IMHO Qt is way too bloated for this sort of thing) In the end, WASM running in browsers can only use browser features that are also available to Javascript, e.g. for rendering that would be canvas-2d, WebGL, WebGPU or the DOM). But at least WebGL and WebGPU are close enough to similar native 3D APIs that you can share some code between native ports and WASM running in browsers - but it still makes sense to use a higher level graphics libraries which abstracts over the 3D-API differences, or alternatively use wgpu.rs or libdawn in the native versions (which are the standalone native WebGPU libraries used by Firefox and Chrome).
- flohofwoe 3y agoBefore WASM's GC feature was ready, it was basically "bring your own GC" which had to run entirely within the WASM context. With the new GC support in WASM, it's now possible to delegate garbage collection to the WASM runtime by exposing garbage-collected-references to the outside world (for instance in browsers that would be the JS engine garbage collector).
- jasonwatkinspdx 3y agoThe article addressed that in some detail. There's a number of downsides to implementing your own GC atop the linear memory, due to limitations in threading model, modular security requirements, etc. Meanwhile the browser has a very high performance GC sitting right there we could expose to WASM fairly easily. That's the basic idea of current efforts and what the article/talk is about.
- bentobean 3y ago[flagged]
- DC-3 3y agoIt's a joke. The whole presentation is riffing on the Communist Manifesto.
- xcdzvyn 3y agoI Ctrl+F'd "spectre" to no results. Very disappointed. Nice username by the way.
- pcthrowaway 3y agoOk, now I'm curious. How is it riffing on the communist manifesto?
- DC-3 3y agoThere's a few references. 'A world to win' is from the closing remarks of the Manifesto. 'With GC, the material conditions are now in place' is a reference to the fundamental basis of Marxist theory. There's probably others that I'm missing. The general tack is to suggest that WebAssembly is being democratized and made available to the masses. Bit of an odd analogy but there you go.
- virgildotcodes 3y agoGiven that this article has nothing to do with actually promoting a political/economic view, this reaction may be unhealthy.
- antonvs 3y agoWhat propaganda does to your brain.
- flohofwoe 3y agoApparently "the rest of us" is people interested in using garbage-collected languages with WASM, because the post is mostly about the new-ish GC support in WASM.
- deleted 3y ago[deleted]
- 3cats-in-a-coat 3y agoI don't believe that's the correct way to use WASM. If one has a GC collected language one may be better off compiling to JS, or at least a combination of JS and WASM for some linear C-like computation that's then offloaded back to JS. People need to look at JS, WASM, WebGL/WebGPU and the other browser APIs as a single platform, and use the right parts for the right job, instead of reimplementing JS functionality in WASM and vice versa etc.
- flohofwoe 3y agoA platform shouldn't dictate details like what programming language to use to create applications for that platform. It's already bad enough with iOS and ObjC/Swift or Android with Java/Kotlin, but at least there are escape hatches on those platforms. WASM is the escape hatch that was needed on the browser platform.
- 3cats-in-a-coat 3y agoI'm discussing JS and WASM as two compile targets for your preferred language. No one is "dictating" anything. But JS and WASM are complementary in some important ways. GC being one.
- brabel 3y agoAre you aware that WASM is going to have a GC soon? It's in phase 3 (Implementation Phase): https://github.com/WebAssembly/proposals https://github.com/WebAssembly/proposals
- katspaugh 3y agoHere's a youtube video of this talk: https://www.youtube.com/watch?v=lUCegCa7A08 https://www.youtube.com/watch?v=lUCegCa7A08 Really excited about Scheme compiling to WebAssembly. A whole world of possibilities indeed!
- rapnie 3y agoYes. The Spritely Institute is working here and have some nice blog posts and example apps. https://spritely.institute/news/scheme-to-wasm-lambdas-recursion.html https://spritely.institute/news/scheme-to-wasm-lambdas-recur...
- davexunit 3y agoFollow along with Guile Hoot (Scheme -> WASM compiler and general WASM toolchain) here: https://gitlab.com/spritely/guile-hoot https://gitlab.com/spritely/guile-hoot
- austin-cheney 3y agoI have not seen the value in WASM just yet. To me WASM has always looked like a Flash replacement, and there is value in that but that isn't what developers wish it were. Developers wish it were a JavaScript replacement, which it isn't and does not not wish to be. As a result I see nothing happening here but the disappointment and lost dreams of sad Java developers over the last 6 years. Being flamed on Reddit by desperate Java developers wishing for WASM who emotionally cannot figure out JavaScript to save their careers was the straw that broken the camel's back. I deleted my Reddit account and never looked back. Dire indications of far deeper problems not specifically related to Java, JavaScript, or WASM.
- k__ 3y agoThe benefits I saw were high performance libraries in the browser and runtimes for multiple languages by just integrating WASM. Sure, not all languages, but getting Rust and C/C++ out-of-the-box for a start seems to be worth it. Also, it's an open source runtime, so if you integrated it, you get improvements from the community, which is a huge gain for small projects.
- austin-cheney 3y agoC++ and Rust are already open source and there isn't reason to believe applications executed as WASM are faster than near JavaScript equivalents. There is amazing advantage though to just exposing C++/Rust applications without requiring a separate installation or executable for both security and convenience, but I am not seeing much of this in the wild. I think the sand boxed nature of WASM is a bridge too far for many C++/RUST application developers who would then need to include a tremendous number of support library they take for granted outside the browser.
- tvink 3y ago>Java developers wishing for WASM who emotionally cannot figure out JavaScript to save their careers If you got flamed, I imagine it was more about tone than content :)
- 3y ago
- p0w3n3d 3y agoIn my opinion WebAssembly and all the in-browser applications are a waste of power. Please do a small experiment: make a 30 minutes video call on your laptop using both: natively compiled skype and google meet. In my case meet drains almost 2x amount of power and after an hour-lasting meeting I have no battery left, but on one-hour meeting on skype I still have 56% of battery. It's because you cannot have native performance on something that is still the virtual machine. Another reservation I have is global migrate-to-the-cloud trend, where I can see heavy-CPU programs like adobe photoshop moving to in-browser, while I feel much more comfortable using natively compiled applications. It's just faster and gives working smoothness feeling. Also when I have a locally installed photoshop or lightroom, nobody requires any money from me. I can have a dedicated laptop for my photos processing, and nobody will take it from me, because I didn't pay for the next month. However this is another story of making people dependant on subcriptions in all cases of our lives...
- paulgb 3y ago> Please do a small experiment: make a 30 minutes video call on your laptop using both: natively compiled skype and google meet. I don't think this is a Wasm issue. IIRC Google Meet uses WebRTC for encoding, which is the compute-heavy part of a video call. They might use Wasm for background blurring or something like that. In general I suspect that the issue here is that Skype as a native app can access some video-specific hardware acceleration that the browser can't. CPU-bound workloads should be close to native speed (OP says within 10% of native which tracks with my experience)
- saiya-jin 3y agoI agree, virtualization layers always add a bit of overhead by principle, but in 2023 we use plenty of those and the hit is small enough to ignore it for most uses. Either some bad coding/lib dependencies or lack of direct access to better hardware as you mention, but then browsers should allow this, with some good permission process.
- paulgb 3y ago
- k__ 3y agoDoes using the JavaScript GC for other languages pose any risks? Like, does application code rely of GC implementation details to be performant that might be different in JS' implementation?
- kajaktum 3y agoOkay, someone tell me why JVM isn't it? Is there something fundamentally flawed in the JVM that can't be fixed?
- slj 3y agoOracle
- kaba0 3y agoWrong answer. There is hardly a more open platform than the JVM, its reference implementation is open source, it has an open specification for both the language and the VM with plenty completely independent implementations, and is so big, running business critical infrastructure in basically almost every FAANG, that any single one would alone pay for its continuous development. Also, Oracle has been a surprisingly good steward of the platform, managing to retain almost the whole Java team from the Sun days (remarkably hard to do that at takeovers), increased the pace of its development and finished open-sourcing everything (formerly OracleJDK had proprietary extensions not found in OpenJDK, nowadays only some trademarked logos remain as the sole difference). So they mostly own only the name’s trademark, which is no big deal. Remember, google vs oracle happened over Sun’s license that explicitly forbade using their software on mobile devices. No such restrictions exist anymore in case of OpenJDK, which has the same license as the Linux kernel.
- unnouinceput 3y agoActually is the correct answer. Oracle and its shenanigans are the reason why I avoid their DB and Java.
- 0x445442 3y agoI thought browser VMs lost (Flash, Applets, etc) or was that just because they weren’t open like WASM?
- pie_flavor 3y agoFlash and applets were replacements for visual sections of webpages, handling rendering, layout, and interactivity in a frame. WebAssembly is just code. (To put it another way: The JS browser VM hardly lost.)
- kaba0 3y agoThey lost because they were ahead of their times -- the rest of the web tech were way behind and the best one could do was to put a canvas and render real interactive content there. In the meanwhile, web tech has improved considerably so now you don't have to manually render to a canvas, the DOM is expressive enough for many things, so integrating with JS instead of wholesale replacing it makes much more sense. But besides starting from a clean slate, escaping a few historical warts (e.g. 32bit types would not have that big of a support in a newly planned JVM simply due to hardware advancements), there is nothing significantly better or novel about it, in my opinion -- maybe with the exception of its history: it being closely related to asm.js is imo a very interesting tidbit.
- unnouinceput 3y agoQuote: "Firstly it's "close to the metal" -- if you compile for example an image-processing library to WebAssembly and run it, you'll get similar performance when compared to compiling it to x86-64 or ARMv8 or what have you." Is WebAssembly now able to run it outside a web browser or this guy is just "inflating" results, to put it mildly and not call him a liar. Because last I checked, there is no world where a browser application is in similar performance with a native one.
- flohofwoe 3y agoMy home computer emulators (mostly integer bit-twiddling code written in portable C) have similar performance between native and WASM with -O3 (within 10..25% of each other) - so yeah, WASM absolutely is in the same performance ballpark for 'regular' C code that doesn't use platform- and compiler-specific language extensions. Link: https://floooh.github.io/tiny8bit/ https://floooh.github.io/tiny8bit/
- craftoman 3y agoWebAssembly is the Flash of 2010. Even if companies adapted I would rather block it from running on my machine. I prefer transparency these days because almost every company is abusing user’s privacy.
- fleventynine 3y agoObfuscated javascript is no more transparent than webassembly. And today the webassembly "state machine" is quite isolated from the web-page and web APIs, making it easy to observe all inputs and outputs. Also, nothing is stopping a web page author from implementing a simple webassembly interpreter in javascript and using that to execute the code if the browser's webassembly engine has been turned off.
- flohofwoe 3y agoTBF, that stance makes sense only if you also disable Javascript, otherwise it's just superstition (look at any complex webpage and try to make sense of the minified Javascript code in there, even when pretty-printed that's about as useful as looking at the WASM disassembly).
- hoten 3y agoThere's literally zero external capability given to WASM in the browser. It must call out to JavaScript to interact with Web APIs. There simply is nothing to hide.
- yayitswei 3y ago> So why aren't we there? Where is Clojure-on-WebAssembly? Where are the F#, the Elixir, the Haskell compilers? There's this and other similar projects: https://github.com/helins/wasm.cljc https://github.com/helins/wasm.cljc
- wahern 3y agoI believe the original question concerned compilation of Clojure, et al programs to WebAssembly. Unless I'm misunderstanding, your link is to a project for manipulating (assembling and disassembling) WASM bytecode, which is both the wrong direction and not really a compiler at all--at best a constituent part of a compiler.
- archibaldJ 3y agofor haskell to work we still need - stack support of the hs-wasm-cabal - lots of rewriting to remove C string, etc, from many packages: https://gitlab.haskell.org/ghc/ghc/-/issues/23354 https://gitlab.haskell.org/ghc/ghc/-/issues/23354
- nuc1e0n 3y agoMy gut feeling is that the built in GC will either be complex and difficult to implement, each garbage collected language will use the new facilities in incompatible ways or languages will still end up rolling their own gc for some reason. However, I hope I'll be proved wrong and the new gc facilities will be a great success.
- shortrounddev2 3y agoHow do you develop in wasm? I've been unable to get a decent debugging environment with breakpoints running, as the support for them seems experimental. Do you all just fly blind, debugging with print statements?
- iainctduncan 3y agoI use s7 Scheme compiled to web assembly and love it. It uses its own GC and is 100% ANSI C so was quite easy to get going (it is fairly similar to Guile but liberally licensed). This allows me to reuse my domain code from Scheme for Max projects in a webaudio/webmidi contex, and control a WASM synth in C++ from Scheme. Here's is my ultra simple example page which I will eventually update with the progress from the private app I am doing. https://github.com/iainctduncan/s7-wasm https://github.com/iainctduncan/s7-wasm Edit to clarify: I am using s7 specifically because that's the one I use in Scheme for Max, my main OSS project. It is great for computer music.