Interesting post. I've used Laravel for a few years now for work and personal projects, and I've really enjoyed it. I tried to test out Rails to explore other MVC web frameworks, and I just couldn't vibe with it. I think the major areas in which I was incompatible with Rails were:
- Lack of dependency injection/inversion of control. I find it interesting the author lists this as an advantage. With Rails, I was always a little anxious not knowing where things were defined or being implemented.
- Validation happens on models, not requests. With Laravel, I really appreciate being able to validate pretty much any data coming into the application regardless of whether or not it ends up in the database. With Rails, I tried to look for something similar to FormRequest and its validation rules, but I couldn't find many solutions. I think it might just be one of those things that's not the "Rails way".
- Perhaps more of a Ruby issue than a Rails issue, but the dynamism of the language - especially in its type system - was a bit of a drawback for me. I really appreciate PHP 8 and newer versions of Laravel for their support in type hinting and static analysis; being able to mouseover anything and know pretty confidently what I'm working with is a huge boon in my productivity.
I definitely agree with the author on a lot of the Laravel tooling stuff. I've learned to just kind of ignore most of the offerings outside of the core framework. I'm sure it's all great, but there's always a bit of churn in Laravel as the author mentioned so I'd rather save myself the future heartbreak.
Pretty much my experience as a frontend guy that had to fill in for a team reduction and had to start working on the Rails side of things. I always felt like I was just having to "know" what was going to happen. Unit tests, mocks, etc. were all coming back "ok" but there was always something in production that would act up. I had never this happen with the Java and PHP backends that I always had to touch up when there wasn't much talent available. Before I was let go from the Rails client I suggested that they invest in property based testing for all code as it was quite clear there were cases that weren't being thought of that existed in the application somewhere (undocumented, manually added, etc.).
> Lack of dependency injection/inversion of control. I find it interesting the author lists this as an advantage. With Rails, I was always a little anxious not knowing where things were defined or being implemented.
This is why i switched from rails to symfony even though I hadn't had experience with those kinds of systems before. I took to it rather well
> - Lack of dependency injection/inversion of control. I find it interesting the author lists this as an advantage. With Rails, I was always a little anxious not knowing where things were defined or being implemented.
Rails itself doesn´t have framework/library for DI/IOC but you can use constructors, I understand that a lot of Rails devs won't and just use wtv they need.
That is 100% true. Convention is an agreement we already had. It's much less effort, and more manageable to learn that, with the potential downsides as well, compared to figuring out the particulars of a custom configuration.
The author should be careful of what they’re wishing for with respect to ActiveRecord callbacks. They’re sort of what people might call a sharp knife. You can get a lot done quickly but easily end up with something that’s dangerous to operate later.
Autoloading is fine as long as you don't go nuts with gems or write classes that will stomp on other implementations of a namespace if autoloaded. The UX as the article concedes is great most of the time. The problem usually arises when someone pulls in a gem that does a ton of class opening and can poison the rest of the application with unexpected behavior. Yes, making you vulnerable to this is a downside of autoloading, but its within your control when adding new code.
Knowing where things are defined is table stakes. A language that supports making it nearly impossible to find a function definition is objectively bad.
My point is that it’s only hard to know that if you create that problem yourself in rails, with some exceptions in ActiveSupport. The system just allows you to make that mistake, but experienced practitioners generally will not do that.
It's impossible to stop all 100+ engineers on a large team from using footguns like that. It's why I find Rails to be an awful solution for large or mature companies: sure if everyone is a "Rails ninja" who perfectly knows the consequences of every bit of code they write, a Rails app can be beautiful and perfect. That's simply not realistic as an org grows beyond a certain size.
You could make that case for a lot of popular tech stacks, and in many circumstances 100+ engineers working in a single code base is going to be a pain regardless of thee stack.
I think Rails is great if you don't go wild with things like callbacks, 10s of levels of partial nesting, and mystery behavior included in controllers. If you keep your gem use sane too, you'll be fine.
In regards to the authors complaint about ERB vs Blade I’ve had the same thoughts and have been absolutely delighted by the third party Phlex view system for rails: https://www.phlex.fun/
- Lack of dependency injection/inversion of control. I find it interesting the author lists this as an advantage. With Rails, I was always a little anxious not knowing where things were defined or being implemented.
- Validation happens on models, not requests. With Laravel, I really appreciate being able to validate pretty much any data coming into the application regardless of whether or not it ends up in the database. With Rails, I tried to look for something similar to FormRequest and its validation rules, but I couldn't find many solutions. I think it might just be one of those things that's not the "Rails way".
- Perhaps more of a Ruby issue than a Rails issue, but the dynamism of the language - especially in its type system - was a bit of a drawback for me. I really appreciate PHP 8 and newer versions of Laravel for their support in type hinting and static analysis; being able to mouseover anything and know pretty confidently what I'm working with is a huge boon in my productivity.
I definitely agree with the author on a lot of the Laravel tooling stuff. I've learned to just kind of ignore most of the offerings outside of the core framework. I'm sure it's all great, but there's always a bit of churn in Laravel as the author mentioned so I'd rather save myself the future heartbreak.