1
0 Comments

Building Better Web Apps with Ruby on Rails and WebAssembly

Are you a Ruby on Rails (ROR) developer looking to expand your toolkit and take your web app development to the next level? Look no further than the new WebAssembly (WASM) integration in ROR 3.2. With this new update, ROR developers can now port their code to WebAssembly and run it on the frontend, on embedded devices, as serverless functions, and on the edge. This means that your ROR code can be run anywhere, making Ruby a truly universal language.

But what exactly is WebAssembly, and why should ROR developers care? WebAssembly is a binary low-level instruction format that runs on a virtual machine. It was designed as an alternative to JavaScript and is capable of running applications on any browser at near-native speeds. Wasm can be targeted from any high-level language, including C, Go, Rust, and now Ruby.

WebAssembly is portable and secure, meaning it can run on any modern browser, even mobile devices. For security, Wasm programs run in a sandboxed, memory-safe VM, preventing them from accessing any system resources like the file system, network, or memory.

With WebAssembly, portability is taken to the next level. Instead of building, testing, and distributing many images for different platforms, you can build one binary and run it in any modern browser. This allows you to save time and effort while also reducing the number of images and runtimes you need to manage. Wasm's ability to run code at native speed has allowed developers to build sites like Figma, Google Earth, and even run Vim in the browser.

Thanks to the new WASM integration in ROR 3.2, you can now run Ruby code directly in the browser without the need for a backend. It only takes a couple of lines of code to get started with the Ruby WASM port. After downloading ruby.wasm, you can instantiate the interpreter in the browser and feed the text of text/ruby type into the WebAssembly program. The best part? You can confirm that Ruby is running from the browser by opening the developers’ tools and observing that no further connections are needed once ruby.wasm is downloaded.

The benefits of using Ruby with WebAssembly are many. First, it offers a new way for ROR developers to expand their toolkit and stay competitive in a rapidly evolving tech landscape. Second, it allows ROR code to be run anywhere, making Ruby a universal language that can be used on any platform. Third, it saves time and effort by reducing the number of images and runtimes that need to be managed.

In conclusion, if you're a ROR developer looking to build better web apps with less effort, the new WebAssembly integration in ROR 3.2 is definitely worth checking out. With the ability to run Ruby code directly in the browser, the possibilities are endless. Give it a try and see how it can improve your development workflow!

What do you think about Ruby's new WebAssembly integration?
  1. It's great news! This will make Ruby more versatile and useful for a wider range of projects.
  2. I'm not a fan. I think Ruby should stick to its strengths as a backend language.
  3. 'm not sure yet. I need more information on how this will work in practice.
Vote
on February 15, 2023
Trending on Indie Hackers
I'm a lawyer who launched an AI contract tool on Product Hunt today — here's what building it as a non-technical founder actually felt like User Avatar 151 comments Never hire an SEO Agency for your Saas Startup User Avatar 83 comments A simple way to keep AI automations from making bad decisions User Avatar 65 comments “This contract looked normal - but could cost millions” User Avatar 54 comments 👉 The most expensive contract mistakes don’t feel risky User Avatar 41 comments We automated our business vetting with OpenClaw User Avatar 34 comments