├── .editorconfig ├── .gitignore ├── C# ├── README.md ├── Vagrantfile ├── hello.cs └── scripts ├── C++ ├── README.md ├── Vagrantfile ├── hello.cpp └── scripts ├── C ├── README.md ├── Vagrantfile ├── hello.c └── scripts ├── CONTRIBUTING.md ├── Crystal ├── README.md ├── Vagrantfile ├── hello.cr └── scripts ├── D ├── README.md ├── Vagrantfile ├── hello.d └── scripts ├── F# ├── README.md ├── Vagrantfile ├── hello.fs └── scripts ├── Go ├── README.md ├── Vagrantfile ├── hello.go └── scripts ├── Haskell ├── README.md ├── Vagrantfile ├── hello.hs └── scripts ├── Java ├── Hello.java ├── README.md ├── Vagrantfile ├── pom.xml └── scripts ├── Julia ├── README.md ├── Vagrantfile ├── hello.jl └── scripts ├── Kotlin ├── README.md ├── Vagrantfile ├── hello.kt └── scripts ├── LICENSE ├── Nim ├── README.md ├── Vagrantfile ├── hello.nim ├── nim.cfg └── scripts ├── Python ├── README.md ├── Vagrantfile ├── hello.py └── scripts ├── README.md ├── Rust ├── README.md ├── Vagrantfile ├── hello.rs └── scripts ├── Scala ├── Vagrantfile ├── hello.scala └── scripts ├── Swift ├── README.md ├── Vagrantfile ├── hello.swift └── scripts ├── TypeScript ├── Vagrantfile ├── hello.ts └── scripts ├── compile-to-web-inkscape.svg └── compile-to-web.png /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node,vagrant 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # nyc test coverage 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # Bower dependency directory (https://bower.io/) 31 | bower_components 32 | 33 | # node-waf configuration 34 | .lock-wscript 35 | 36 | # Compiled binary addons (http://nodejs.org/api/addons.html) 37 | build/Release 38 | 39 | # Dependency directories 40 | node_modules/ 41 | jspm_packages/ 42 | 43 | # Typescript v1 declaration files 44 | typings/ 45 | 46 | # Optional npm cache directory 47 | .npm 48 | 49 | # Optional eslint cache 50 | .eslintcache 51 | 52 | # Optional REPL history 53 | .node_repl_history 54 | 55 | # Output of 'npm pack' 56 | *.tgz 57 | 58 | # Yarn Integrity file 59 | .yarn-integrity 60 | 61 | # Yarn Lock file 62 | yarn.lock 63 | 64 | # package.json Lock file 65 | package-lock.json 66 | 67 | # dotenv environment variables file 68 | .env 69 | 70 | 71 | ### Vagrant ### 72 | .vagrant/ 73 | 74 | # End of https://www.gitignore.io/api/node,vagrant 75 | -------------------------------------------------------------------------------- /C#/README.md: -------------------------------------------------------------------------------- 1 | # C# Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling C# to WASM is supported through the [Mono Compiler](http://www.mono-project.com). 10 | 11 | The [Mono Compiler news page includes an overview of the current support](http://www.mono-project.com/news/2017/08/09/hello-webassembly/). 12 | -------------------------------------------------------------------------------- /C#/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.cs", destination: "hello.cs" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /C#/hello.cs: -------------------------------------------------------------------------------- 1 | public class Hello 2 | { 3 | public static void Main() 4 | { 5 | System.Console.WriteLine("Hello, World!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /C#/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | # install llvm build dependencies 5 | sudo apt update 6 | sudo apt install -y git subversion cmake gcc g++ python 7 | 8 | # build custom wasm llvm 9 | mkdir -p src/mono-wasm 10 | cd ~/src/mono-wasm 11 | git clone https://github.com/lrz/mono-wasm build 12 | svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 13 | cd llvm/tools 14 | svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 15 | cd ../.. 16 | mkdir llvm-build 17 | cmake -G "Unix Makefiles" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../llvm 18 | make 19 | 20 | # build binaryen 21 | cd ~/src/mono-wasm 22 | git clone https://github.com/WebAssembly/binaryen 23 | cd binaryen 24 | cmake . 25 | make 26 | 27 | # build custom mono llvm 28 | cd ~/src/mono-wasm 29 | clone https://github.com/mono/llvm llvm-mono 30 | mkdir llvm-mono-build 31 | cd llvm-mono-build 32 | cmake -G "Unix Makefiles" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" ../llvm-mono 33 | ditto ../llvm-mono/include include 34 | make 35 | 36 | # build mono compiler 37 | cd ~/src/mono-wasm 38 | git clone git@github.com:lrz/mono-wasm-mono.git mono-compiler 39 | cd mono-compiler 40 | ./autogen.sh --host=i386-darwin --with-cross-offsets=offsets-wasm32.h CFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" CXXFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" --disable-boehm --with-sigaltstack=no --enable-llvm --enable-llvm-runtime --with-llvm=../llvm-mono-build --disable-btls --with-runtime_preset=testing_aot_full 41 | make 42 | 43 | # prepare mono runtime 44 | cd ~/src/mono-wasm 45 | git clone git@github.com:lrz/mono-wasm-mono.git mono-runtime 46 | cd mono-runtime 47 | cp config-wasm32.h config.h 48 | cp eglib/src/eglib-config-wasm32.h eglib/src/eglib-config.h 49 | 50 | # c lib 51 | cd ~/src/mono-wasm 52 | git clone git@github.com:lrz/mono-wasm-libc.git libc 53 | 54 | # build dist folder 55 | cd ~/src/mono-wasm/build 56 | make 57 | 58 | # build hello world 59 | cd sample/hello 60 | make 61 | } 62 | 63 | function build () { 64 | echo 'No build has been added yet, feel free to open a pull request' 65 | } 66 | -------------------------------------------------------------------------------- /C++/README.md: -------------------------------------------------------------------------------- 1 | # C++ Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling C++ to WASM is supported through the [Emscripten](https://kripken.github.io/emscripten-site/) version of [Clang++](https://clang.llvm.org). 10 | 11 | The [Emscripten wiki includes a walkthrough of the process](https://github.com/kripken/emscripten/wiki/WebAssembly). 12 | -------------------------------------------------------------------------------- /C++/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.cpp", destination: "hello.cpp" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /C++/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout << "Hello World!"; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /C++/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | apt-get update 5 | # install emscripten prerequisits 6 | sudo apt-get install -y build-essential cmake python nodejs git-core 7 | 8 | # install emscripten sdk manager 9 | wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz 10 | tar -zxvf emsdk-portable.tar.gz 11 | echo 'export PATH="$PATH:/home/ubuntu/emsdk-portable"' >> /home/ubuntu/.bashrc 12 | 13 | # ensure emscripten sdk manager is in environment 14 | source .bashrc 15 | 16 | # install emscripten 17 | emsdk update 18 | emsdk install sdk-incoming-64bit 19 | emsdk activate sdk-incoming-64bit 20 | } 21 | 22 | function build () { 23 | emcc hello.cpp 24 | } 25 | -------------------------------------------------------------------------------- /C/README.md: -------------------------------------------------------------------------------- 1 | # C Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling C to WASM is supported through the [Emscripten](https://kripken.github.io/emscripten-site/) version of [Clang](https://clang.llvm.org). 10 | 11 | The [Emscripten wiki includes a walkthrough of the process](https://github.com/kripken/emscripten/wiki/WebAssembly). 12 | -------------------------------------------------------------------------------- /C/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.c", destination: "hello.c" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /C/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | printf("Hello World"); 6 | } 7 | -------------------------------------------------------------------------------- /C/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | apt-get update 5 | # install emscripten prerequisits 6 | sudo apt-get install -y build-essential cmake python nodejs git-core 7 | 8 | # install emscripten sdk manager 9 | wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz 10 | tar -zxvf emsdk-portable.tar.gz 11 | echo 'export PATH="$PATH:/home/ubuntu/emsdk-portable"' >> /home/ubuntu/.bashrc 12 | 13 | # ensure emscripten sdk manager is in environment 14 | source .bashrc 15 | 16 | # install emscripten 17 | emsdk update 18 | emsdk install sdk-incoming-64bit 19 | emsdk activate sdk-incoming-64bit 20 | } 21 | 22 | function build () { 23 | emcc hello.c 24 | } 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Requesting a new language 4 | 5 | 1. [Open an issue on GitHub](https://github.com/ChristianMurphy/compile-to-web/issues/new) 6 | 2. Include the name of the language in the issue title 7 | 3. Include links to any resources you may have found on how to compile that language to WASM 8 | 4. Consider opening a [Pull Request](https://github.com/Roshanjossey/first-contributions#readme) adding the language (See "Adding a new language" below) 9 | 5. Thats all! Thanks for contributing! :bow: 10 | 11 | ## Reporting a bug 12 | 13 | 1. [Open an issue on GitHub](https://github.com/ChristianMurphy/compile-to-web/issues/new) 14 | 2. Include the name of the language in the issue title 15 | 3. Include any logs or stacktraces in a [Markdown fenced block](https://help.github.com/articles/creating-and-highlighting-code-blocks/) 16 | 4. Consider opening a [Pull Request](https://github.com/Roshanjossey/first-contributions#readme) resolving the issue. 17 | 5. Thats all! Thanks for contributing! :bow: 18 | 19 | ## Adding a new language 20 | 21 | 1. First time opening a Pull Request? [Checkout this Pull Request guide!](https://github.com/Roshanjossey/first-contributions#readme) 22 | 2. Add a new folder for the language with the following files: 23 | * `hello.{language extension}` for example `hello.go` for Go lang 24 | * `Vagrantfile` 25 | * `scripts` 26 | 3. Commit changes 27 | 4. Add `install` and `build` steps to `scripts` 28 | 5. Commit changes 29 | 6. Open a Pull Request 30 | 7. Review and updates to Pull Request 31 | 8. PR merged 32 | 9. Thats all! Thanks for Contributing! :bow: 33 | -------------------------------------------------------------------------------- /Crystal/README.md: -------------------------------------------------------------------------------- 1 | # Crystal Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :no_entry: Not Yet 6 | 7 | ## Compiler Support 8 | 9 | There is [ongoing discussion on Crystal support](https://github.com/crystal-lang/crystal/issues/829). 10 | -------------------------------------------------------------------------------- /Crystal/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.cr", destination: "hello.cr" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Crystal/hello.cr: -------------------------------------------------------------------------------- 1 | puts "Hello world!" 2 | -------------------------------------------------------------------------------- /Crystal/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /D/README.md: -------------------------------------------------------------------------------- 1 | # D Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling F# to WASM is supported through [LDC](https://wiki.dlang.org/LDC). 10 | 11 | https://wiki.dlang.org/Generating_WebAssembly_with_LDC 12 | -------------------------------------------------------------------------------- /D/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.d", destination: "hello.d" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /D/hello.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | 3 | void main() { 4 | writeln("Hello World!"); 5 | } 6 | -------------------------------------------------------------------------------- /D/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /F#/README.md: -------------------------------------------------------------------------------- 1 | # F# Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling F# to WASM is supported through the [Mono Compiler](http://www.mono-project.com). 10 | 11 | The [Mono Compiler news page includes an overview of the current support](http://www.mono-project.com/news/2017/08/09/hello-webassembly/). 12 | -------------------------------------------------------------------------------- /F#/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.fs", destination: "hello.fs" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /F#/hello.fs: -------------------------------------------------------------------------------- 1 | open System 2 | 3 | [] 4 | let main argv = 5 | printfn "Hello World" 6 | Console.ReadLine() |> ignore 7 | 0 8 | -------------------------------------------------------------------------------- /F#/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Go/README.md: -------------------------------------------------------------------------------- 1 | # Go Language Web Assembly Support 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling Go to WASM is supported through the `GOARCH=wasm GOOS=js` compiler options. 10 | See https://blog.owulveryck.info/2018/06/08/some-notes-about-the-upcoming-webassembly-support-in-go.html 11 | -------------------------------------------------------------------------------- /Go/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.go", destination: "hello.go" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Go/hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("hello world") 7 | } 8 | -------------------------------------------------------------------------------- /Go/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Haskell/README.md: -------------------------------------------------------------------------------- 1 | # Haskell 2 | 3 | ## Supported 4 | 5 | :no_entry: Not Yet 6 | 7 | ## Compiler Support 8 | 9 | Two independent efforts are working to add WASM support for Haskell: [asterius](https://github.com/tweag/asterius) and [haskell-wasm](https://github.com/haskell-wasm/wasm) 10 | -------------------------------------------------------------------------------- /Haskell/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "shell", inline: <<-SHELL 8 | apt-get update 9 | apt-get install -y make 10 | SHELL 11 | 12 | config.vm.provision "file", source: "scripts", destination: "scripts" 13 | config.vm.provision "file", source: "hello.hs", destination: "hello.hs" 14 | end 15 | -------------------------------------------------------------------------------- /Haskell/hello.hs: -------------------------------------------------------------------------------- 1 | main = putStrLn "hello world" 2 | -------------------------------------------------------------------------------- /Haskell/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Java/Hello.java: -------------------------------------------------------------------------------- 1 | package org.teavm.samples; 2 | 3 | class Hello { 4 | public static void main (String[] args) { 5 | System.out.println("Hello World"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Java/README.md: -------------------------------------------------------------------------------- 1 | # Java 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling Java to WASM is supported through the [Tea VM](http://teavm.org/). 10 | -------------------------------------------------------------------------------- /Java/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.java", destination: "hello.java" 9 | config.vm.provision "file", source: "pom.xml", destination: "pom.xml" 10 | 11 | config.vm.provision "shell", inline: <<-SHELL 12 | echo 'source ~/scripts' >> .bashrc 13 | SHELL 14 | 15 | # OPTIONAL: increase ram and cpus to speed up builds 16 | config.vm.provider "virtualbox" do |v| 17 | v.memory = 4096 18 | v.cpus = 2 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /Java/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | org.example.teamjava 7 | my-app 8 | jar 9 | 1.0-SNAPSHOT 10 | Compile to web assembly 11 | http://maven.apache.org 12 | 13 | 14 | 15 | org.teavm 16 | teavm-maven-plugin 17 | 0.5.1 18 | 19 | 20 | 21 | org.teavm 22 | teavm-classlib 23 | 0.5.1 24 | 25 | 26 | 27 | 28 | 29 | compile 30 | 31 | process-classes 32 | 33 | org.teavm.samples.Hello 34 | true 35 | true 36 | true 37 | WEBASSEMBLY 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Java/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | apt install maven 5 | apt install openjdk-8-jdk 6 | } 7 | 8 | function build () { 9 | mvn install 10 | } 11 | -------------------------------------------------------------------------------- /Julia/README.md: -------------------------------------------------------------------------------- 1 | # Julia Language Support 2 | 3 | ## Supported 4 | 5 | :no_entry: Not Yet 6 | 7 | ## Compiler Support 8 | 9 | A Julia to WASM compiler is in progress at https://github.com/amellnik/Julia-to-JS 10 | -------------------------------------------------------------------------------- /Julia/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.rs", destination: "hello.rs" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Julia/hello.jl: -------------------------------------------------------------------------------- 1 | println("hello world") 2 | -------------------------------------------------------------------------------- /Julia/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Kotlin/README.md: -------------------------------------------------------------------------------- 1 | # Kotlin 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling Kotlin to WASM is supported through the [Kotlin Native](https://github.com/JetBrains/kotlin-native/). 10 | -------------------------------------------------------------------------------- /Kotlin/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.kt", destination: "hello.kt" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Kotlin/hello.kt: -------------------------------------------------------------------------------- 1 | fun main(args: Array) { 2 | println("Hello, world!") 3 | } 4 | -------------------------------------------------------------------------------- /Kotlin/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | wget https://github.com/JetBrains/kotlin-native/releases/download/v0.5/kotlin-native-linux-0.5.tar.gz 5 | tar -zxvf kotlin-native-linux-0.5.tar.gz 6 | } 7 | 8 | function build () { 9 | ./kotlin-native-linux-0.5/bin/konanc hello.kt -target wasm32 10 | } 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2019 Christian Murphy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Nim/README.md: -------------------------------------------------------------------------------- 1 | # Nim 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Nim requires a custom _nim.cfg_ file 10 | 11 | ``` 12 | @if emscripten: 13 | cc = clang 14 | clang.exe = "emcc" 15 | clang.linkerexe = "emcc" 16 | clang.options.linker = "" 17 | cpu = "i386" 18 | passC = "-s WASM=1 -s 'BINARYEN_METHOD=\"native-wasm\"' -Iemscripten" 19 | passL = "-s WASM=1 -Lemscripten -s TOTAL_MEMORY=335544320" 20 | # use ALLOW_MEMORY_GROWTH=1 instead of TOTAL_MEMORY if performance isn't top priority 21 | @end 22 | ``` 23 | 24 | Then a custom build command 25 | 26 | ``` 27 | nim c -d:useRealtimeGC -d:release -d:emscripten --out=index.html hello.nim 28 | ``` 29 | 30 | See https://forum.nim-lang.org/t/2838 31 | -------------------------------------------------------------------------------- /Nim/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.nim", destination: "hello.nim" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Nim/hello.nim: -------------------------------------------------------------------------------- 1 | echo "Hello World" 2 | -------------------------------------------------------------------------------- /Nim/nim.cfg: -------------------------------------------------------------------------------- 1 | @if emscripten: 2 | cc = clang 3 | clang.exe = "emcc" 4 | clang.linkerexe = "emcc" 5 | clang.options.linker = "" 6 | cpu = "i386" 7 | passC = "-s WASM=1 -s 'BINARYEN_METHOD=\"native-wasm\"' -Iemscripten" 8 | passL = "-s WASM=1 -Lemscripten -s TOTAL_MEMORY=335544320" 9 | # use ALLOW_MEMORY_GROWTH=1 instead of TOTAL_MEMORY if performance isn't top priority 10 | @end 11 | -------------------------------------------------------------------------------- /Nim/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Python/README.md: -------------------------------------------------------------------------------- 1 | # Python 2 | 3 | ## Supported 4 | 5 | :no_entry: Not Yet 6 | 7 | ## Compiler Support 8 | 9 | There is ongoing discussion about WASM support at [PyPy.js issue 145](https://github.com/pypyjs/pypyjs/issues/145). 10 | -------------------------------------------------------------------------------- /Python/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.py", destination: "hello.py" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Python/hello.py: -------------------------------------------------------------------------------- 1 | print("hello world") 2 | -------------------------------------------------------------------------------- /Python/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![Compile to Web](compile-to-web.png) 2 | 3 | Discover what languages can be compiled into [Web Assembly (WASM)](http://webassembly.org) 4 | 5 | ## Languages 6 | 7 | | Language | Compiles to LLVM | Compiles to WASM | 8 | | ------------------------- | :---------------------: | :---------------------: | 9 | | [C](C/) | :ballot_box_with_check: | :ballot_box_with_check: | 10 | | [C#](C%23/) | :ballot_box_with_check: | :ballot_box_with_check: | 11 | | [C++](C++/) | :ballot_box_with_check: | :ballot_box_with_check: | 12 | | [Crystal](Crystal/) | :ballot_box_with_check: | :grey_question: | 13 | | [D](D/) | :ballot_box_with_check: | :ballot_box_with_check: | 14 | | [F#](F%23/) | :ballot_box_with_check: | :ballot_box_with_check: | 15 | | [Go](Go/) | :ballot_box_with_check: | :ballot_box_with_check: | 16 | | [Haskell](Haskell/) | :grey_question: | :grey_question: | 17 | | [Java](Java/) | :ballot_box_with_check: | :ballot_box_with_check: | 18 | | [Julia](Julia/) | :ballot_box_with_check: | :grey_question: | 19 | | [Kotlin](Kotlin/) | :ballot_box_with_check: | :ballot_box_with_check: | 20 | | [Nim](Nim/) | :ballot_box_with_check: | :ballot_box_with_check: | 21 | | [Python](Python/) | :grey_question: | :grey_question: | 22 | | [Rust](Rust/) | :ballot_box_with_check: | :ballot_box_with_check: | 23 | | [Scala](Scala/) | :ballot_box_with_check: | :no_entry: | 24 | | [Swift](Swift/) | :ballot_box_with_check: | :no_entry: | 25 | | [TypeScript](TypeScript/) | :grey_question: | :grey_question: | 26 | 27 | ### Key 28 | 29 | | Icon | Meaning | 30 | | :---------------------: | ------- | 31 | | :ballot_box_with_check: | Success | 32 | | :no_entry: | Broken | 33 | | :grey_question: | Unknown | 34 | 35 | ## Installation 36 | 37 | 1. Install [Vagrant](https://www.vagrantup.com/downloads.html) 38 | 2. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 39 | 3. For a desired language `cd` into the folder, then run 40 | 41 | ```sh 42 | vagrant up 43 | vagrant ssh 44 | sudo su - 45 | install 46 | build 47 | ``` 48 | 49 | ## Contributing 50 | 51 | Interested in seeing a new language? Found a bug in the examples? 52 | Check out the [Contributing Guide](CONTRIBUTING.md) for how to get involved! 53 | 54 | ## FAQ 55 | 56 | **Question**: Why is "Compile to LLVM" listed? 57 | 58 | **Answer**: [LLVM](https://llvm.org/) was an [influence for WebAssembly technology](http://webassembly.org/docs/faq/#why-not-just-use-llvm-bitcode-as-a-binary-format) and [was the first compiler infastructure with official WASM support](http://webassembly.org/docs/faq#which-compilers-can-i-use-to-build-webassembly-programs). 59 | -------------------------------------------------------------------------------- /Rust/README.md: -------------------------------------------------------------------------------- 1 | # Rust 2 | 3 | ## Supported 4 | 5 | :ballot_box_with_check: Yes 6 | 7 | ## Compiler Support 8 | 9 | Compiling Rust to WASM is supported through the [Rust WASM target](https://www.hellorust.com/setup/wasm-target/). 10 | -------------------------------------------------------------------------------- /Rust/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.rs", destination: "hello.rs" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Rust/hello.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello World!"); 3 | } 4 | -------------------------------------------------------------------------------- /Rust/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | apt-get update 5 | # install emscripten prerequisits 6 | sudo apt-get install -y build-essential cmake python nodejs git-core 7 | 8 | # install emscripten sdk manager 9 | wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz 10 | tar -zxvf emsdk-portable.tar.gz 11 | echo 'export PATH="$PATH:/home/ubuntu/emsdk-portable"' >> /home/ubuntu/.bashrc 12 | 13 | # install rustup, rust version manager 14 | curl https://sh.rustup.rs -sSf | sh -s -- -y 15 | 16 | # ensure emscripten and rustup are in environment 17 | source .bashrc 18 | 19 | # install emscripten 20 | emsdk update 21 | emsdk install sdk-incoming-64bit 22 | emsdk activate sdk-incoming-64bit 23 | 24 | # install rust wasm target 25 | rustup target add wasm32-unknown-emscripten 26 | } 27 | 28 | function build () { 29 | rustc --target=wasm32-unknown-emscripten hello.rs -o hello.html 30 | } 31 | -------------------------------------------------------------------------------- /Scala/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.scala", destination: "hello.scala" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Scala/hello.scala: -------------------------------------------------------------------------------- 1 | object HelloWorld { 2 | def main(args: Array[String]): Unit = { 3 | println("Hello, world!") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Scala/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /Swift/README.md: -------------------------------------------------------------------------------- 1 | # Swift Language WebAssembly Support 2 | 3 | ## Supported 4 | 5 | :no_entry: Not Yet 6 | 7 | ## Compiler Support 8 | 9 | [Swift is built with an LLVM compiler tool chain](https://github.com/apple/swift-llvm), which opens some opportunities to for it to work with [EMScripten](https://kripken.github.io/emscripten-site/). 10 | 11 | There is [ongoing discussion on Swift support in the EMScripten Community](https://github.com/kripken/emscripten/issues/2427). 12 | -------------------------------------------------------------------------------- /Swift/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.swift", destination: "hello.swift" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Swift/hello.swift: -------------------------------------------------------------------------------- 1 | print("hello world") 2 | -------------------------------------------------------------------------------- /Swift/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /TypeScript/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "ubuntu/xenial64" 6 | 7 | config.vm.provision "file", source: "scripts", destination: "scripts" 8 | config.vm.provision "file", source: "hello.ts", destination: "hello.ts" 9 | 10 | config.vm.provision "shell", inline: <<-SHELL 11 | echo 'source ~/scripts' >> .bashrc 12 | SHELL 13 | 14 | # OPTIONAL: increase ram and cpus to speed up builds 15 | config.vm.provider "virtualbox" do |v| 16 | v.memory = 4096 17 | v.cpus = 2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /TypeScript/hello.ts: -------------------------------------------------------------------------------- 1 | console.log('hello world'); 2 | -------------------------------------------------------------------------------- /TypeScript/scripts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function install () { 4 | echo 'No install has been added yet, feel free to open a pull request' 5 | } 6 | 7 | function build () { 8 | echo 'No build has been added yet, feel free to open a pull request' 9 | } 10 | -------------------------------------------------------------------------------- /compile-to-web-inkscape.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xmlWeb 78 | compile to 88 | -------------------------------------------------------------------------------- /compile-to-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChristianMurphy/compile-to-web/a7e365d51309bf6a10cf1c3ef3223bace8166b95/compile-to-web.png --------------------------------------------------------------------------------