Ruby's first release was in 1995. Go in 2009.
Bad news buddy:
https://gobyexample.com/struct-embedding
At first I loved it, then quickly realized as you did that it makes code essentially unreadable.
And the embedded struct has to be part of the struct definition, it can’t be snuck in by reopening the class and include-ing new bits.
As for disliking Rails, join the club, plenty of Ruby users dislike Rails too.
a. Yes, global mutable state is anti-functional style, side-effect-oriented, god function/object programming and it sucks.
b. The lack of an ability to seal objects, classes, and modules from further modification is a problem.
c. Ruby 3 should've broken compatibility by adding gradual typing.
d. Nonorthogonality - Too many ways to do the same thing.
e. Dying community - Too much broken code out there.
f. Ruby was "Perl5 2.0" in most senses.
For type-safer things that look like Ruby, Crystal is an almost viable, interesting alternative.
Otherwise, I have evolved past Ruby because of the learning curve for others, too many people hate it, too many maintainers have attitude/professionalism problems, and there are more supportable alternatives for most use-cases such as rust, elixir, and bash. Sometimes, it's still useful to use ruby for some quick text formatting or a quick CLI utility in the space of awk, perl, or sed. The world mostly uses js and python. One can either be a hipster with obscure tools or get things done with the lowest TCO/highest ROI.
"freeze" has been there from the very start". You can freeze objects, or individual classes and modules (because, hey, they're objects) just fine. I'm all for freezing more stuff, and the migration towards freezing string literals was good, and you can freeze very aggressively in your own code, including system classes.
> c. Ruby 3 should've broken compatibility by adding gradual typing.
If they had, it would've split the community. Some of us would've forked it. Any degree of gradual typing in Ruby will need to be extremely cautiously approached and/or mostly optional, as it strikes at the heart of what makes Ruby what it is. There are places it would work and be fine, and there are places where it would massively hamper productivity.
> For type-safer things that look like Ruby, Crystal is an almost viable, interesting alternative.
Crystal has a fraction of the community and too many pointless differences to Ruby for many of us to consider.
> The world mostly uses js and python. One can either be a hipster with obscure tools or get things done with the lowest TCO/highest ROI.
Funny. My career has spanned multiple "the world mostly uses $language" phases, and it's never affected my TCO/ROI whether what I've happened to use matches the current $language. What has mattered is picking a language the right libraries are available for and that I'm comfortable in. Sometimes I only get one of those, and sometimes that means picking a different language the Ruby, but writing composable tools means it's quite rare, and each time makes it rarer.
Here's a challenge: in the Gitlab source code, tell me where `external_file_project_job_artifacts_path` is defined. It's referenced in a few places but it isn't defined anywhere.
And yes I know in other languages you can use codegen to construct unsearchable identifiers in the same way, but Ruby seems to actively encourage it.
Those are some pretty clean routes!
Because of that a lot of people still have major bad practices set in their heads such as a method shouldn't be longer than 5 lines etc.
Most rails code bases that I have seen usually has had a senior ruby lover refactor things in such a way that one thing is always calling another thing and even though the actual working business logic might be 12 lines which should have been linearly written, is spread across 5 files with objects being new'd up everywhere making it really hard to follow.
salary = 100
bonus = 10
total = (bonus
+ salary)
=> 100
Argh. The real example was more complex but you get the idea. Lint/Void: Variable bonus used in void context.
Web search for 'ruby void context' finds a bunch of WTFs.99% of the time when I get air dropped on a big piece of non-rails ruby software it's going to 1. be a headache and 2. earn me a tremendous number of billable hours trying to fix it.
A lot of dev/consulting shops that popped up after the advent of Rails began using it for absolutely everything and none of them knew what they were doing architecturally.
Agreed 100%. This practice pushed me out into Rust/Go and I don't see myself returning unless corrections are made.
I strongly believe Shopify, Stripe, Rails need to come together and eradicate this blight from the ecosystem if they wish to see new adoption. No other ecosystem finds this acceptable behavior and is actively discouraged.
It's not necessarily the language itself, which is a reasonable language, it's the patterns that are common in the ecosystem:
1. Use of inheritance for code sharing. It makes it extremely hard to reason about any piece of code I am looking at. Where does the `param` variable come from? Is it injected by any ancestors of the class I'm looking at? Who knows, I have to use the debugger to find out. I cannot reason about the code without it. Of course you can use Ruby while preferring composition over inheritance, it's just rarely done by the community. Other modern languages like Go and Rust wisely leave out inheritance for code sharing in their object model and arguably have much more readable (albeit verbose) code.
2. Global mutable state is everywhere. Not sure if it's Rails architecture that encouraged using global state as request local state (until they found out that this makes concurrency hard), but Ruby codebases are full of global mutable state. It's everywhere and again makes it hard to reason about dependencies between objects and how they interact with each other. Again, this is nothing that the language forces people to do, it's conventions.
3. Overuse of meta programming. Ruby's metaprogramming is really well done in my opinion. The problem is that lots of people want to use it and do so in places where it doesn't provide enough value to justify the costs. It's an authentication library. It doesn't need it's own DSL.