Chrome and Firefox support WebAssembly to make fast applications on the web!
You can write your web application in C language also!
This is simple demo using shared memory on both JavaScript and WebAssembly.

"WebAssembly test" (src on GitHub)

To set up WebAssembly to your Mac (taking 2 hours and 20GB storage space!!)

1. binaryen (compiler for WebAssembly)

cd *** git clone https://github.com/WebAssembly/binaryen.git cd binaryen cmake . && make

*** : your bin path
2. wabt (assembler for WebAssembly)

git clone --recursive https://github.com/WebAssembly/wabt cd wabt make cd ..

3. LLVM (takes long time and big storage space!)

git clone http://llvm.org/git/llvm.git cd llvm/tools git clone http://llvm.org/git/clang.git cd ../projects git clone http://llvm.org/git/compiler-rt cd ../.. mkdir llvmtmp cd llvmtmp cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly ../llvm make -j 8 sudo make install

4. edit PATH (.profile etc...)

export PATH=***/wabt/out/clang/Debug/:***/binaryen/bin/:$PATH

5. done! Let's make web an app in C!

#define SIZE 10 int mem[SIZE]; int* getMemory() { return mem; } int getMemorySize() { return SIZE; } int calc() { int sum = 0; for (int i = 0; i < SIZE; i++) { sum += mem[i]; } return sum; }

"WebAssembly test on GitHub"

本ブログの記事や写真は「Creative Commons — CC BY 4.0」の下に提供します。記事内で紹介するプログラムや作品は、それぞれに記載されたライセンスを参照ください。
CC BY / @taisukef / アイコン画像 / プロフィール画像 / 「一日一創」画像 / RSS