Questions tagged [webassembly]

WebAssembly (abbreviated Wasm) is a new portable, size- and load-time-efficient format suitable for compilation to the web.

WebAssembly

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.

Efficient and fast

The Wasm stack machine is designed to be encoded in a size- and load-time-efficient binary format. WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.

Safe

WebAssembly describes a memory-safe, sandboxed execution environment that may even be implemented inside existing JavaScript virtual machines. When embedded in the web, WebAssembly will enforce the same-origin and permissions security policies of the browser.

Open and debuggable

WebAssembly is designed to be pretty-printed in a textual format for debugging, testing, experimenting, optimizing, learning, teaching, and writing programs by hand. The textual format will be used when viewing the source of wasm modules on the web.

Part of the open web platform

WebAssembly is designed to maintain the versionless, feature-tested, and backwards-compatible nature of the web. WebAssembly modules will be able to call into and out of the JavaScript context and access browser functionality through the same Web APIs accessible from JavaScript. WebAssembly also supports non-web embeddings.

Resources

2772 questions
140
votes
4 answers

What languages can be compiled to WebAssembly (Wasm)?

What languages can be compiled to WebAssembly (Wasm)? I believe right now C, C++, and Rust (experimental) can be compiled to WebAssembly, with the llvm compiler backend, with languages like Java, Swift, and C# not currently being supported, but…
Jordan Stewart
  • 3,187
  • 3
  • 25
  • 37
128
votes
5 answers

Compiling Python to WebAssembly

I have read that it is possible to convert Python 2.7 code to Web Assembly, but I cannot find a definitive guide on how to to so. So far I have compiled a C program to Web Assembly using Emscripten and all its necessary components, so I know it is…
Robbie
  • 1,733
  • 2
  • 13
  • 20
117
votes
3 answers

What is the difference between asm.js and WebAssembly?

I have been reading about asm.js and WebAssembly recently: http://ejohn.org/blog/asmjs-javascript-compile-target/ https://brendaneich.com/2015/06/from-asm-js-to-webassembly/ I am still confused about a few things: Is asm.js code compiled in time…
NeoWang
  • 17,361
  • 24
  • 78
  • 126
108
votes
5 answers

Blazor performance

I would like to start using Blazor, despite the fact that it is still at the alpha level. As I understand it, Blazor uses WebAssembly to compile C# on the client side. And I have these questions: Does this approach run faster than, for example,…
FoxPro
  • 2,054
  • 4
  • 11
  • 34
69
votes
6 answers

How can one generate and save a file client side using Blazor?

I want to have a SPA that's doing all the work client side and even generating some graphs/visuals. I'd like to be able to have the user click buttons and save the visuals, tables, and other things from the page (that are both seen and not seen, so…
shawn.mek
  • 1,195
  • 1
  • 11
  • 17
63
votes
4 answers

Why the JVM cannot be used in place of WebAssembly?

As far as I understood, JavaScript cannot be compiled ahead of time because of it's dynamic nature. So Interpretation and just in time compilation happens at run time, that affects JavaScript performance. So WebAssembly comes into picture. Languages…
Jawahar
  • 4,775
  • 1
  • 24
  • 47
58
votes
5 answers

How can I return a JavaScript string from a WebAssembly function

How can I return a JavaScript string from a WebAssembly function? Can the following module be written in C(++) ? export function foo() { return 'Hello World!'; } Also: Can I pass this to the JS engine to be garbage collected?
user181351
50
votes
6 answers

How do I compile a C++ file to WebAssembly?

Suppose I have a simple, self-contained C++ file (math.cpp) like this: int add(int x, int y) { return x + y; } How would I compile it to WebAssembly (math.wasm)? Note: I am using the Clang tool-chain.
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
49
votes
5 answers

How can I access and manipulate the DOM in WebAssembly?

I have recently started using WebAssembly for some of my projects. I am doing this because I heard that WASM is faster than JavaScript. When I actually started my first WASM project, I realized that I didn't know how to manipulate the DOM in C++. Is…
user12658460
44
votes
1 answer

using WebAssembly in chrome extension

I have a chrome extension that includes a complicated function comp_func(data) which takes a lot of CPU by performing many bitwise operations. Because of that, I'm trying to use WebAssembly. I've tried to follow several tutorials, for example this…
nogmos
  • 859
  • 1
  • 8
  • 12
42
votes
2 answers

How to use alert(),confirm() and prompt() function using Blazor?

I am learning the Blazor technology. I started a default increment project in VS 2019 and I have modified the code for Decrement with confirm() and alert but it does not work. @page "/counter"

Counter

Current count:…

Prasanna Kumar J
  • 1,288
  • 3
  • 17
  • 35
40
votes
1 answer

How to compile Java to WASM (WebAssembly)?

I wonder can I use Java and compile it to WASM (WebAssembly)? The list https://webassembly.org/getting-started/developers-guide/ has no Java, Kotlin GraalVM WASM project https://www.graalvm.org/reference-manual/wasm/ is for running wasm inside JVM,…
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
39
votes
1 answer

How do I use a C library in a Rust library compiled to WebAssembly?

I'm experimenting with Rust, WebAssembly and C interoperability to eventually use the Rust (with static C dependency) library in the browser or Node.js. I'm using wasm-bindgen for the JavaScript glue code. #![feature(libc, use_extern_macros)] extern…
olanod
  • 30,306
  • 7
  • 46
  • 75
36
votes
3 answers

How can I check if a browser supports WebAssembly?

With support for WebAssembly coming into all new major browsers, how can I check whether the current browser which is visiting my website supports it?
Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
34
votes
4 answers

TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'

I'm trying to load a .wasm file using the fetch api on Chrome , and serving a html file using express. But chrome does not let me load the file: 'Uncaught (in promise) TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME…
Ricardo Machado
  • 787
  • 1
  • 8
  • 16
1
2 3
99 100