Codementor Events

Why Rails is still better than SPAs for most of the cases

Published Sep 25, 2018

Yeah. Let's get my hands dirty. Simple Page Applications are beautiful said, but it's not what everyone needs.
This is controversial. Everyone today only knows how to say MERN - Mongo, Express, React and Node - when it comes to choosing a tech stack for a new app. That's super trendy, today, and it's indeed a very powerful combo of frameworks. Don't get me wrong.

But it's still not the best choice to everyone. I tell you why:

The Single Page App is another app

For me, the biggest caveat of having a SPA is precisely that the SPA is another app on its own. You'll have a lot of components, API calls, couplings, and states to generate and mantain.
It's more code. It's a new app. There's a wholo lot of business who just don't need this extra layer of complexity and expense (since you're writing more code), in exchange of marginal UX improvements.
And if you decide to change something on your backend app (which happens a lot in in products that are not yet so mature)... there you go changing a whole different app in your front end.

React is beautiful, but it requires you to know what's going on

React is complex ES6 code. It requires you to know exactly what's happening there. All the state manipulations, API calls and soft reloads that the framework does can get new developers (new to your code) a harder time to get started, since the code written is not necessarily the most straightforward to read.

In the meantime, for the fact that Rails is so opinionated, most of the apps run in similar grounds and assumptions. They are usually built in a similar fashion, and this gives more agility to developers to perform changes faster.

SQL is very fast

Sometimes people start saying that SQL is not so efficient, and the future is No-SQL. It's just plain wrong to say that SQL is not fast enough - if used right (something which all the decent computer scientists should know how to do), the power of SQL is still pretty today.

I have worked with databases with hundreds of tables, with millions of records each. And it worked like a charm - because it was well built. It's all about how you organize information, how it will grow and how you want to access it. For a lot of applications (specially those that are more report-intensive), SQL is very handy for extracting data without much effort.

I have also worked before with business users that knew how to use SQL, and could perform simple select statements in copies of the application database for very complex analysis that they ran. I would never see them being able to run those analisys in non-table based databases.

SQL, with its Joins, Indexes and Normalizations is a beautiful pattern that is applicable to most information systems I've ever came across in my carreer.

Active Record is still beautiful

And keeping on the database talk, ActiveRecord, the core of Rails is still amazing. If you take all the rest of the framework out and keep only the back end, Rails is still very useful precisely because of ActiveRecord and how fast you can build and handle complex data with it.
If you're all in SPAs, building your back-end with Rails is a huge tool to consider.

Unless you need ultra-sleek and flawless UX (which is many times the case, I see that), you can probably afford a soft and fast page reload. Just not bothering about all the async calls and different states the User Interface can be without having the back end updated (which is a struggle sometimes in SPAs), is a huge increase in productivity for the developers. Specially in early stages of development

Rails has an amazing community

Rails has an amazing community, and it's just amazing what you can find in Stack Overflow when you run into any weird error while coding. The amazing community is there to help you. You also get that with the JS-stack, but the Rails community is very mature and is able to solve in no time any of the trivial errors (98% of what you'll face).

TL;DR

Rails is still amazing, even comparing with more recent options. Using the right tool for the right problem is the key. Full on Rails, Rails for the back end only or just any other approach.

Discover and read more posts from Sal Sousa
get started
post commentsBe the first to share your opinion
Show more replies