Hacker News new | ask | show | jobs
by kjksf 3283 days ago
It's like asking "is there JavaScript API to JavaScript".

WebAssembly is a portable instruction set, a simplified CPU.

The main use case for WebAssembly is compiling C/C++ code to that instruction set using emsscripten, which is a clang-based C/C++ compiler that emits WebAssembly modules.

Depending on how you look at it, the answer to "is there C API to assembly?" is:

a) yes, that's the first API there ever was and it's the main API

b) the question doesn't make sense. C/C++ is compiled to WebAssembly, there's no API to it. You could imagine a system that would allow using WebAssembly modules from native C/C++ code, where you would need a C/C++ bridge to executing WebAssembly functions (similar to JavaScript bridge for calling WebAssembly functions), but this is not really why WebAssembly exists

1 comments

b) is what I meant. I know that would not have been the original intention but I still think it can be useful in some cases, and there does not seem anything wrong with it. (It clearly wouldn't be for static linking WebAssembly codes with C codes, like what you might do with JavaScript, although it can have different uses.)