Hacker News new | past | comments | ask | show | jobs | submit | puohufgh's comments login

Quick question about Wasmer and C programming: can I use Wasmer to compile a simple Hello World C program only once and then run this program on all supported architectures like I can use Cordova with Javascript to do the same?

Quickly exploring the wasmer-c-api examples just now[1], this does not appear to be the case: I get the impression one must write a bunch of high-friction boilerplate code to load/unload/configure/run wasm in order to do a simple hello world program. I have recently converted from being a C programmer to a Javascript programmer because I just can't deal with complicated C build systems and cross-compiling anymore: CMake, Gradle, etc. I spend more time trying to get a dependency to compile and learning the CMake language than I do actually solving my problem. People say "Electron is cancer" but at least I can get Cordova quickly working to ship an app for Windows/Mac/Linux/Android/iOS. I'd love to go back to lightweight, fast C programs though if I had the option. I tried using SDL2 but many of the examples will run fine on one platform but then fail to run on a different platform (say iOS or Android) and as a lone indie dev I don't have the time to investigate such issues. (I tried and managed to fix a few broken builds, but grew frustrated and gave up.) Cordova with Javascript so far is the only thing I've tried that just works for universal cross-platform dev.

[1] https://github.com/wasmerio/wasmer-c-api


The easiest way to compile C code to WebAssembly is by using Zig (https://ziglang.org): zig cc -target=wasm32-wasi and you’re done. Nothing else to install. It is equally easy to cross-compile to another platform, against without installing anything else.


Thanks! I see that Zig is much more than just a programming language then; it has its own C compiler that addresses much of the toil of cross compiling C code.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: