wasmerio/wasmer-ruby

[More Examples] Could more examples be added?

rubyFeedback opened this issue · 1 comments

Could more examples be added?

Ideally something like a slow build-up step that showcases what can be done with it.

I'd also love some example where we could add functionality to a simple sinatra
application or something like that.

Right now I am a bit clueless what we can do with wasmer. Even opal makes this
more clear than wasmer.

I think this is hard because Wasmer can do exactly what it says on the tin: it is a Wasm runtime, and that means you can do stuff like: import/export functions and memory, do basic pointer math to access strings in the memory if you have well-made functions that allow you to do that... call a function that accepts a fixed number of typed values. Execute a Wasi program.

Access a compiler! Run the compiler when you want, either just-in-time or way ahead of time. Those are all the basic features of wasmer. If we're not sure why we needed a compiler, it's going to be tricky coming up with uses for wasmer. I'd like to say that Wasm (and wasmer) have tricked me into using a compiler, I never wrote a Rust program before today, and now I'm parsing HTML in Rust, and reading files from disk, and building Cargo crates as command-line and library types.

I had some wrong ideas about how this was going to be useful to me as a Rubyist going in. I'm still not sure I've got the right idea, but I think after doing this exploration I can definitely say that I now have a much better idea of what it's not.

There's also a legitimate argument to be made, maybe, that of the languages that Wasm supports interoperability with, we probably picked the worst. I think a good example would be "how to run ruby.wasm and execute a ruby script from wasmer-ruby, in a Ruby host" because frankly that's one I couldn't get working on my own after struggling a while (invalid integer return / something not sure what the error was when fetching the Wasi version maybe I compiled it wrong)

This would give a great opportunity to talk about "where no progress is possible" – why would anyone do this? There might be some good reasons, but I'll bet you can cross performance off the list if you're running Ruby as a wasm inside of Ruby, cause no matter what you do your ruby has to be interpreted, so it's going to be slower than an actually compiled language.