Hacker News new | ask | show | jobs
by luismedel 962 days ago
I still have to try wasm, but I see the main focus seems to be on cloud and edge deployments.

What I'd really like would be to program a game in C (or classic Turbo Pascal) and have a way to run it "hosted" in a iOS, Android or <whatever platform> native app. Is that possible nowadays?

7 comments

You can compile the game to wasm and run it in a web environment. That can be a wrapper around a system webview, so you don't need to actually bundle a web engine in your app.

The web environment would provide all the API support for your game: graphics, audio, networking, etc. in a cross platform way.

This works today - many game engines compile to wasm, from Unity to Godot - but it is more popular to ship a native build of the engine on each platform rather than use a web environment. But that's because those engines take the time to port to each of those platforms; instead, you can use wasm + the web to get portability in a much simpler way (but with some limitations, of course).

I ported Neverball, a game written in C, to WASM (https://play.neverball.org/). It requires a browser to run, meaning it runs on any device that has a browser. That is superior to native in my eyes.
Someone would need to implement a library to abstract away the differences between all of these platforms, like Spin does for server software.

I'm not aware of a tech stack that does that.

I also replied to OP, but SDL is popular for this.

https://www.libsdl.org/

WASIX might come in handy for that!

https://wasix.org

Appreciate your hustle! ABC
Not WASM-related, but just a few days ago we had a Cosmopolitan libc announcement on HN. https://news.ycombinator.com/item?id=38101613

This promises a single C code base and portable executable generation for

  Linux
  MacOS
  Windows
  FreeBSD
  OpenBSD
  NetBSD
You could write it using SDL2, a popular C library. They say the support iOS and Android: https://wiki.libsdl.org/SDL2/Installation
you may want to take a look at https://github.com/extism/extism