Hacker News new | ask | show | jobs
by kdma 2933 days ago
Nice video but (unrelated to the IDE) in order to use a printf from js it was necessary to: provide a js emulated syscall to c file that calls another c function that calls back to js again
1 comments

Yeah, it’s super weird when most people are expecting this to compile into JavaScript running in a browser. Nevertheless, to be fair, this isn’t a C, C++, or Rust to JavaScript compiler-compiler it’s a C, C++, or Rust compiler that targets WebAssembly. I realize this might read as overly pedantic but it explains why it makes sense to the implement the C interface. It’s also a reasonable optimization pass for a mature compiler when it knows that you’re targeting WebAssembly running in a browser.