14 ms·
Can someone ELI5 what problem this solves? I think of WebAssembly as being a tool for getting code written in <random language> to run in a web client. Can't
by nycticorax 4y ago
Can someone ELI5 what problem this solves? I think of WebAssembly as being a tool for getting code written in <random language> to run in a web client. Can't I already run code written in <random language> on a server that I control? Heck, PG went on at some length in one of his early essays about how that was one of the great things about the Web: you could use any language you wanted on the server. Even Common Lisp...
- rglullis 4y ago"dumb clients" don't exist anymore. Why run things on the server and have to deal with scaling issues, if I can just distribute super complex applications easily and as reliably as publishing a web page?
- satvikpendem 4y agoNext.js' (and others') server side rendering exists and React Server Components exist as well. We're seeing a reversion back to the server due to SEO and performance concerns.
- rglullis 4y agoYour example is about something that gives power to the developers. My is about something that gives power to application users. Which do you think is more important for non-developers?
- satvikpendem 4y agoWhatever get their job done faster. Don't host an ecommerce site as a client-side app, no one will buy your products if they don't show up on Google. Same with heavy websites, people complain often of bloated JS-based sites hogging their CPU, RAM and battery life. Doing the computation on the server is actually beneficial to the user's hardware. Non-developers don't care about client-side computing as much developers think they do. Aside, I also can't believe I'm defending server side rendering in this day and age where people actually think client side routing is better. Around 10 years ago when React was still getting new, I would have held the same views as you. It's interesting how tech moves cyclically.
- rglullis 4y agoI don't think we are contradicting each other. I am not talking about using WASM to make a ecommerce site, or any site for that matter. I am talking about applications running in the browser. Games. Email/Social media clients. Productivity Tools. Media Players. Basically anything that people want to do on a mobile app, but that could be done/distributed via the browser.
- iknowstuff 4y agoIt lets you run untrusted code. Great for exposing a plugin API.
- clscott 4y agoIt's also valuable for running code written in <random language> to be executed in <another random language>. Write a library in Rust and compile it to WASM, theoretically any language with WASM bindings could run it. This could really make niche languages more easily adopted if their execution environment supported libraries in WASM. Imagine using Java's JDBC from something like Nim. Nim could take advantage of a 30 year old mature and fast database access framework without haveing to envest that ime and effort themselves. Or even something more modern like the polars dataframe library.
- ptx 4y ago> Imagine using Java's JDBC from something like Nim. You can already do this with JNI. How does WASM improve things? In both cases (WASM or native code) you get the overhead of two runtimes and the hassle of converting data types, don't you?
- kaba0 4y agoGraalVM’s polyglot execution does solve this problem, it can even optimize across language barriers. (But it runs native languages as LLVM “bitcode” basically, not natively)
- merb 4y agoGraalVM will Not succeed, because every language needs Tour be reimplemented in graal, in wasm every language just needs a wasm Target. Also Java is really slow Boy adding a wasm Target. Most languages have a way to run on a wasm engine.
- kaba0 4y agoThey have to be implemented as interpreters only though. > Most languages have a way to run on a wasm engine But it is basically useless for managed languages that as of yet has to bring their runtimes as well.
- hahnchen 4y agoI think it’s meant to make it easier to use. They also have their whole package manager to use
- jasonwatkinspdx 4y agoWASM has an OS abstraction API that ends up being pretty good. There's work in progress on cross language resource sharing, interface types, etc. It's early days yet but this is generating excitement for WASM as a sort of very lightweight cross language container/vm. It's also useful in "plugin" scenarios, like say filtering code in a network proxy. Or if you wanted to make your own Function as a Service system.
- zrail 4y agoI'm not sure if it's mainstream but my thoughts on server-side WASM always run to user-provided logic. WASM provides a helpful building block for a generic user-provided logic sandboxed runtime. Think about a workflow engine embedded in a marketing product. Usually there's some kind of GUI builder which generates an AST to be interpreted directly at runtime. What if instead the GUI generated a WASM artifact to be run on sandboxed runtimes? What if, furthermore, you offered advanced users the opportunity to upload WASM binaries where they could implement arbitrarily complex logic to be executed in the sandbox? I think this is a super powerful concept, although of course making a business case for implementing it is the trick.
- fwsgonzo 4y agoI don't think a server-side sandbox makes sense for anything that is JIT-based (or even binary translation). We already have KVM which is actual native performance, and it can run anything you would ever want, and then some. WASM is bytecode working on a 2GB linear arena, and it fits OK in a browser.
- azakai 4y agoThe 2GB limit was a temporary browser limitation. Modern browers mostly support 4GB now. And wasm64 is testable today, which supports 64-bit pointers and more than 4GB.
- zrail 4y agoI don't think that's really the use case I'm describing. Maybe I'm doing a bad job, I dunno. The use case is essentially user logic for event stream processing, where the events are things like "received an email" or "clicked a link" or "3 days have passed". You're not going to spin up a KVM for every contact on a 2 million member email list even if you're using Firecracker, but executing a WASM blob for every event might be feasible.
- moralestapia 4y agowasm is a specification for a VM (VM as in Java, not as in AWS/docker). wasm gives you the bare minimum to run, other projects fill the gaps between that and what you would normally expect for an execution environment (ABIs, file system access, stacks, etc...). wasmer is one of such projects.
- trh0awayman 4y agoWASM is basically a misnomer at this point. People are using it as a universal virtual machine/runtime. Whether that makes any sense is still an open question.
- kbaker 4y agoIn your view, why does it not make sense? It certainly seems appealing as a universal runtime, and lives up to its claims as long as things like WASI get standardized.
- CharlesW 4y ago> WASM is basically a misnomer at this point. Web standards/technologies are in wide use outside of browsers (via things like Electron), so you may find that the name makes more sense when viewed through that lens.
- thecosmicfrog 4y agoAn example of this is Microsoft Flight Simulator. Packages such as aircraft are distributed/compiled as WASM modules and run (as I understand it) in a sandboxed environment within the simulator.
- helsontaveras18 4y agoThat’s the first use case that’s practical, in the wild, and adopted by Microsoft nonetheless. Do you have any additional details/links on how this works?
- cheriot 4y agoPlugins for desktop apps would be safer if the plugin is run with WASM.
- flohofwoe 4y agoWASM is also useful for distributing a single binary blob that runs on different Operating Systems and CPU architectures, instead of 'stamping out' NxM native executables. This area overlaps more with Java and .NET (but with more/different language options) than 'an alternative to JS in the browser'. For instance I have a C++ shader compiler which includes some massive 3rd party libraries (glslangValidator, SPIRVTools and SPIRVCross) which takes forever to compile, so distributing in source code form is not really an option, and the only alternative is to ship precompiled binaries for each supported OS/CPU combination. Currently I do this via GH Actions, which kinda works, but just building a single WASM blob and shipping that to users (who then would need to install one of the WASM runtimes though) sounds kinda interesting. PS: WASM may also be useful as universal plugin format. For instance the new Microsoft flight sim uses WASM instead of scripting or native DLLs for modding: https://docs.flightsimulator.com/html/Programming_Tools/WASM/WebAssembly.htm https://docs.flightsimulator.com/html/Programming_Tools/WASM...
- kaba0 4y agoJava’s GraalVM can do plenty of languages, on top of running managed ones much faster. I don’t see novelty here.
- flohofwoe 4y agoIf I compile a C or Rust program to run in GraalVM, will the LLVM bitcode be converted to some sort of universal bytecode, or does Graal attempt to run the bitcode directly via a plugin? (e.g. do I distribute GraalVM bytecode or LLVM bitcode to the user?). The documentation is a bit unclear about this, but there's this weird blurb at the end: > Note: LLVM bitcode is platform-dependent. The program must be compiled to bitcode for an appropriate platform. ...why would this detail even matter if LLVM bitcode is converted to 'GraalVM bytecode'? In any case, it doesn't sound much like "write once run everywhere" ;) See: https://www.graalvm.org/22.2/reference-manual/llvm/ https://www.graalvm.org/22.2/reference-manual/llvm/
- kaba0 4y agoGraal’s truffle runtime works basically as an AST interpreter, so you have to ship the LLVM bitcode. I have yet to get my feet wet with sulong, but my guess would be that LLVM will produce different bitcode on different platforms, and thus the execution can potentially be different - also note that llvm bitcode is not a stable format. But I don’t think that interpreting it on a different platform than it was compiled on would have a fundamental reason not to work (after all, it is just java code) - perhaps it uses the platform llvm libs for some parsing, which is not platform-agnostic?
- Sodman 4y agoBeing able to add arbitrary logic to an otherwise static binary has a lot of interesting use cases. For example Envoy Proxy supports hot-loading arbitrary HTTP filters compiled to WASM into its filter-chain. This allows users to extend the feature set of Envoy, by adding custom logic to request parsing, reporting custom metrics, calling out to other services before forwarding the request, etc etc. This allows their unique custom use-case-specific code to be managed separately to Envoy, so it can be ported across upgrades etc. It also means that if there's a very particular feature you want that's unique to your business, and wouldn't make sense to contribute to the upstream OSS project, you can write a WASM module for it. It's somewhat niche, because anything built in this way which is generally useful to many users, will probably just be made a native feature of the host platform. Conversely, anything that does something significantly complex and custom should probably live as it's own stand-alone microservice somewhere. There's still a lot of room for value between the two extremes though!
- brundolf 4y ago- Running code on a server you don't control - Running code you don't fully trust on a server you do control WASM comes with powerful sandboxing, and if you combine that with static linking you can pretty much drop Docker for your PaaS (and all the overhead/complexity/insecurity that comes with it). This is what Cloudflare Workers do
- FooBarWidget 4y agoAnd can someone ELI5 why WebAssembly is useful, given that there are already a myriad of other virtual machines out there (JVM, CLR, BEAM, etc)? And why could/did those other virtual machines not evolve to fulfill the need that WebAssembly fulfills? Why is a new machine language and new virtual machine necessary?
- IshKebab 4y agoWebassembly can be targeted by C/C++ and Rust. It's also designed with security in mind. The JVM is not a reliable sandbox.
- indymike 4y ago>And why could/did those other virtual machines not evolve to fulfill the need that WebAssembly fulfills? All three were designed primarily as bytecode interpeters that would run as a layer between the OS and application, and were primarily designed to run stand-alone (i.e. desktop/server apps). Java was originally included in most web browsers, but the applet model just didn't get it done for users - and most Java software moved either be web applications (i.e. serving HTML) or desktop or mobile applications. > Why is a new machine language and new virtual machine necessary? WASM was designed to be embedable (and secure), streamable and is now ubiquitous as it is supported by all three major browsers, plus Node (and Deno) and many desktop web-app platforms (e.g. Electron). The embedable part is what makes it really different than JVM, CLR and BEAM - for example, you can include a WASM runtime in your application and call WASM code from a C or Rust app just like the browser does.
- duped 4y agoWASM is JVM with lessons learned
- sanxiyn 4y agoWhat lessons did it learn?
- simonw 4y agoHow to implement a safe sandbox.
- pjmlp 4y agoThat remains to be battle tested, and there are already some USENIX talks on the matter.
- oblio 4y agoWell, if you rephrase that slightly, it probably covers the main idea: > How to implement a safe<<R>> sandbox.
- simonw 4y agoSticking it in every modern web browser for the past several years is a pretty good way of battle testing it!
- pjmlp 4y agoExcept this isn't a browser, and a bytecode paper standard isn't an implementation.
- pjmlp 4y agoVC money searching out the next gold mine for re-inventing P-Code, IBM TIMI, Burroughs, M-Code, EM intermediate language, JVM bytecode, MSIL, ....
- intelVISA 4y agoIs it really that well-funded? I doubt there's much money in P-Code v2 - most devs see right through it.
- pjmlp 4y agoSo much that is where Docker is trying to pivot into, WASM containers.
- oblio 4y agoYeah, but what's the business angle to sell to VCs? Putting ads in the low level runtime? :-))))
- pjmlp 4y agoJava Application Servers reboot.