Ruby on Rails 8, The SPA Killer

By kirt@optimalcadence.com, December 18, 2024

Web application development has come a long way since I started writing software professionally in 1999. Early web applications, while amazing at the time, were essentially dynamic websites. Rendering an application was often slow as files and images gradually downloaded into the browser. When you interacted with the application, the page went blank, the browser spinner spun, and the whole cycle repeated itself.

While this wasn’t ideal for user experience, writing web applications was relatively simple by today’s standards. Programmers loaded data from databases or third-party sources, generated the HTML markup expected by the browser, and sent it back to the client. However, this simplicity eventually fell short of satisfying bored engineers and companies selling software tools and libraries (aka Merchants of Complexity). Complexity began to creep in, burdening developers with trendy architectural patterns, bloated standards, protocols, and frameworks that offered minimal improvements to the end-user experience. Over time, developers (myself included) spent more time writing boilerplate code than delivering features that truly benefited businesses.

In 2004, Ruby on Rails was introduced by Danish developer David Heinemeier Hansson (DHH). For those ready to embrace it, Rails changed everything. It follows an opinionated "convention over configuration" model, which offloads much of the complexity to the framework itself, allowing developers to focus on building software that matters to stakeholders. Without exaggeration, Rails transformed the trajectory of web application development. Thousands of startups adopted it, propelling Ruby and Rails to the forefront of popular technologies.

Today, Rails powers over 1.5 million web applications and supports massive-scale platforms like Airbnb, Shopify, and GitHub. Its popularity inspired similar frameworks in other languages, such as Laravel (PHP), Phoenix (Elixir), and Grails/Spring Boot (Java), among others.

About a decade ago, a new paradigm emerged with the goal of improving user experiences: Single Page Applications (SPAs). Built with JavaScript libraries running directly in the browser and communicating with backend APIs, SPAs introduced a more responsive and interactive experience. Frameworks like React, Vue, Svelte, and Ember gained traction, enabling frontend applications to load data asynchronously while seamlessly updating the UI without requiring page refreshes.

This paradigm was revolutionary—but the Merchants of Complexity were at it again. As these frameworks evolved and the demands on them grew, their complexity skyrocketed. Some of the challenges SPAs face include:

  • Long initial load times due to the large JavaScript files required before rendering can begin.
  • SEO challenges—while improved a bit, crawlers often don’t wait for client-side rendering to complete and therefore SPA driven pages miss out on ranking.
  • Increased complexity in software builds and deployments, necessitating specialized frontend, backend, and DevOps teams.

The industry’s response to these concerns? More complexity. Tools like Next.js and Nuxt emerged, enabling partial server-side and client-side rendering. Once again, developers found themselves spending significant (if not the majority) time managing complexity rather than solving real business problems.

But there’s hope. Rails is back to simplify the landscape with Rails 8, offering a refreshingly straightforward solution that delivers the responsiveness and reactivity of SPAs without their downsides.

Rails 8 is aptly described as the "One-Person Framework," and I can personally attest to this. It retains the core benefits that made it revolutionary while introducing new features that elevate it even further:

  • Hotwire: A suite of tools for creating reactive and responsive websites rivaling SPAs, without the complexity of splitting rendering between the client and server. It’s also SEO-friendly.
  • Propshaft - No build step! Leveraging the latest browser technologies, Rails eliminates the need for building (compiling, transpiling, bundling, minifying, etc.), simplifying the development process.
  • NoPaaS: Rails 8 includes Kamal, a tool that allows developers or DevOps teams to easily deploy applications to cost-effective self-hosted or Virtual Private Servers (VPS) instead of pricey cloud services like Heroku or AWS. This can save hundreds, if not thousands, of dollars per month without compromising performance.
  • Solid Cache, Solid Queue, and Solid Cable: These technologies streamline caching, job scheduling, and real-time capabilities by leveraging the same database used for your application, eliminating the need for third-party solutions like Redis.

If it isn’t obvious, I’m once again thrilled about Rails and the opportunities it brings for me and the companies I work with. Ruby and Rails consistently rank among developers' most loved technologies. Happy developers are productive developers, and productive developers are happy developers.