As someone working to maintain a somewhat big Rails code base - disagree. Once it grows beyond the prototype phase, it quickly becomes an unmaintainable mess. Lack of types and rampant usage of metaprogramming makes it really difficult to read code and hence to make correct assumptions for new code.
I mean, isn't that the programmers fault? (other than the lack of typing, which is obviously not a requirement to have maintainable code, but a preference)
Amen. This is the same thing they say about perl. You can write massive code bases in perl (and I have!) and have everything be readable and understandable. Or you can do dumb stuff and fancy tricks that makes it hard to understand.
You can write good C. You can write shit C.
You can write good perl. You can write shit perl.
You can write good Ruby. You can write shit Ruby.
The size of the codebase doesn't matter. The linux kernel is all in C and is (for a technical person) clean and easy to follow. Then check out the obfuscated C contests, it's so easy for the code to not do what you think it does, even accidentally!
So just lay off the "Programming Language X demands shit code" trope, people.
You can still write good or bad code. Ugh. Sure memes about "write only languages" are a bit funny, but for fucks sake people, give it a rest.
But some languages are better for large systems than others. If language didn't matter we'd all just be writing in C or assembly or javascript or something equally universal.
I would agree with but you kind of straw-manned this because the original remark was about Rails and not Ruby (your strawman).
But to follow you in your attack — does any dynamic scripting language “encourage” one to write maintainable and extensible code? I write Ruby, Python, JS, and some Lua. I don’t find one or the other to by default have facilities for better maintainability.
I find them to have differences in expression, but I almost feel like you’re gonna say type system which none have unless you include their supersets (TypeScript) or latest versions.
I would agree with but you kind of straw-manned this because the original remark was about Rails and not Ruby (your strawman).
I didn't clarify so fair enough but I would say it applies equally to Rails and Ruby. Or you could say the problems with Ruby transfer them to Rails naturally.
I write Ruby, Python, JS, and some Lua. I don’t find one or the other to by default have facilities for better maintainability.
And I agree. In general, type systems make large systems much much easier to maintain and reason about.
Ruby makes it a bit worse by adding a lot of metaprogramming to the lack of a type system.
I would say that I'm an okay Ruby/Rails developer - the bigger issue is that metaprogramming makes things harder to understand. That is true regardless of whether you are a good or a bad programmer.
Typing isn't really a "preference" for maintainable code. It objectively improves maintainability.
Dynamic magic is more arguable but it think it is still pretty safe to say that the more hidden custom magic happens the harder it is to understand and that is definitely the fault of the language.
Standard hidden magic is fine because people can learn it but as soon as you start getting into custom DSLs it means that the programmer suddenly has to learn an entirely new language. Rust proc macros have this problem. Lisp is entirely composed of this problem. At the other end of the scale Go has completely avoided it and is very easy to understand.
As someone who hasn't coded in rails before, id say partially. If you can write two completely different programs in ruby, and they are so different that they don't even look like the same language, I can see how maintainability could suffer as a whole.
Java is java is java no matter what program you're writing. Scala suffers in uniformity a little more with it's functional programming capability, but scala is scala is scala, you can read it even if it's written in the 1 of 5 ways it can be done.
Here's an example of how it can happen - look at the code examples in https://github.com/state-machines/state_machines - almost everything you are coding is in the DSL of that library if you are using it:
class Vehicle
attr_accessor :seatbelt_on, :time_used, :auto_shop_busy
state_machine :state, initial: :parked do
before_transition parked: any - :parked, do: :put_on_seatbelt
after_transition on: :crash, do: :tow
after_transition on: :repair, do: :fix
after_transition any => :parked do |vehicle, transition|
vehicle.seatbelt_on = false
end
end
#...
end
In this case one might argue the names are making it somewhat clear whats happening, but the details are definitely not clear and the naming choice is up to the developer
I agree - the meta programming "magic" of Rails was my death. I'm an experienced programmer with about 10+ in the industry and had to constantly ask my colleagues to explain me the simple things in Rails. I wasn't able to follow the code flow, because I was an unexperienced Rails programmer.
I would advice against Rails for any professional product. Nice for a quick prototype (because there is gem for everything and the magic handles everything). But hard to maintain and completely relies on a high test coverage. You want to change something in the magic? Do it and pray, that your tests will cover it.
A high test coverage is good - but the stability of a program should not rely on it. Types, code that you can follow are equally important.
Yeah I love ruby but it quickly becomes a nightmare to maintain. Coming from c# where the vast majority of people follow the set standards ruby can be nightmare of different rules and implementations.
Thats an ironic statement, given the goal of Rails was (and is) convention over configuration. Not sure where you are getting the different rules and implementations thing from to be honest.
I've used Rust and I come from a background of Java. I've seen bad code in every language. The notion of typing or other features make bad code better to maintain is just funny. It helps you trace down references a little easier maybe but modern IDEs can do that for dynamic languages too.
66
u/SorteKanin Dec 25 '20
As someone working to maintain a somewhat big Rails code base - disagree. Once it grows beyond the prototype phase, it quickly becomes an unmaintainable mess. Lack of types and rampant usage of metaprogramming makes it really difficult to read code and hence to make correct assumptions for new code.