I relax by programming. It’s especially satisfying to play with something that changes how I think about a topic. I once discovered eget and realized that most modern software ships as a single binary attached to a GitHub release.

Recently my friend, David, had a further realization that what would make eget better is if it itself was easier to get (ha!). I thought it would be delightful to have a WASI eget cli to fetch native binaries. These days almost everything cross-compiles trivially to WASI command modules. Those are basically little unix cli apps that have a small footprint and can run anywhere (something Java never achieved).

But Current WASI is ‘mostly useless’?!?

But “WASI is useless” cos it doesn’t support networking. The whole point of eget is to do http calls to find binaries. \

This is where poor man’s resumable exceptions come in. I modified eget such that every time it wants to do an http download:

  1. Check the filesystem, maybe that HTTP call already has been cached on disk

  2. Abort with an error indicating HTTP call and filesystem location where it should get downloaded to

So eget js wrapper (see David’s post) just runs eget in a loop until eget has no more network calls to do: pull request. So there, I made something useful in the useless no-networking WASI version.

But isn’t this kinda dumb?

Could we just port eget to js using LLMs? Sort of, a lot of the code for fetching binaries involves various compression libs. JS likely doesn’t have non-ffi versions of some of those. It would require a lot more testing too.

Could we plumb through networking to wasm? No, the WASM ABI is stuck in the previous century (like all ABIs), so exposing fetch() to golang would be a lot of painful work and no fun at all.

Sometimes doing things the stupid way feels so good.

As a result of this bit of fun and David’s hard work we now have a portable way to download non-portable binaries =D