4 ms·
One notable thing is the ruby apps in a single .wasm file. This may make ruby CLI apps easier, as well as eventually replacing things like docker or shipping yo
by swlkr 5y ago
One notable thing is the ruby apps in a single .wasm file. This may make ruby CLI apps easier, as well as eventually replacing things like docker or shipping your ruby code to a server.
- cpuguy83 5y agoYou don't just execute a .wasm file, it requires a runtime which will JIT compile the code into machine code and handle the (wasi) system interfaces (e.g. read, write, stat, etc).
- specialp 5y agoYes this is true with all interpreted languages. But if you consider the use-case the OP was contrasting with (Docker) that not only has the Ruby runtime, but an entire Linux OS as well.
- anamexis 5y agoWouldn't a more natural point of comparison be installing the ruby interpreter?
- zem 5y agono, because you also need to install all your dependencies
- anamexis 5y agoWell, vendor them and tar it up. You could make a ruby script in a few lines that would load the dependencies and then execute the app all as one file.
- regularfry 5y agoThat is... uh... not a few lines.
- deleted 5y ago[deleted]
- anamexis 5y agoI'm fairly confident you could write a ruby script that would untar a folder and then execute the entry point in 2-3 lines. Then the trick is just making this script and the tar binary be in one single, executable file. You could do this trivially by encoding the binary in base64, but I'm fairly sure there would be a way to have it as straight binary in well, in a way that the ruby interpreter wouldn't complain about.
- regularfry 5y agoYou're skipping the fun part. What's in that tarball? In order to gather the dependencies into the tarball in the first place, they need to be installed. And not all your dependencies are handled by `bundler`. In any interesting project you're going to be depending on system libraries that Rubygems has no way to signal to the OS that it needs. You need to `apt install <foo>` for interesting values of `foo`. That means you've got a few choices: either you document what those OS packages are and rely on the operator knowing that they need to pay attention, or you try to automagically install them when you unpack your tarball, or you include everything you need from the build system in the artefact. This means running the application and finding all the files it touches via `dlopen` and hoping you exercised all the interesting code paths. Option 1: you're back to installing dependencies. Option 2: you're wishing you'd just used `dpkg` to build yourself a .deb, and you're still installing dependencies. Option 3: now you need to figure out how to swap out OS libraries after the ruby interpreter has started, and need to get all the configuration right to point into your untarred filesystem, and you're wishing you'd just used Docker.
- anamexis 5y agoIf you're using native extensions or external dependencies, it's a moot point, because the Ruby WASM compiler doesn't support them either.
- FooBarWidget 5y agoIf you require a runtime then it's not better than JRuby with a jar.
- exdsq 5y agoWhy would it replace docker? You still need the dependencies of the CLI app Edit: Ah I guess it’s just the WASM vm if it includes everything
- qbasic_forever 5y agoI was thinking the same thing, isn't ruby particularly hard to package as it doesn't support static compilation? It would be nice to just sidestep all of that with a hermetic little WASM distribution.
- psychoslave 5y agoNot sure it covers what you expect, but there are tools out there to convert a ruby script into a single binary executable, like https://github.com/loureirorg/rb2exe https://github.com/loureirorg/rb2exe
- schemescape 5y agoIt looks like this embeds the Ruby runtime, a virtual file system for the files, and uses WASI to interact with the OS. The portability sounds great, but I’d like to see how performance is impacted. Edit: also curious about file size.