November 1st, 2024

Rewrite it in Rails

The author developed a customs declaration app in Ruby on Rails, faced challenges rewriting it in Rust and SvelteKit, and ultimately returned to Rails for its rapid development benefits and collaboration.

Read original articleLink Icon
Rewrite it in Rails

In 2022, the author began developing a customs declaration application using Ruby on Rails after experimenting with various programming languages and frameworks. Despite initial intentions to rewrite the application in a different language, the Rails version quickly gained functionality and user approval. The author then attempted to create a "version 2" using Rust and SvelteKit, but faced challenges in feature completeness and development complexity. Over time, the Rails application continued to evolve, while the new stack struggled to deliver value to users. Eventually, the author recognized the need to revert to Rails for parts of the application, acknowledging the framework's strengths, including its mature ecosystem and ability to facilitate rapid development. The experience underscored the importance of making trade-offs in web application development and highlighted that no framework is perfect. The author concluded that returning to Rails allowed for increased productivity and collaboration with colleagues, while also emphasizing the value of learning from different programming languages and frameworks.

- The author initially chose Ruby on Rails for its familiarity and speed of development.

- Attempts to rewrite the application in Rust and SvelteKit faced significant challenges.

- The decision to revert to Rails was based on its strengths and the need for rapid feature delivery.

- The experience highlighted the importance of trade-offs in web development.

- Learning from various frameworks ultimately improved the author's programming skills.

Link Icon 22 comments
By @jsnell - 2 months
Discussion two days ago, 239 points, 219 comments: https://news.ycombinator.com/item?id=42024246
By @wkirby - 2 months
I spend a lot of time each year evaluating frameworks for our clients and their projects, and I keep on coming back to rails.

> Does it turn into unmaintainable spaghetti code after a while? Only if you let it. It's typically caused by developers, not programming languages or frameworks.

After running a number of rails applications in production for going on a decade, this is really hard, and I find it to be one place where rails (really ruby) doesn't help much.

Of all the languages we work in (and it's quite a few), ruby has the worst support for modern language tools: the LSP implementations are weak, and don't play well with containerized development environments. Typing efforts are fractured, and the official way is... well.. it's bad. This is exacerbated by ruby's tendencies towards "fluent" interfaces, which is actually code for lots of methods that take undocumented hashes of arguments --- and hash access with strings and symbols? nightmare fuel.

But I still come back to rails. It's productive, it's fast enough, it scales just fine, and perhaps most importantly there's a "right" way to do just about everything your web application will ever need to do: background jobs, websockets, read-only database replicas.

All in all, its still my recommendation for new web projects going into 2025.

By @xp84 - 2 months
> It's typically caused by developers, not programming languages or frameworks.

Best sentence in the article. I’ve worked in well-organized and reliable PHP apps, and giant buggy abortions in TypeScript. Lots of Rails apps with varying degrees of quality. Languages and frameworks can’t fix disorganization, poor architecture, laziness, or most of all, ignorance of how the Web should work (and why.)

The main predictor of how good your app will be technically, is the skill level of your worst developers + how much your best developers care (or are allowed to care, which necessarily varies with business conditions). Regardless of if you’re using trendy languages like Rust, TS, etc.

Of course, while as hackers we desperately wish for the app to be of very high quality, the sad truth is that companies who always obsess over the finest details under the hood don’t tend to perform as well financially as the ones who make compromises to get things to market faster and pivot more effectively, so I think that’s why most of us have rarely worked in commercial codebases where nothing is embarrassing.

By @nop_slide - 2 months
Over the last few months I evaluated django, laravel, and rails by doing their tutorials.

So far rails has been my favorite to rediscover, I used it 10 years ago and boy has a lot changed!

I was hoping to like django more since I'm a professional python dev, but django felt like I was still clobbering together libraries (whitenoise, celery, etc) and it doesn't have a great front end story.

Laravel was super slick, but I just can't do PHP. I know it's come a long way but it's just not for me.

Rails really stuck for me the most and I really like the hotwire paradigm. As a dad with limited time for side projects Rails is going to be the tool for me now to spin up something quickly.

I'm actually porting over a current side project to rails and stumbled on this magical gem called "Brick"[0]. You just point it at your existing DB then it reads the current state of the database and makes active record models in memory for you to play with. You can then eject the models and controllers into your code base, and bam you have your model layer recreated in rails.

[0]: https://github.com/lorint/brick

By @mgkimsal - 2 months
Many make the same argument about Laravel, Symfony, ASP.NET, etc.

There's a huge amount of value in having an ecosystem of components that are designed to work together, and randomly choosing "oauth X" and "smtp Y" components and trying to string them together, vs using a battle-tested and supported stack, just invites a lot of hurt.

If you have a team of Java web app devs, having them build a web app in Rust or Go will be incredibly costly and inefficient. It seems very obvious to me, but I still get people that say "oh, it's not that hard - library X can do all of that other stuff"... but inevitably it can't. And the communities of people doing web app stuff in (Rust, Go, Scala, etc) just aren't big enough to provide the community support other frameworks provide.

Kudos to the author for their epiphany.

By @cpursley - 2 months
The problem was choosing Rust and SvelteKit over Elixir with LiveView (Phoenix) - especially coming from Rails where it’s an easy transition due to shared philosophy and even syntax to some degree. Rust is neat but complex and probably overkill for a web app. But yeah, in general - innovation tokens cost time vs what you already know.
By @hfourm - 2 months
What about Rails and Svelte? While many people are doing things with full stack Rails, there are just as many using Rails (whether as a monolith or separate backend from frontend deployments) with modern JS.

Actually, in recent Rails versions the mistakes of Webpacker have been replaced with much more flexible gems for building frontend assets with esbuild, vite, or any other build tool.

This gives the ability to seamlessly blend the nice pre packaged rails ecosystem with the nice ecosystem of react components or other modern frontend tooling most people are using.

I close this comment with mentioning: you still may not need all of that new stuff! What does your app actually do?

By @agentultra - 2 months
I'm not surprised that this conclusion was reached after trying to use Rust for a web development project.

Rails' is what people are going for when they choose it, not Ruby (generally speaking... there are obviously people who like Ruby). Rails provides all of the tooling, conventions, and ecosystem needed to tackle a great deal of web development projects.

Rails is a great example of a killer application. People learned Ruby just so they could use Rails. Wanna make a bread-and-butter website, just build it in Rails. Three-quarters of what you need is available in the framework itself and most of everything else is a library that integrates seamlessly with the framework.

If you need to use a systems-level language to solve a technical problem, you'll know exactly why you need to go through the trouble. If you're using maxims to justify your choice, you have no idea. "Because it's blazingly fast," doesn't matter if -- as the TFA points out -- your most heavily-trafficked endpoint is serving a p90 of < 400ms, your team is delivering the features you need on time, and your users are happy.

I think there are lots of good reasons to use a Rust-based framework. I work in Haskell full time. I get it. But there are huge trade-offs. The most obvious one is that almost no SaaS or open-source components you use will ship Rust or Haskell SDKs. They will ship libraries that integrate with Rails.

By @malkosta - 2 months
Too bad you didn't choose Phoenix/Elixir. Give it a try, and never come back to Rails.
By @henning - 2 months
This isn't really an argument in favor of Rails so much as it is an argument against being indecisive and scattering your efforts too widely.
By @hakunin - 2 months
By @chrisfosterelli - 2 months
Changelog had a podcast come out with David Hansson (the creator of Rails) a few days ago: "Rails is having a moment (again)" https://changelog.com/podcast/615

I'm not a particular fan of Ruby itself but I can appreciate the value that Rails brings. The interview with DHH was quite interesting... DHH is not someone I find I've always agreed with but his opinions nonetheless always seem reasonable and thoughtful. It seems useful to have someone that Zigs when the rest of the industry Zags.

By @galaxyLogic - 2 months
Rewriting really improves the quality of the code-base, because it increases our understanding of it, and allows us to replace stupid designs with better ones. Using adifferent language or platform forces you to rewrite much of it, with the same or better design.

In my opinion the ionvestment is not so much in the code, than in the design.

By @Scarbutt - 2 months
I couldn’t help but notice that he was working with two extremes, ruby and rust. A nice middle ground could have been nodejs with TS, with the advantage of using a single language throughout the project. While nodejs doesn’t have something like rails, its ecosystem is largely centered around building web applications.
By @make_it_sure - 2 months
Rails is having a comeback
By @siliconc0w - 2 months
I do think LLMs change the game a bit. Rails is nice because of the ecosystem and how magic and expressive it is but LLMs can generate and maintain a lot of the boilerplate while they're less good at debugging the magic when it is misbehaving.

I am working on an app that has a frontend in Django and the backend in Go and when I make changes to the Go side I just feel a lot more confident it'll all work as intended. Compared with Django I keep finding myself in the weeds debugging why some random dependency is misbehaving which is difficult because python allows you to do some really heinous stuff like instantiate classes that are chosen using runtime configuration.

By @systems_glitch - 2 months
Rails still gets the job done. That's what you get paid to do -- the job!
By @very_good_man - 2 months
Excellent article. This is why I have tied my livelihood to Ruby on Rails.
By @claudiojulio - 2 months
Forget Rails and embrace Sveltekit. All the magic of Rails can be achieved in any framework with LLMs.