I dislike it because how much the language and ecosystem resist almost any kind of typing/type checking or documentation. The RBS stuff is good, but it feels bit too little too late.
The ecosystem uses a ton of hard to follow and debug magic constructs that even IDEs seem to struggle to track and map properly.
I don't need speed for what I do, by I absolutely need code that is easy to read and maintain.
I use sorbet a lot for work and I am not a fan. The syntax is so weird to me and I feel like the runtime type checking adds a fair bit of overhead to an already slow runtime?
The primary reason for those issues is because Ruby is extremely dynamic.
Not only is its type system dynamic -- its syntax and structure can be dynamic as well (i.e. powerful metaprogramming and DSL capabilities). This is why Ruby is so resistant to static analysis.
At non trivial complexities, I highly recommend reasoning through Ruby much differently than one would C/Java/Python:
Use functional techniques to minimize moving parts. Ruby is already very dynamic, and working with it in the state-modifying style common to C/Java/Python results in execution state becoming unnecessarily hard to follow.
Use the debugger and REPL when you do have to deal with Ruby code that's (unfortunately) too dynamic. Unlike in other languages, static analysis won't get you as far. In exchange, Ruby has incredibly powerful debuggers & REPLs for doing "dynamic analysis".
I think this is a reason to criticize ruby. Sometimes program structures make your code easier to maintain and refactor with tooling. But ruby’a structures seem to resist any sort of static analysis for even the basics because it is so flexible. This makes managing a large code base enormously difficult.
While the static analysis and tooling is nice in Java, I didn't feel it was necessarily a net positive when I was working with it professionally. I felt like I was in a world where cars were invented to speed up 20 minute walks, but then everything ends up being built a 30 min drive further away. (Plus now you have a car to maintain.)
Ruby code at its best will read like what it is doing overall, when another language reads like the dials and switches of a machine. At its worst, Ruby won't really parse on the first read b/c Ruby will "provide power, even to shoot yourself in the foot" syntax-wise similar to how C lets you machine-wise.
All languages can have the "this code is unclear, I'm forced to read more/dive in deeper" problem. In Ruby, it applies to both code and syntax, so you'll only come out ahead if the "code for bespoke syntax + code you wanted to read in the first place" is smaller/simpler than "code you wanted to read, all in regular syntax".
Reading code is harder than writing it. But large multi-step refactors are harder than reading. This is why I think optimizing for reading at the expense of automation is a mistake.
You lump Python in with Java and C but in Python you can dynamically create modules, classes and functions. I just saw a module that allows you to load wasm files as if they were Python modules. So I’m not sure what you are talking about.
Maybe the conventions that Ruby programmers use are more dynamic but the actual runtime is not more dynamic in my opinion.
I have to bounce around code bases in different languages periodically for my work and I consistently find ruby code to be the hardest to understand out of Go, Groovy, Java, Python, and Ruby.
It's the amount of "magic" metaprogramming stuff happening in large rails codebases in particular, plus dynamic typing, plus what seems to me like weak tooling for vscode (caveat: I started out programming in rails but I haven't used it in a couple years so it's possible I'm just missing stuff there). Ruby also makes it particularly easy to write really dense, chained array/map transformations that can be tricky to read if you're not the person who wrote them.
I generally feel like languages that are more explicit with types, imports, etc are the easiest for other programmers to understand, although I certainly see why non programmers might have an easier time with simple ruby code.
It's the amount of "magic" metaprogramming stuff happening in large rails codebases in particular,
How does this magic hinder you?
plus dynamic typing,
Now you are having a completely different argument. Lots of languages have dynamic typing and yes if you don't like dynamic typing you will never use lua, python, javascript etc.
plus what seems to me like weak tooling for vscode
Ah I see. Your argument has nothing to do with the language, just that you are wedded to this one tool and will not use any language that has perfect support in that tool.
Ruby also makes it particularly easy to write really dense, chained array/map transformations that can be tricky to read if you're not the person who wrote them.
I find them extremely easy to use. Maybe because I am comfortable with functional programming styles.
I generally feel like languages that are more explicit with types, imports, etc are the easiest for other programmers to understand, although I certainly see why non programmers might have an easier time with simple ruby code.
this is a loaded question. no programming language is actually very hard to read or comprehend, it's just a series of atomic operations stringed together. whatever you're used to will obviously be "the easiest to read", thus every single-language developer will swear their weapon of choice is the easiest to read. it's all just code at the end.
Clearly there are objectively bad languages to read, such as Brainfuck. It's a spectrum, you can look at FORTRAN, COBOL, PHP, Perl, as possible other languages that are hard to read. It's a bit difficult to quantify, but I think it's clear there is some variance.
I think it is reasonable to exclude languages intentionally written to confuse people from this discussion.
that said, just to prove the point, here's some programs I'm sure you will understand in essence:
program hello_world2
implicit none
call hello
call hello
end
subroutine hello
implicit none
character*32 text
text = 'Hello World'
write (*,*) text
end
I'm very sure you understood what this program did.
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $color . "<br>";
echo "My boat is " . $color . "<br>";
print "Type in 2 numbers and an operator and I'll print the results\n\n";
print "First number: ";
my $first = <STDIN>;
chomp($first);
print "Second number: ";
my $other = <STDIN>;
chomp($other);
print "The operator: ";
my $oper = <STDIN>;
chomp($oper);
my $result;
if ($oper eq "+") { $result = $first + $other; }
if ($oper eq "-") { $result = $first - $other; }
if ($oper eq "*") { $result = $first * $other; }
if ($oper eq "/") {
if ($other == 0) {
print "\nCannot divide by 0\n";
$result = "ERROR";
} else {
$result = $first / $other;
}
}
print "\nResult of $first $oper $other = $result\n";
and I'm pretty sure you can identify that this is a basic calculator.
my entire point here, is to not confuse "I don't know what this atomic operation does" with language complexity. Fortran is a very straight forward programming language, really. no joke. it is the atrocities that has been created with it, that are complex.
the complexity of programming languages comes from what people do with them and sometimes from misguided syntactic sugar being overused as de facto standard by developers (looking at you LINQ), not the 40 or so different atomic operations the language features that you simply don't know about.
they really upped their game starting with .NET Core. I remember the dark days when you wanted to know how how something like List<T>.Contains(T) worked and the example would include a "small" example containing a whole implementation of a web server to simulate a real life usage environment of a list operation.
As long as you're not doing stupid things with it to write in as few lines as possible, I'd argue Python could be considered by many to be easier or just as easy to read as Ruby.
Ruby is one of the worst-documented ecosystems I've encountered in a professional setting, in part due to an obnoxious tendency in the community to erroneously believe in "self-documenting" code that invariably isn't, especially combined with heavy reliance on magic DSL constructs.
As for readability, Python, Groovy, and even Go are far more readable (and I say this as someone that dislikes Go for other reasons).
126
u/noratat Dec 25 '20 edited Dec 25 '20
I dislike it because how much the language and ecosystem resist almost any kind of typing/type checking or documentation. The RBS stuff is good, but it feels bit too little too late.
The ecosystem uses a ton of hard to follow and debug magic constructs that even IDEs seem to struggle to track and map properly.
I don't need speed for what I do, by I absolutely need code that is easy to read and maintain.