3 ms·
> I never really understood the criticism about "magic" in Rails. I'll state my case as clearly as possible: The magic in Rails REQUIRES memorization... freak
by horsawlarway 5y ago
> I never really understood the criticism about "magic" in Rails.
I'll state my case as clearly as possible: The magic in Rails REQUIRES memorization... freaking everywhere. And it provides virtually no hints to jog your memory.
There's just too much tooling, hidden away out of sight, and applied through shenanigans with Ruby that other languages/frameworks make MUCH more obvious.
Simple trivial example? Rails fucks with imports left and right. Rails allows you to not even write a require statement half the time - it's just going to load things from places. Hope you have that list memorized.
Does it save you some time? Yes.
Does it make the code look "Cleaner"? Sure.
Does it make my life a fucking chore every time I have to run a damn console to find the source location of an object at runtime because it's entirely unintuitive about where it freaking came from? Damn right it does.
---
If you started early in your career with Rails - you probably don't notice this. But if you have experience with a solid selection of languages (ex professionally I've used: GoLang, C, C++, JS/Typescript, C#, Java, Netlogo, Rust & Ruby) I find the discoverability in Ruby/Rails about the lowest on the list.
Very fast to work with if you happen to have it all memorized. But that's about the only compliment I can give it.
- svachalek 5y agoI have to work with a lot of legacy codebases day to day, but generally it's get in, figure it out, make a change, test it, and go. With Rails, I just end up in that "figure it out" loop over and over. In my book it's a write-only coding environment like everyone used to complain about with Perl and PHP. People crank that stuff out really fast and move on and leave future generations to suffer. But they love it, of course.
- montblanc 5y agoHow much effort did you put into learning Ruby and Rails properly? It's easy to get started but rather hard to master and it sounds like you're invested in other tech.
- horsawlarway 5y agoRight back at ya: "Which version of Ruby and Rails?" :P Because to me - RoR is in the death spiral period that the original ASP.Net was in before Microsoft threw the whole thing out and started over with the Core version. Namely: Rails trys to give you opinionated best defaults, but the "best defaults" have changed dramatically since the framework came into existence. So you end up with 6 very different set of opinions as the framework has evolved, and the documentation is poor (honestly, at least ASP.net had okish docs - I find Rails docs pretty damn bad) and you get a complete wash on 3rd party sites trying to find relevant info for the version you happen to be using. Also - Unlike MS and ASP, Rails doesn't even fucking try to keep naming consistent. They seem to favor making the syntax as close to natural language as possible, often deprecating the old syntax in favor of new method names solely "because it reads better". Which drives me freaking nuts. Inertia will keep it running for a long time, but it's not the thing I would pick for greenfield projects anymore.
- montblanc 5y agoI'll take legacy Rails over legacy Java or legacy PHP or legacy .NET but to each his own. Good luck!
- nomilk 5y agoSome random thoughts: 1. These are fair criticisms. These kinds of problems can also be difficult to demonstrate to others who may help. For example "some function `f(x)` gives 5 when it should give 7" will get an answer in 5 minutes on stack overflow, whereas "my thing's not working and I don't know why" will receive 4 downvotes and no answer in the same time. 2. I tend to be the kind of learner who doesn't sit down for 30 days and read the docs cover to cover, but rather I start using the new tool on day 1 and figure out what I need to know as a I go. But rails rewards the former approach (i.e. reading through the rails guides - or even just skimming them). This may take a few weeks, but it gives the ability to at least know where to start to look if something has gone wrong. 3. > And it provides virtually no hints to jog your memory. I kinda agree. I feel like this should be easily addressed (although I'm not totally sure how).
- saghm 5y ago> GoLang, C, C++, JS/Typescript, C#, Java, Netlogo, Rust & Ruby) I find the discoverability in Ruby/Rails about the lowest on the list What's interesting to me about this comment is that among the languages I'm familiar with that you list, the difference between the best discoverability and the worst feels way larger than the difference between the worst one and Ruby. To me, C is barely any better than Ruby; sure, Ruby lets you define methods/types at runtime, but C doesn't even _have_ methods, making finding all the things you can do with a given type way worse in my opinion. Plus, you can still have some wonky generated stuff with macros, although I'll concede that's usually less common than Ruby metaprogramming. Java, C++, and Go are a bit better, since you get a namespace instead of just a random identifier without context, but these namespaces are generally split across multiple files, so in practice I would need to rely on tooling to do this for me, and at least with RubyMine this wasn't in practice _that_ much worse.
- horsawlarway 5y agoDon't get me wrong - there are definitely some C/C++ codebases where the macros have gotten way out of hand. But in general, they're both typed - which helps SO freaking much. Ex: C doesn't have methods, but if you store most of your data in structs then you can easily do two things: 1) find all the places where the header defining that struct is included 2) Do a global search for the struct name Both will present you with a nice list of places that data is used, and show the functions that accept it as an argument. Where as with Ruby - I basically have to use RubyMine to get anything even sort of working, and even then it chugs along very slowly trying to do it. Solargraph in VSCode doesn't really work at all (at least 50% of the time it finds no definition for me) and just using a basic editor is a nightmare. Sometimes you can do a global find for "def [classname]" but that only gives you the definition, not any of the places that use/modify it. Basically - Ruby is one of the few languages where I feel like global search just doesn't work well, and it also eschews import/require/include statements when used in Rails. It's just a tangled mess, and there's NO way to unwind it without tooling, and even the tooling struggles (RubyMine is a guaranteed way to get my fans running at full speed for large projects, and it's the best I've used).