Webassembly in chrome

Demo: http://webassembly.org/demo/AngryBots/

http://www.androidpolice.com/2017/01/24/webassembly-enabled-default-chrome-58-gives-web-apps-processing-power/

EXAMPLES
https://mdn.github.io/webassembly-examples/js-api-examples/

Let’s write “Hello World”

SAMPLE CODE: https://github.com/tkhemani/webAssembly-sample

First set it up: http://webassembly.org/getting-started/developers-guide/:

  • Add CMake to PATH: ;C:\Program Files\CMake\bin\
  • INSTALL Emscripten from here: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html

Next COMPILE AND RUN IT:

$ mkdir hello
$ cd hello
$ echo '#include ' > hello.c
$ echo 'int main(int argc, char ** argv) {' >> hello.c
$ echo 'printf("Hello, world!\n");' >> hello.c
$ echo '}' >> hello.c
$ emcc hello.c -s WASM=1 -o hello.html

To serve the compiled files over HTTP, we can use the emrun web server provided with the Emscripten SDK:

$ emrun --no_browser --port 8080 .

Once the HTTP server is running, you can open it in your browser. If you see “Hello, world!” printed to the Emscripten console, then congratulations! You’ve successfully compiled to WebAssembly!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s