24 ms·
WebAssembly 2.0 First Working Draft
- rektide 5y agoAre subprojects intended to eventually make it into the main spec or do they remain standalone? GC, threads, atomics, component-model, interface-types... Im not sure what to expect to eventually make it into this spec & what will continue developmemt semi-independently. Personally https://github.com/WebAssembly/component-model/pull/23 https://github.com/WebAssembly/component-model/pull/23 feels like it marks the start of webassembly's first full era. We need interoperation, webassembly needs to really be embeddable, & only then can we really understand & explore what webassembly means to the world. (Rust got an early start with wasm-bindgen, doing all the lifting on their side, but it's not reasonable & only semi-interoperable having each language rebuild that bindgen system & abingor itself... hence canonical abi & component-model.) Edit: tux3 has a good comment linking the changelog, noting that indeed numberous specs have been integrated. https://news.ycombinator.com/item?id=31087610 https://news.ycombinator.com/item?id=31087610 Really excited for multiple table per module support! The idea of a capabilities based sort of system, where a module is handed a couple working sets of data as SharedArrayBuffers to work g communicate with, is quite compelling.
- the_duke 5y agoAlso take a look at wit-bindgen [1], which is basically a prototype for interface types and supports multiple languages. I agree we that interface types/components will be a game changer. And also that progress on all the important proposals (GC, interface types, linking, stack control, threads) has been painfully slow. [1] https://github.com/bytecodealliance/wit-bindgen https://github.com/bytecodealliance/wit-bindgen
- syrusakbary 5y agowit-bingen is great. For those that want to use wit-bindgen with Wasmer (tl;dr I work at Wasmer) here's the repo: https://github.com/wasmerio/wit-bindgen https://github.com/wasmerio/wit-bindgen
- richdougherty 5y agoThe whole list of proposals and where they're at is here: https://github.com/WebAssembly/proposals https://github.com/WebAssembly/proposals You can see that "interface types" is at "Phase 1 - Feature Proposal (CG)", so still early days. And there's a link to the proposal here, for people like me who don't know about it: https://github.com/WebAssembly/interface-types https://github.com/WebAssembly/interface-types
- simonw 5y agoIs there a good summary anywhere of what's new in 2.0 compared to 1.0?
- paulsmith 5y agotl;dr SIMD - new: vector types - 128-bit width FP and integer types and values for SIMD, with related instructions (and validation thereof) plus memory instructions for wide loads, and support in the runtime for wide values (consts, etc.), and in the text and binary formats - value types (i32, i64, f32, f64) are now called number types - new: reference types - basically function pointers and pointers to objects in the host, values of which can be stored in tables, with related instructions for accessing them and checking for null - new: table instructions - get, set, size, grow, fill, copy, etc. - element and data segments - not new but expanded definition and given more runtime support (added to the store, can be referenced by address like other runtime objects), plus new indices for referencing segments and their modes (basically, how they are initialized during instantiation) - limited form of subtyping allowed when importing external values - result types can be a sequence of values (i.e., multiple return values from functions) - new instructions to avoid trapping on floating-point to integer conversions ("saturation")
- simonw 5y agoThis is exactly what I was looking for, thanks very much!
- teabee89 5y agoThere's also: Multiple values[1] "Generalized the result type of blocks and functions to allow for multiple values; in addition, introduced the ability to have block parameters: - Function types allow more than one result - Block types can be arbitrary function types" [1] https://www.w3.org/TR/wasm-core-2/appendix/changes.html#multiple-values https://www.w3.org/TR/wasm-core-2/appendix/changes.html#mult...
- teabee89 5y agoHere: https://www.w3.org/TR/wasm-core-2/appendix/changes.html https://www.w3.org/TR/wasm-core-2/appendix/changes.html
- tux3 5y agoI assume this page describes what changed since 1.0: Since the original release 1.0 of the WebAssembly specification, a number of proposals for extensions have been integrated. The following sections provide an overview of what has changed. https://webassembly.github.io/spec/core/appendix/changes.html https://webassembly.github.io/spec/core/appendix/changes.htm...
- infogulch 5y agoThe additions that look interesting to me are multiple return values for functions, and table manipulations. IIRC tables are used to communicate things like function pointers with the host executor, maybe like a vtable but more general.
- richdougherty 5y agoThanks! Here's a quick summary from there, with links to the implemented proposals. Multiple values: Generalized the result type of blocks and functions to allow for multiple values; in addition, introduced the ability to have block parameters https://github.com/WebAssembly/spec/blob/main/proposals/multi-value/Overview.md https://github.com/WebAssembly/spec/blob/main/proposals/mult... Reference types: Added and as new value types and respective instructions Table instructions: Added instructions to directly access and modify tables Multiple tables: Added the ability to use multiple tables per module Bulk memory and table instructions: Added instructions that modify ranges of memory or table entries https://github.com/WebAssembly/spec/blob/main/proposals/reference-types/Overview.md https://github.com/WebAssembly/spec/blob/main/proposals/refe... https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md https://github.com/WebAssembly/spec/blob/main/proposals/bulk... Vector instructions: Added vector type and instructions that manipulate multiple numeric values in parallel (also known as SIMD, single instruction multiple data) https://github.com/WebAssembly/spec/tree/main/proposals/simd/ https://github.com/WebAssembly/spec/tree/main/proposals/simd... Sign extension instructions: Added new numeric instructions for performing sign extension within integer representations. https://github.com/WebAssembly/spec/blob/main/proposals/sign-extension-ops/Overview.md https://github.com/WebAssembly/spec/blob/main/proposals/sign... Non-trapping float-to-int conversions: Added new conversion instructions that avoid trapping when converting a floating-point number to an integer https://github.com/WebAssembly/spec/blob/main/proposals/nontrapping-float-to-int-conversion/Overview.md https://github.com/WebAssembly/spec/blob/main/proposals/nont...
- dmkolobov 5y agoLooking at this it seems tail-calls are still not part of the spec? Has there been any news regarding return_call? Would be cool to see it for more efficient implementation of functional languages.
- titzer 5y agoTail calls are only blocked on a second production engine implementing them. V8 has been done with tail calls for more than 3 years.
- The_rationalist 5y ago
- miolini 5y agoLooking for memory shrink instruction.
- eatonphil 5y agoIs WebAssembly faster than JavaScript? Any good benchmarks you can link me to? I found one of Daniel Lemire's [0] from 2018 which seems to suggest it's basically not much faster. 2018 is long enough away from now though that this post may not be relevant. I don't know. It's odd to me how WebAssembly seemed to be started as a way to get performance improvements by working with cached instructions (and maybe also explicit memory management and integer types) but I don't hear much about performance these days. Maybe I'm not paying attention. Instead I hear more about it as a universal platform or a way you can run C/C++ code in the browser (like tree-sitter and CPython and Ruby, etc.). Or about people using it in edge compute or as the engine for smart contracts. In those ways you could just as well have used the JVM though. [0] https://lemire.me/blog/2018/10/23/is-webassembly-faster-than-javascript/ https://lemire.me/blog/2018/10/23/is-webassembly-faster-than...
- joren- 5y agoI do see some improvements for FFT workloads. The SIMD webassembly version is quite a bit faster. Try it yourself: https://0110.be/posts/pffft.wasm%3A_an_FFT_library_for_the_web https://0110.be/posts/pffft.wasm%3A_an_FFT_library_for_the_w...
- GiorgioG 5y agoI don't care if it's faster, the same or even slightly slower. The sooner I can start working on large applications with a strongly typed language (that isn't just transpiled to JS) - the better.
- eatonphil 5y agoMy point is that compilation targets are somewhat arbitrary. Non-JavaScript languages have been compiling to JavaScript for a long time. What difference does it make for you as a user of a language that it compiles to webassembly than to JavaScript or any other VM?
- laszlokorte 5y agoJavaScript being garbage-collected, having a rather complex runtime, not having proper integers etc... makes it a rather unfortunate compile target. Yes you can do it and it is done but js idiosyncrasies leak into the source langues pretty easily.
- crudbug 5y agoNo DOM API ? No GC API ?
- TheCycoONE 5y agoIt appears to include the currently standardized extensions. GC is a proposal in phase 2, and I'm not even aware or a proposal for DOM access yet but it would require several other proposals to go through first.
- trzeci 5y agoDOM API? Why? This can be added by any third party library. Wasm should not care about DOM
- yurymik 5y agoI still can't find any mentions of external memory mapping without copying it into the heap. _Very_ disappointing as it makes yet another version of WASM completely unusable for many high-performance applications :(
- keithwinstein 5y agoThe multi-memory proposal is your best bet for this: https://github.com/WebAssembly/multi-memory https://github.com/WebAssembly/multi-memory It's supported in Wasmtime, WAVM, and WABT and wasm2c, and not much else so far (https://webassembly.org/roadmap/ https://webassembly.org/roadmap/).
- jacobmischka 5y agoNeat, a few of these accepted proposals were the topic of my Master's thesis a couple years ago: https://github.com/jacobmischka/uwm-masters-thesis https://github.com/jacobmischka/uwm-masters-thesis Exciting to see a major release, though admittedly it seems a little arbitrary if there aren't any breaking changes (and very problematic if there are?).
- MuffinFlavored 5y agoAs somebody familiar with WebAssembly, how would you do FFI? like say you wanted to make a J2534 DLL http://www.drewtech.com/support/passthru.html http://www.drewtech.com/support/passthru.html How would you export these DLL functions or even call functions from other DLLs (dlopen/dlsym, etc.)
- gary_0 5y agoYou can import host functions and data to a WASM VM much like you would with, say, an embedded Python VM. The exact API depends on which VM implementation and host language you're using. dlopen/dlsym support is still in the works (for example, see [0]). You can't call function pointers directly from WASM, naturally, but it is possible to wrap dlsym so you can use it from a WASM program. There just isn't a standardized/pre-made way to do it yet, so you'd have to write the glue code yourself. [edit] The Emscripten WASM toolchain seems to support dlopen/dlsym, see: https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md https://github.com/WebAssembly/tool-conventions/blob/main/Dy... [0] https://github.com/wasmerio/wasmer/issues/1995 https://github.com/wasmerio/wasmer/issues/1995
- bluejekyll 5y agoYou may want to look into WASM interface types, which is defining what amounts to an IDL for WASM so that different languages have common calling conventions: https://hacks.mozilla.org/2019/08/webassembly-interface-types/ https://hacks.mozilla.org/2019/08/webassembly-interface-type... I don’t know if there’s a better intro article. I believe this is the current iteration of the proposal: https://github.com/WebAssembly/interface-types/blob/main/proposals/interface-types/Explainer.md https://github.com/WebAssembly/interface-types/blob/main/pro...
- pwdisswordfish9 5y agoAre there any actual incompatibilities or is the version number just a marketing gimmick?
- eatonphil 5y agoThere isn't a law saying all legit software must use semver. :) Python makes breaking changes whenever they want in minor version changes.
- kibwen 5y agoTechnically, even semver doesn't strictly require you to not update the major version when there haven't been incompatible changes (I swear, a triple negative is the easiest way to parse this sentence :P ).
- sinsterizme 5y agoHow about: You can bump the major version with no incompatible changes and still be semver compliant
- singularity2001 5y agoOnly forward incompatibilities, that is: Wasm 1.0 engines can't handle 2.0 opcodes etc
- AgentME 5y agoThe web tries very hard to avoid backwards incompatibilities. I don't expect the WASM standard to ever directly get any backwards incompatibilities, unless they're opt-in (like how using JS modules stops you from using with-statements).
- tester89 5y agoThis https://github.com/WebAssembly/spec/issues/1439 https://github.com/WebAssembly/spec/issues/1439
- encryptluks2 5y agoIf you want sandboxes then use Flatpak or force Microsoft and Apple to implement a standards compliant sandboxing API. The web browser is not the place to do it and people should be looking at how this will be used to run binary blobs anytime you visit a site.
- kaba0 5y agoHow is the litany of minimized js used as a compile target not binary blobs already?
- encryptluks2 5y agoThere is a difference between obfuscated JS and minimized. Minimized can be unminimized. Also, two wrongs don't make a right.
- autoexec 5y agoI know folks are excited about webassembly but it's a security nightmare. JS alone is bad enough with most exploits I see that can get you infected just by visiting a page requiring it even when the issue doesn't lie in JS directly. The idea of letting any random website you visit run code on your machines should give anyone pause, but it seems like everybody is just too excited about the powerful web applications they could make to worry about the malicious web apps that will be created as well. For now I've got webassembly disabled, and I don't see that changing
- lxgr 5y agoAre there any improvements in there that would allow for more efficient bytecode interpreters in WASM? As far as I understand, something like e.g. a high-performance JVM would be hard to do in WASM due to its machine's Harvard-like architecture.
- slaymaker1907 5y agoThere is some really exciting stuff "https://github.com/WebAssembly/proposals https://github.com/WebAssembly/proposals" I'm particularly excited about stack switching.
- outside1234 5y agoAs an aside, how does one get involved in the WebAssembly community? For example, if you wanted to get involved in Kubernetes you'd go to KubeCon, and governance of the OSS project is pretty understandable? What is the equivalent in WebAssembly land?
- gulbanana 5y agoSeek employment at Mozilla, Google or Apple.
- tlively 5y agoThe simplest way to get involved is to start attending the biweekly standardization meetings. The agendas are organized here: https://github.com/WebAssembly/meetings https://github.com/WebAssembly/meetings To attend the meetings, first join the W3C WebAssembly Community Group here: https://www.w3.org/groups/cg/webassembly https://www.w3.org/groups/cg/webassembly, then email the CG chairs at webassembly-cg-chair@chromium.org to ask for an invite. From there you'll get a sense of who folks are so you can pair names with faces when contributing to the various proposal discussions on the many proposal repos listed here: https://github.com/webassembly/proposals https://github.com/webassembly/proposals. To get a sense of how things are run and decided, read the process documents here: https://github.com/WebAssembly/meetings/tree/main/process https://github.com/WebAssembly/meetings/tree/main/process. The TL;DR is that the community group and its subgroups decide everything by consensus via votes during the meetings.
- ramesh31 5y agoAny higher level developments in WASM land? What about garbage collection?
- tlively 5y agoThe GC proposal recently moved to phase 2 and has a lot of momentum. Teams working on compiling Java, Kotlin, and Dart to Wasm are closely involved in the standardization effort and implementations are under way in V8 and other Web engines. Right now the bulk of the effort on the standardization side is in tweaking the instruction set to simplify it and improve performance and on the implementation side the focus is heavily on optimizations, both offline and in the engines.
- zacharycohn 5y agoTypo in the Abstract paragraph. "WebAseembly Core"
- alephnan 5y agoWhat are examples of real applications / businesses using WebAssembly?
- wiqar 4y agoDisclosure: I work for Wasmer, a WebAssembly company. 1. Figma uses Wasm extensively in the browser. 2. Unity ships their game engine to the browser using WebAssembly 3. Amazon Prime uses WebAssembly as a part of their OTT stack 4. A lot of Blockchain companies user WebAssembly to process smart contracts. 5. There are new start-ups lile Hotg.ai that use WebAssembly to deploy ML solutions to connected or semi-connected devices. (Hotg.ai uses Wasmer) 6. Shopify uses AssemblyScript and WebAssembly for their plugin system.
- alephnan 5y agoDoes anyone know why Rust is one of the "de facto" host languages for WebAssembly? Is it because Rust naturally leant itself to machine code, therefore it was easier to build a compiler? Is it because the Rust community wants to create more "killer features" for the language and have it stand out? Are there benefits to using Rust versus TypeScript as the host language?
- nindalf 5y agoCan TypeScript be compiled to WebAssembly? My understanding was that it couldn’t be, although a related language AssemblyScript could be.
- biztos 5y agoI don’t know but I would guess it’s because of the relationship between Rust and Mozilla. https://news.ycombinator.com/item?id=26067118 https://news.ycombinator.com/item?id=26067118 There are probably specific advantages to Rust, but it’s also just nice to work in a language you like. I can compile Go to WebAssembly so I’m not going to write TypeScript. Your preferences may differ.
- amouat 5y agoOne of the major benefits of Rust is that it isn't garbage collected. I'm not sure of the current status of GC support in WASM, but it used to mean that to compile something like Go to WASM also meant including a full GC implementation in the WASM code, not only bloating it but complicating implementation etc.
- jfmc 5y agoWhat about pointer size? Is still only 32-bits? It is impossible to write some C programs when you do not know the size of your data and pointers. I'm asking that because despite all the hype, wasm binaries are still 32-bit (at least in browsers), while 32-bit OS are being deprecated. 64-bit pointers are really good for some applications, with no performance degradation at all. Does Wasm 2.0 support branch instructions needed for irreducible control flows? (without the relooper hack)
- shadowofneptune 5y agoI had some trouble understanding the problem, since I've never had to translate a program that relies on goto into a purely structured one. Does this article cover it well? https://medium.com/leaningtech/solving-the-structured-control-flow-problem-once-and-for-all-5123117b1ee2 https://medium.com/leaningtech/solving-the-structured-contro...
- jfmc 5y agoThe requirement for structured programs dates back from the asm.js hack. Both relooper and stackifier are still workarounds. CPUs do not require structure programs at all. Unless there is a really good reason this still looks a hack driven by limitations of the underlying code generation. I understand that some compilation passes are easier/cheaper with structured control. But then... why are not LLVM and GCC enforcing them as well (at least their roadmaps)?
- astrange 5y agoIt’s for security reasons and enabling static code analysis, there’s no particular need to make compilation “easier”. PNaCL also had a lot of limitations though I don’t remember what they actually were.
- deleted 5y ago[deleted]
- faichai 5y ago
- trzeci 5y agoDid I miss something, but I don't see any mention about improvements in debugging capabilities. As a game developer that targets iOS/Android/UWP/WASM - WASM will be never a first target to work with, if there will be no debugger connection between IDE and Browser, that understands WASM. The current solution that works only for Chrome and allows to use DWARF is an improvement but it has lot's of limitations: One of them is the limit of 4GiB (or 2GiB - don't remember) of DWARF file. Secondly - the entire browser tends to crash with that plugin on larger projects.
- jfmc 5y agoI have the strange feeling that WASM is reinventing the wheel at each step and that they should have continued with PNaCL technology.
- journey_16162 5y agoMy dream for WebAssembly is direct filesystem / local database access in Electron apps and mobile apps powered by a WebView. So you could have for instance, a Rust binary that does almost everything and is able to use DOM for rendering. Currently if I understand it correctly the only way to do that is without WASM actually. A separate binary communicating via IPC with JavaScript in the renderer process - I'm not sure if the latency is good enough to put any front-end logic in that binary. Edit: Actually it's quite viable as it is and I'm not sure how I did not think of it sooner. Just run everything in WASM and make requests to the database like WASM -> JavaScript -> IPC and latency is not a problem here.