AsssemblyScript, C, C++ Go, Javy, Rust, Zig, Warpo, and QuickJS (compiled to WASM running JavaScript source code) Native Messaging hosts.
Fastest to slowest in Debian 13 live session run from Chromium Version 149.0.7800.0 (Developer Build) (64-bit).
WASI imports in WAT representation from jco print nm_*.wasm > nm_*.wat wind up different for each
input language.
Before building, if you are not using Chromium browser, rather Chrome, check ~/.config and see what the name of Chrome configuration folder is; it should be named something like google-chrome-stable or google-chrome, and adjust that line accordinging in install_host.js. bun is used to install AssemblyScript and AssemblyScript's wasi-shim.
git clone https://github.com/guest271314/native-messaging-webassembly
cd native-messaging-webassembly
node install_hosts.jsIf everything goes as expected the respective nm_* files should be compiled to WASM with optimizations per the specific compiler, and WASI support. The Native Messaging host manifests will be written to ~/.config/<chromium|googlechrome*>/NativeMessagingHosts, and the URL to navigate to in the browser should be printed to terminal. Launch with chrome --load-extension=/path/to/native-messaging-webassembly (where you just cloned the repository), and navigate to the URL printed. Open DevTools and observe results of which WASM file was executed fastest by wasmtime, the base case.
There is a Bytecode Alliance Javy specific file, nm_javy_node_wasi.js that uses Node.js node:wasi module to run the same nm_javy.wasm using WebAssembly JavaScript API.
There is also a generic nm_node_wasi.js that can be run with any of the WASM files compiled by install_hosts.js, e.g.,
node nm_node_wasi.js ./nm_tinygo_wasi.jsThere's a generic, minimal WAPI P1 implementation, too, nm_wasip1_min.js that can be run as such, after marking the file as executable, to test different JavaScript runtimes' execution (adjust shebang line accordingly)
./nm_wasip1_min.js ./nm_warpo.wasmAdditionally, there is a standalone test that uses deno to test Native Messaging hosts outside out the browser, that can be run as such
deno -A ./nm_standalone_test.js ./nm_node_wasi.js ./nm_c_wasi.wasmor
deno -A ./nm_standalone_test.js ./nm_rust_wasi.shTo test with a runtime other than wasmtime, the default WebAssembly runtime, rebuild with, for example, passing bun to the script
node install_hosts.js --runtime=bunOn Debian 13 lve my results for 100 runs of each WASM file is this running test_wasi.js in the unpacked extension
0 'nm_assemblyscript' 0.1976559999999405
1 'nm_zig_wasi' 0.19885799999967216
2 'nm_c_wasi' 0.2042730000005662
3 'nm_rust_wasi' 0.22548400000005958
4 'nm_warpo' 0.2342590000006556
5 'nm_tinygo_wasi' 0.2594749999994041
6 'nm_qjs_wasi' 0.27996299999997015
7 'nm_cpp_wasi' 0.3086060000002384
8 'nm_javy' 0.3109239999997616
9 'nm_go_wasi'
I'm curious to see what results you get on your machine.