7 ms·
WASM 2.0
- aleksi 1y agoCurious that Editor's Draft has "bikeshed" in the URL.
- lifthrasiir 1y ago"Bikeshed" here refers to the Bikeshed preprocessor [1]. [1] https://github.com/speced/bikeshed https://github.com/speced/bikeshed
- lioeters 1y agoAnnouncement post in March 2025 summarizes the changes from WASM 1.0. Wasm 2.0 Completed - https://webassembly.org/news/2025-03-20-wasm-2.0/ https://webassembly.org/news/2025-03-20-wasm-2.0/ > ..here is the summary of the additions in version 2.0 of the language: Vector instructions: With a massive 236 new instructions — more than the total number Wasm had before — it now supports 128-bit wide SIMD (single instruction, multiple data) functionality of contemporary CPUs, like Intel’s SSE or ARM’s SVE. This helps speeding up certain classes of compute-intense applications like audio/video codecs, machine learning, and some cryptography. Bulk memory instructions: A set of new instructions allows faster copying and initialization of regions of memory or ranges of tables. Multi-value results: Instructions, blocks, and functions can now return more than one result value, sometimes supporting faster calling conventions and avoiding indirections. In addition, block instructions now also can have inputs, enabling new program transformations. Reference types: References to functions or pointers to external objects (e.g., JavaScript values) become available as opaque first-class values. Tables are repurposed as a general storage for such reference values, and new instructions allow accessing and mutating tables in Wasm code. In addition, modules now may define multiple tables of different types. Non-trapping conversions: Additional instructions allow the conversion from float to integer types without the risk of trapping unexpectedly. Sign extension instructions: A new group of instructions allows directly extending the width of signed integer value. Previously that was only possible when reading from memory.
- immibis 1y agoYou can have an ISA sufficiently generic to run on any CPU, or one sufficiently specific to efficiently exploit SIMD on a particular CPU. Never both. That's why some platforms provider higher-level operations, like element-wise multiplication of packed arrays. I can't see whether the actual WASM2 SIMD instructions are sufficiently generic because apparently I'm rate-limited on GitHub (???) and therefore can't see the spec.
- flohofwoe 1y agohttps://web.archive.org/web/20250429065033/https://webassembly.github.io/spec/core/syntax/types.html https://web.archive.org/web/20250429065033/https://webassemb... Values are hardwired to 128 bits which can be i8x16/i16x8/i32x4/i64x2 or f32x4/f64x2, so that already limits the 'feature surface' drastically. IMHO as long as it covers the most common use cases (e.g. vec4 / mat4x4 floating point math used in games and a couple of common ALU and bit-twiddling operations on integers) that's already quite a bit better than having to fall back to scalar math.
- mdaniel 1y ago> apparently I'm rate-limited on GitHub (???) and therefore can't see the spec. Are you also on Firefox? I've been getting those 429s a lot over the past week or so. I haven't changed my configuration other than I'm religious about the "check for updates" button, but I cannot imagine a world in which my release-branch browser is a novelty. No proxies, yes I run UBO but it is disabled for GH
- eppsilon 1y agoI got some using Orion on iOS yesterday. Same engine as every other iOS browser, so I guess it's sending a user agent GH doesn't like?
- ncruces 1y agoThey were sufficient for me to implement most of `string.h` and get speedups between 4 and 16x vs “portable musl C code,” including sophisticated algorithms such as this one: http://0x80.pl/notesen/2016-11-28-simd-strfind.html http://0x80.pl/notesen/2016-11-28-simd-strfind.html I posted about my efforts here: https://news.ycombinator.com/item?id=43935284 https://news.ycombinator.com/item?id=43935284 Or, if you wanna jump to the code: https://github.com/ncruces/go-sqlite3/blob/main/sqlite3/libc/string.h https://github.com/ncruces/go-sqlite3/blob/main/sqlite3/libc...
- treetalker 1y agoWasm, per footnote 1: > A contraction of “WebAssembly”, not an acronym, hence not using all-caps.
- esperent 1y agoShouldn't it be WAsm in that case?
- jmull 1y agoI would say no. There aren't any particular rules about contractions and intermediate capitalization so we are free to choose. WAsm is more awkward than Wasm so the latter seems better.
- pseudosavant 1y agoI'm not sure. But I think we could use a new bike shed? I think it should be orange.
- shellac 1y agoNot that you have to use all caps for acronyms, e.g. scuba, radar, laser.
- andybak 1y agoI would maybe argue that used to be acronyms but now are just... well, words.
- strogonoff 1y agoIt’s one thing to take an acronym and “demote” it to a common noun if it’s being used often by wide public (not unlike how proper nouns become common nouns), it’s another thing to randomly pretend that a regular noun is an acronym. I’m looking at you, photographers shouting “RAW” in all caps whenever the topic comes up. “WASM” rubs me wrong for the same reason. I admit to being guilty of this and mimicking whatever form I encounter first, but then I’d switch once I look it up. I don’t quite understand why would anyone do otherwise.
- TekMol 1y agoI'm still skeptical about the whole Wasm ordeal. If you want to run code written in other languages in the browser, you could just as well compile to JavaScript. All Wasm brings to the table is a bit of a speed improvement.
- dgb23 1y agoIt's difficult (and ugly/foreign) to write fast JS and at some point you hit a wall. Incidentally that's why/how Wasm got created in the first place.
- cheschire 1y agoIt’s not a complete replacement for JS transpiling. It has some advantages for specific use cases. A couple benefits I like are: Not having the JS GC randomly pausing your process unpredictably. Sandboxing untrusted code, i.e. you sell a SaaS and you also want clients to be able to run untrusted plugins from a marketplace.
- TekMol 1y agoYou can use fixed data structures like Uint8Array in JavaScript just like you can (have to?) in Wasm. Then you won't have the GC do stuff, right?
- emaro 1y agoEven if this were true, 'a bit of a speed improvement' is still huge given the amount of JS that's run in our world.
- qoez 1y agoWasm with simd can get things like physics simulation and some ML on the order of 2x faster. I'm finding it really useful.
- pjmlp 1y agoOr let the GPU do it instead.
- Dabbling_Dion 1y agoDOA. Without direct browser support for WASM with DOM access ( and no need for JavaScript "shim"), all this is futile.
- lifthrasiir 1y agoMight be futile for the broader scope, but the main scope of enabling native code in the browser would remain strong.
- adrian17 1y agoWhat do you mean, DOA? It's been in active use for years now. As far as I know, "2.0" is just a marketing term batching several extensions standardized since 1.0 (and simplifying feature queries "are extensions X,Y,Z supported" to "is 2.0 supported"), not unlike what Vulkan does with their extensions.
- cedws 1y agoIt’s not DOA, it just became everything except anything to do with “web.” The purpose it was invented for has been forgotten.
- krapp 1y agoThe purpose it was invented for was not the web. WASM was designed from the beginning to be a platform-independent technology[0]. The HN crowd has just always been terminally myopic about this because it has "web" in the name. [0]https://learn-wasm.dev/tutorial/introduction/what-webassembly-is-not https://learn-wasm.dev/tutorial/introduction/what-webassembl...
- pdubroy 1y agoThe WebAssembly spec is quite approachable, but for anyone who is interested in learning Wasm and doesn't want to read the spec — WebAssembly from the Ground Up (https://wasmgroundup.com/ https://wasmgroundup.com/) an online book to learn Wasm by building a simple compiler in JavaScript. It starts with handcrafting bytecodes in JS, and then slowly builds up a simple programming language that compiles to Wasm. There's a free sample available: https://wasmgroundup.com/book/contents-sample/ https://wasmgroundup.com/book/contents-sample/ (Disclaimer: I'm one of the authors)
- MrResearcher 1y agoIs it possible to "instrument" the WASM code to enable in-process debugging? In other words, would it be possible to generate WASM based off some input string (my custom language) on-the-fly, and then run it with breakpoints and memory inspection, all within the same Javascript script hosted on, say, a web page?
- pdubroy 1y agoI'm not sure I totally understand what you mean by "in-process" here. But you could have some JavaScript that compiles some code in your custom language to WebAssembly and then execute it, and you can use the browser dev tools to set breakpoints the Wasm, inspect the memory, etc. In the book, we don't cover source maps, but it would also be possible to generate source maps so that you can set breakpoints in (and step through) the original source code in your custom language, rather than debugging at the Wasm instruction level. Does that answer your question?
- MrResearcher 1y agoSadly, no, I'd like to write a ~Prolog interpreter (compiler into WASM that would dynamically replace parts of the implementation as source code evolves), and have the debugger and WASM memory inspector as part of the web page written in Javascript, which was used to compiled the code in the first place. That is, would it be possible to implement a debugger and memory inspector in Javascript without resorting to dev tools? Prolog doesn't map 1:1 to WASM/Javscript via source maps, making it nearly impossible to properly debug it in dev tools.
- anentropic 1y agoAre any of the runtimes already implementing this?
- adrian17 1y agoMost have been for some time now. As the announcement post says: > the Wasm Community and Working Groups had reached consensus and finished the specification in early 2022. All major implementations have been shipping 2.0 for even longer. > In a future post we will take a look at Wasm 3.0, which is already around the corner at this point! Features in 3.0 presumably also being mostly implemented already, some maybe just kept behind feature flags.
- titzer 1y agoEverything in 3.0 has at least two browser implementations; that's part of the requirements for advancement to phase 4. Wasm 2.0 is complete in a handful of engines, whereas 3.0 is less well-supported. Wizard is almost done with 3.0; only memory64 and relaxed-simd are incomplete.
- thrance 1y agoIs there anywhere I could look at the "changelogs" between 1.0 and 2.0, and 2.0 and 3.0? All I could find are different versions of the spec that don't seem very keen on expliciting what changed.
- thomasballinger 1y agoThere's a change history in the spec at https://webassembly.github.io/spec/core/appendix/changes.html https://webassembly.github.io/spec/core/appendix/changes.htm... and I see a 3.0 branch with updates for 3 https://github.com/WebAssembly/spec/blob/1e8f1dad8ca35ef39412a8965eff39127946ee81/document/core/appendix/changes.rst#release-30 https://github.com/WebAssembly/spec/blob/1e8f1dad8ca35ef3941...
- 1y ago
- rossant 1y agoCan C functions returning structs by value be compiled to WASM?
- thrance 1y agoYes, but AFAIK you can't "export" them to JS currently.
- singularity2001 1y agothat's right unfortunately these types are opaque right now
- AlexAltea 1y agoGreat release with many welcome features. As a nit, I'm rather disappointed at the inclusion of fixed-size SIMD (128-bit wide) instead of adaptive SIMD instructions letting the compiler maximize SIMD width depending on host capabilities, similar to how ARM SVE works.
- lifthrasiir 1y agoPersonally I prefer fixed-size SIMD mainly because it enables more usages than usual vector instructions while vector instructions can be rather trivially lowered to fixed-size SIMD instructions. I'd call them as "opportunistic" usages, because those are perfectly fine without SIMD or vector but only get vectorized due to the relatively small size of SIMD registers. Those usages are significant enough that I see them as useful even with the presence of vector instructions.
- camel-cdr 1y agoIf you have variable length SIMD, you can always treat them as fixed-size SIMD types. New x86 processor don't executes 128-bit SIMD, the vecto ALUs are all wider now and 128 and 256-bit instructions have the same throughput and latency. Also, do you have an example for such "opportunistic" usages? I suppose mainly things the SLP vectorizer can usually do already (in compiled languages, I'm not sure how good the JIT is these days). I worry that we now may end up in a world, where "hand optimized SIMD" in WASM ends up slower than autovectorization, because you can't use the wider SIMD instructions and leave 2x (zen4) to 4x (zen5) of the performance on the table.
- lifthrasiir 1y ago> Also, do you have an example for such "opportunistic" usages? The simplest example would be copying a small number of bytes (like, copying structs). Vector instructions generally have a higher setup cost, like setting so it can't really be used for this purpose. Maybe future vector instructions have no such caveats and can be used as like SIMD, but AFAIK it's not yet the case even for RISC-V's V extension.
- 1y ago
- inoffensivename 1y agoI've been working on Webassembly runtimes for the last year or so, specifically on spec compliance and performance. I came to it as a neophyte, but I've become quite fond of the specification. It's a bit hard to get started with the notation, but it's refreshing to have such a thoroughly specified language. There is a reference interpreter generated directly from the spec, which is very useful for resolving questions about what a runtime should do in a given situation. The provided specification tests allow implementers to be confident that their runtime conforms to the spec. Overall I think it's an impressive specification and is worth studying .
- iFire 1y agoI got blocked writing high level wasm bindings with types other than int or float, is this still the case?
- marianoguerra 1y agowith the wasm-gc proposal you get access to structs and arrays: https://github.com/WebAssembly/gc/blob/main/proposals/gc/Overview.md https://github.com/WebAssembly/gc/blob/main/proposals/gc/Ove... with the component model's wit you get higher level types like enums, option, result and generics: https://component-model.bytecodealliance.org/design/wit.html https://component-model.bytecodealliance.org/design/wit.html
- singularity2001 1y agono you don't , these types are unfortunately opaque only internally usable.
- mamidon 1y agoIt's more accurate to say those do the boilerplate of memory access necessary for complex types for you. You're still basically limited to integers and floats. But when you think about it, isn't that basically true for native languages?
- Klasiaster 1y agoWhat's truly missing for Wasm and WASI to be an alternative to POSIX is dynamic instatiation so that a Wasm program/component can start another Wasm program/component by providing the bytecode at runtime. So far I don't think anyone is working on that.
- packetlost 1y agoI wonder if it hasn't been done because it would break the security model
- xmorse 1y agodoes it? a program would be able to spawn another program only with the exports available to him
- marianoguerra 1y agoin the browser you can compile modules and create instances from arrays of numbers/bytes, here's an obfuscated example: https://wasmgroundup.com/blog/wasm-compiler-in-a-tweet https://wasmgroundup.com/blog/wasm-compiler-in-a-tweet if the host provides the guest wasm module via imports a function to create and run from an array of bytes then it can be done today (if I understand you correctly). Here's some related content: https://github.com/pdubroy/til/blob/main/wasm/2024-02-22-Run-time-code-generation.md https://github.com/pdubroy/til/blob/main/wasm/2024-02-22-Run...
- azakai 1y agoYes, this can be done today, though it needs some gluing together. On the Web (and in Node etc.) you can use JavaScript to create and link the modules, which is how dynamic linking support for wasm works there: https://emscripten.org/docs/compiling/Dynamic-Linking.html https://emscripten.org/docs/compiling/Dynamic-Linking.html
- singularity2001 1y agoThe wasp runtime has a run_wasm host export but I guess that's cheating https://github.com/pannous/wasp https://github.com/pannous/wasp
- canadiantim 1y agoCan WASM be considered "safer" than pure javascript?
- marianoguerra 1y agoyes: > WebAssembly provides no ambient access to the computing environment in which code is executed. Any interaction with the environment, such as I/O, access to resources, or operating system calls, can only be performed by invoking functions provided by the embedder and imported into a WebAssembly module. more info here: - https://webassembly.org/docs/security/ https://webassembly.org/docs/security/ - https://www.w3.org/TR/wasm-core-1/#design-goals%E2%91%A0 https://www.w3.org/TR/wasm-core-1/#design-goals%E2%91%A0
- dathinab 1y agoTL;DR: depending on your use case and defintion of "safe" in most general prupose cases they can be assumed to be "in general" as safe as the other. For the sandbox it's hard to say, lets just say for most considerations they can be treated as "as safe" as the other. But many vulnerabilities had been in APIs interacting with external resources, I/O etc.And currently in the browser that in general goes through JS, so some would say JS is more secure. But it's not that a WASM engine can't provide such APIs to WASM without going through JS (e.g. see WASI) and weather it's WASM or JS they semantically only have access to this APIs through their engine which can guard/filter/limit/etc. the APIs however it wants (i.e. you can't call the systems libc function directly or anything like that). So in general I would say the question if one is "safer" then the other is meaningless. Especially if we compare a custom JS only vs. WASM only sandbox which doesn't have DOM and all the old JS browser APIs. Through with this APIs you could say WASM is slightly more save. There are also some other interesting considerations like e.g. in JS you have eval (and DOM to do eval in a roundabout way) but then in WASM you have memory safety issues (depending on the source language, through due to WASM design they are much much less abusable then in native C, but they still can involve vulnerabilities leading to affecting program behavior in a way which can be a security issue, e.g. overflow overwriting a "valid" flag or similar). Anyway if asked "in general" I think there is no meaningful answer outside of treat it as the same. But if you have specific use-cases/needs things might differ.
- 1y ago
- BuckRogers 1y agoA bytecode for the web was a dream for a very long time. As a C# developer who appreciates Blazor being on the cutting edge with WASM from early on, I'm looking forward to WASM 2.0's changed being added. .NET has a massive jump on this and I think it's one of the better bets they've taken.
- mountainriver 1y agoIs there a list of working WASM apps in the wild? I like the idea of WASM but it often feels like DAPPs. This kinda fun idea that nothing is actually based on, maybe I’m wrong
- CharlesW 1y agohttps://madewithwebassembly.com/ https://madewithwebassembly.com/ https://github.com/mcuking/Awesome-WebAssembly-Applications https://github.com/mcuking/Awesome-WebAssembly-Applications
- nenaoki 1y agoThe Wasm Constant Time proposal was just moved to inactive 4 days ago[0]. From what I can tell the bulk of the work for it was done in 2018[1], but it needs updating to consider SIMD, and for legwork to be done on moving it along as a proper spec extension. Until someone picks up this valuable work and lands this much-needed feature in Wasm, we're extremely vulnerable to timing attacks in all Wasm crypto. [0] https://github.com/WebAssembly/proposals/blob/9fc7a85e/inactive-proposals.md https://github.com/WebAssembly/proposals/blob/9fc7a85e/inact... [1] https://github.com/PLSysSec/ct-wasm https://github.com/PLSysSec/ct-wasm