Lurker News

Comments (438) 69 threads

Earlier comments
charlysisto#
A simple formula to take a lot of AR's bloat away is to use it mainly as a read library (AR's great for generating complex queries in a simple & readable manner).

For write operations (aka user interaction) I use a combination of solnic gem (Virtus) with ActiveModel that way I remove a s*t load of responsibilities from AR and the controller : - params management (and strong params) - validations - nested associations - callbacks - And all the context management (like user vs admin...)
That way I only mildly part from the rails way and yet have a good separation of concern. Actually ActiveModel is used by ActiveRecord so having a form object relying on it is still very much rails compliant. The refactoring is minor (no hexagonal stuff) and the level of indirection very low.

fiatjaf2 replies#
This should come at no surprise, although I don't see anyone criticizing Rails anywhere.

I've never written a line of Ruby, but trying to read Rails code evokes me all this: it seems like a framework created with the sole purpose of hiding everything possible from the programmer.

gonyea2 replies#
It's not hiding anything, other than the conventions. Django's spammy boilerplate is just default behavior.
kowdermeister4 replies#
Conventions is something I try to avoid at all costs. Conventions are usually things that are hard to find in documentation. Conventions are things that every experienced user says that "oh, this is common knowledge" and conventions are the reason why things seem to work magically.

Obviously if you follow a framework from day 0 you don't even notice it. For newcomers, it's a source of frustration.

nitrogen#
Frameworks should be designed for experts as well as newcomers. I was a Ruby-only developer and, after starting a full time Rails job, picked it up quickly enough.
lobster_johnson10 replies#
That's not really what convention refers to here. Rails' motto "convention over configuration" simply means that boilerplate should be avoided, and that code should use sensible defaults whenever there isn't information.

For example, ActiveRecord class names map to table names through a simple pluralizer (UserProfile -> user_profiles). That's a convention, no configuration needed. Just write a class and off you go. You can override this behaviour, but you can also write huge apps that just follow the convention. Other frameworks would typically make this mapping explicit.
You do need to read the documentation to see what the conventional behaviour is, but it's not very deep knowledge. It's not much worse than other frameworks, where you need to find how things are configured.

Continue this thread — 10 replies

viseztrance1 reply#
On the other hand conventions are great when reading a foreign code base.

Continue this thread — 1 reply

gonyea1 reply#
Your complaint is more about implicit vs. explicit. Implicit behavior is bad when it's surprising. When it's what you would have done anyway, then making it explicit creates an unthinking, tedious ceremony that you repeat daily.

Some of my favorite Rails devs are former Python devs. They appreciate conventions and the freedom they give you.

Continue this thread — 1 reply

collyw#
What do you see as Django's spammy boilerplate?
enraged_camel1 reply#
Rails has plenty of critics. You just aren't looking hard enough.

The most common criticisms are: it's slow and it has too much "magic."
At the end of the day, it comes down to this: every framework has its pros and cons. When you use a framework, you gain certain benefits but sacrifice certain things and have to conform to the framework's opinions. In the case of Rails, the primary benefit is extremely fast prototyping. But that's only possible because the framework hides a lot of complexity from you, which can bite you in the ass if you try to go outside its conventions.

dk89965 replies#
I personally can't wait for Rails to be a distant past. So many start-ups got burnt badly by using Rails -- easy to start, hard to scale, maintain, and extend. Rails is too opinionated and if your use-cases don't fit into "Rails way" your screwed.
pmontra1 reply#
But at least it got them started and they could understand if there is a market for their product. My bet: if twitter started with Java Struts (it was 2006) they would have had to spend so much money and have needed so much time to launch that we would be using something else now. Not necessarily a system bootstrapped with Ruby, but you got the idea.

> if your use-cases don't fit into "Rails way" your screwed
Of course.
If a startup service doesn't fit Rails, they should have picked something else. I'm not using Rails for everything.

dk89961 reply#
Startups usually try on a bunch of use-cases (features, ideas, workflows) before they gain traction or die. Your saying that startups should know all the use-cases they plan on building before they even start -- that simply impossible. Maybe your point is that startups shouldn't use Rails and its more suited for dev projects with a clear spec.
danenania#
Not really. Rails is good for quickly hacking things together across a very wide range of the domains that startups usually play in, which makes it as good as anything out there when upfront productivity is the priority and you have rapidly evolving specs.

The only really common startup use case it's decidedly bad at is realtime/sockets/streaming data, where Node takes its place as the hack-it-together tool of choice--at a significant productivity penalty compared to Rails.
It's also, of course, pretty bad at all kinds of tasks unrelated to web development or REST apis. You wouldn't want to write machine learning algorithms or do statistical analysis in Rails, just like you wouldn't want to do 3d game development in Rails. And while you do occasionally see startups who have bolted some heavy data processing or pseudo-ML monstrosity onto their Rails apps, I've never seen anyone in the Rails community claim that was a good idea. The vanilla recommendation there is to keep your main server stack in Rails and then write services in something more appropriate for those needs.

jupp0r1 reply#
From what I've seen, this is exactly what it's good for. Get something going fast. When scale is needed later, the microservice journey starts ...

I agree with the author wholeheartedly, but there is certainly value in getting something that works quickly.

dk89961 reply#
Your also implying that easy to get started and ( scale, maintain, and extend) are mutually exclusive. I am saying they are not and don't have to be. Moreover, this kind of thinking just proves the point of why we need to move of from Rails.
danenania#
Move from Rails into what? Nobody is disagreeing that Rails has problems, but until there's a battle-tested replacement out there with a similarly strong community and range of libraries it's all just theorizing.
wuliwong#
Can you give some examples?

I've always heard people blast Rails b/c of Twitter's experience but Twitter did survive it and scale. Maybe Twitter would have never gotten to the level of success they did without using Rails? Also, I'm not convinced that the original developers at Twitter did a great job implementing the first Twitter infrastructure. It is possible to write bad code using Rails that would be bad no matter what language or framework was used. It's a huge unknown in that story that entirely changes how to judge the outcome.

fiatjaf#
Just rewrite everything in Go.
elliotec1 reply#
Back up what you're saying. Rails built a lot of extremely successful companies. It is not hard to scale or maintain if you are competent. If you scale beyond the capacity of Rails, you are Twitter and it's ok to move on.

I think your statement is patently false.

dk89961 reply#
I am seeing good amount of comments saying "Twitter did it", this is simply a logical error (survival bias). Moreover, I think Twitter would of been successfully even without using RoR.
elliotec#
Github, Airbnb, Dribbble, Bloomberg, Genius, Funny or Die, Goodreads, Groupon, Hulu, Kickstarter, Shopify, Square, Twitch, Soundcloud, etc etc etc.

So yeah, survival bias. If startups failed and used Rails, it's because they were bad startups for reasons outside using Rails.

douchescript#
The things that suck in rails are the views, the asset pipeline and the stupid helper methods for routes that are so complicated for nested routes it's a joke. The database part is actually the good part if you do it right.

Load more comments