IS RAILS IS A BAD IDEA?
I’ll start this article with a disclaimer:
“ I don’t hate Rails as a framework. I just have certain opinions about it“
I am a fan of the ruby on rails framework and I started courses on the framework earlier last year. The framework itself is So beginner-friendly, and one of the things that stood out to me was the fact that it is easily maintainable for small projects but tackling much larger projects might have you in a bind. It also tends to open itself up for collaboration.
So if you are considering to hope on the rail wagon, here are some things that should give you that extra nudge:
- The community is strong
- It’s a beginner-friendly framework
- It has support for pragmatism
- It’s got the best standards and practices
- It enables fast development
- It’s very easy to migrate and modify
Ruby on Rails, which is an open-source web application framework for the server-side operates on Don’t Repeat Yourself(DRY), which provides a standard setup convention.
However Ruby on Rails is annoying! it feels like working with a teenager with attitude issues. It has its way of just getting underneath my skin sometimes — Brrr! I guess that's the price you have to pay for its architecture based Model-View-Controller (MVC) and fast development style which comes in handy when you’re under the pressure of a short deadline or a tight budget.
Okay, some tweets to further buttress my point:
Speed & Architectural Precession
Huge projects with large-scale traffic tend to have slower speed and performance compared to other frameworks like Django, Go, or Node.js. And as usual, all the blame goes to the developer, but honestly, He/She isn't entirely to blame as Rails has a hand in it as well.
Rails is a powerful and nice tool, but when misused by inexperienced developers, performance can take a very bad hit. Now don't get me wrong I know I said earlier that it is beginner friendly but at the same time only for small projects, using Rails to tackle large projects without the experience will have you turning in circles. Having a bad architecture drops the performance together with its hunger for memory this hinders the garbage collectors to do their work causing the whole project to become very slow. Unlike languages like Go and C++, which are compiled, Ruby and Rails require more time to execute code.
So, issues regarding performance still boil down to server or database architecture, rather than Rails itself.
One good side is that you can make your application faster with code optimization, caching, and scaling. To achieve the same performance with Rails as you do with other frameworks like Django, you might need to spend more money and time on better server infrastructure. Obviously, that can be a pain.
Optimization can be a forgotten aspect of Rails development with the lucidity of quickly throwing in some gems, queries, Active Records, and deploying your project. You’ll most likely find your article struggling in the performance area. Although this article isn’t a ‘How to optimize your Rails project’, articles from Cheyne Wallace give a guide on this.
Railway or the Highway
For Rails most of its dependencies and modules — if not all — come out of the box and disregard customization. Developers tend to configure modules, most especially database migrations and routing, which can be exhausting to model especially when your project requires a different setup.
Is this really frustrating for all developers? you might ask and I don't speak for everyone but I can confidently say that quite a number of developers have some complaints about this as seen in the tweets above.
The point is, Rails has it all! Rails is crazy about gems(a library used in your application). While this is good for developers that just want to jump into a project and get things done quickly, it is annoying for some when you have to use things that don’t feel right for your project. One could add that it’s either its way or you spend time and money paving your own way to customization or if you want to build something extended or unconventional.
A lot of things happen behind the scenes and you often don’t know how or why. It feels good not having to micro-manage everything but can also make you prone to unnecessary mistakes. More specifically, the Ruby on Rails code looks simple but yet so complex. Having the ability to take or perform a lot of actions and connect to gems (libraries).
Personally, I believe that Rails takes on more than it can handle at the being of development, some of these things which don't get used by the developer and as such become redundant weighing down on the CPU and slowing things down. The complex capabilities of Rails may seem awesome, but a lot of what happens in a line of code might be unknown. A faction of developers are okay without knowing and focus on getting results as they say “Ignorance is bliss” however another faction tends to lose their composure leaving certain things without their control — I belong to this faction but don't take my word for it have your own experience and make a choice for yourself. for me, it has to do with most of these underlining processes slowing things down with the number of actions performed in a single line of code in Rails making it hard to maintain.
Fewer web hosts
Ruby on Rails is more resource-demanding than some other popular frameworks. It requires more CPU usage, which some web hosts might not give. Hosts that are Virtual Private Servers are much more convenient because they do not support the physical server in the sense that resources like RAM and CPU are not a consideration.
The point is that not all web hosts can keep up with most Rails projects.
Handling the Rails Framework
I know that the above paragraphs might have you tilting away from Rails however performance and speed are not based on the framework alone and so here are ways to handle the framework that will still give you your desired results.
The solution to your issue with performance is quite obvious Caching. The few pages and content blocks that are most likely to be opened by the user should be cached. This alone improves your performance significantly.
In addition to that, making assets like that of the important resources (including images, fonts, etc.) for your pages external be it big, small, or heavy. Whatever the size also significantly boosts performance as offloading away from your server gives it less work to do.
Another way you can improve your performance is by using Unicorn for Heroku. Unicorn is a multi-threaded server (or web worker) for Rails in particular. This handles connections by tripling its amount. A web worker handles one connection, 5 workers handle 5 concurrent connections, and so on.
You can also use eager loading to boost query performance and utilize indexing to boost database performance.
Finally, remember: Don’t repeat yourself (DRY). This is really common advice, but a lot of developers neglect to follow it. Please don't be like those developers.
These are the most common solutions most developers tend to use when using Ruby, and they can make a real difference when it comes to your performance and make your experience with the framework a lot better.
Finally, I’ll like to point out the fact that Rails supports the idea of convention over configuration. It’s time-saving, and enables you to write more business logic code and lay less groundwork that has no connection to the business code.
While it has its advantages, Rails is wrong on a few things. Rails is definitely not flexible — in fact, it is a one-way street bottled into a one-way mechanism. and as such it doesn't make scaling up for large projects easy.
Did the creators of Rails take convention over configuration a little too literal or did we the developers water down their intent when it was first introduced. As a result, they reduce the flexibility of users’ patterns in favour of patterns in-built in the framework. This has made trending concepts complicated to implement without sacrificing other choices.
Upcoming releases seem pretty promising, however, most of the downsides are being fixed, and more features are being added. Rails should be on track to improve in the future.
Rails is the ideal choice if you have deadlines and budget requirements that require fast development. But a more flexible framework like Django is probably a better option just because it allows you full control. Heavy real-time applications, which always require faster performance and scalability, will require consideration if you’re planning to use Rails.