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!