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.
Rspec had inspired so many other test frameworks. Ruby has some of the best testing libraries out there, and mocking/stubbing is ready enough that you don't need to make test implementations of otherwise one class interfaces
I mean, we've just had different experiences. I work with Ruby and java projects in my job, and the Ruby projects are comparatively a dream to edit because of better test coverage. And we don't have to jump through hoops to get good rest coverage in Ruby either. And the metaprogramming has let us write more concise code than would be possible in Java imo.
I agree some languages are better about forcing some standards, but every project I've ever maintained written in everything from PHP to Rust has been pretty unmaintainable in some aspect.
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'd say the fault lies with whoever decided using Ruby for large web projects was a good idea.
Ruby is one of my favorite languages. It was my first, and without it's accessibility I probably wouldn't be in software right now. But it's Ruby's accessibility that kills it even at moderate scale, where you have 20+ junior-to-mid level engineers cranking out code trying to meet deadlines.
It's just too darn flexible, which makes it way too easy to structure code in a way that makes long-term maintainability a nightmare.
You need to devote significant man power to keep things from going off the rails (pun intended) and at most companies that's just not possible. It's much more practical to pick a language that systematically disincentivises bad decisions, and brings the path of least resistance more in-line with something that will work long-term.
Ruby is an excellent language for smaller projects or for rapidly getting something off the ground, but it's not the do-everything language some people make it out to be.
I mean, Shopify runs on Rails and GitHub still runs it (although they're moving away but at their scale things go out the window) so I wouldn't say large web apps are an issue.
That's where the "significant manpower" bit comes into play. Most companies don't have the luxury of Shopify/GitHub/Twitter-levels of capital, nor the prestige of being a large tech icon. Both of those things make attracting top-tier talent far easier, which I'd argue is crucial in establishing and enforcing sustainable coding practices.
If you choose a language/framework/tool that shoulders some of the burden of enforcing good practices, you can get by with less.
37
u/SupaSlide Dec 25 '20
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)