Ruby might be better than Python for new learners
ronynn.github.io
ronynn.github.io
https://github.com/ronynn/ronynn.github.io/commit/f1bc45de82...
The syntax is more elegant. Well yes, but that’s also subjective. Also, the argument doesn’t help LISP to be more popular either.
The indentation argument is old and in my opinion hypocritical (yaml, sass, haml). Also, not getting code you copy and paste from the net to work because of syntax errors based on indentation is the least of the problems in copy and pasting code from the internet.
Selling the larger and more diverse library ecosystem of Python as an advantage for Ruby rather funny. Ruby has good libraries for the web and enough for *NIX scripting but I do wish we had some more stuff to keep up with Python when it comes to math, scientific computing and ML.
I have more fun writing Ruby and that is one of the main reasons I use it. And I think it is an easy enough programming language for a somewhat experienced programmer to pick up. DSLs, meta programming and some other advanced concepts are easy enough to pick up in Ruby and you can figure out the pros and cons for your self quickly. We still have a tradition of fun and quirky projects being done in Ruby. There is a gem to create your own card games and a video on YouTube about somebody building an agi upscaler, that code is in ruby.
My sales pitch would be: “Come join us, we are fun and a bit weird, just like our language. We are also fun at parties!”
Python's "there should be 1 obvious solution to any problem" culture is way better at scale than Ruby's "there should be 5 subtly different solutions to every problem". I hate the distinction between blocks, procs, and lambdas. Ruby's support for both `...` and `..` likewise does more harm than good. That extra period can be easy to miss while scanning code and we all know how much more important readability is than writability. I also don't like the difficulty to distinguish "magic" references from real ones, unlike in Python where all the magic references have double underscores. It once took me a half hour just to figure out why this seemingly normal method called `method_missing` was being invoked when it seemed like it shouldn't (this codebase was so large and classes had so many ancestors / mixins that finding method definitions was generally a problem. I also don't like mixins btw, or inheritance for that matter, but having 1 is better than having both).
I would discourage anybody from learning Ruby for the simple reason that large Ruby codebases are a scourge to our profession. Small Ruby codebases may be fine, and large Python codebases aren't great either, but I much prefer the language that minimizes all the weird gotchas.
And method_missing is a such fundamental part of the language, that it obvious you skipped basic docs on the language. Besides that, there're not many "magic references". Unlike in python, btw, where "there should be 1 obvious solution to any problem" mantra doesn't hold for a veeery long time.
C is generally not considered to be strongly typed but Ruby is. i.e. types aren't automatically coerced at runtime in Ruby.
Comments here say the article is a hack job, so I didn’t read it. That said, I don’t think it’s likely that either language is necessarily better for beginners (and I admit that I base that on nothing but my gut). But non-beginners are probably better suited to whichever more closely resembles whatever they’ve been comfortable with in the past.
Also, with the rise of LLM code generation for jobs like webdev, I get the feeling that lower-level programming skills are going to be increasing valuable for one's programming career.
The hard parts for beginners are identical -- e.g. for loops, functions, and finding the motivation to consistently practice.
Since then I’ve returned to Python for some projects and I find that Python made me better at Ruby and Ruby made me better at Python. JavaScript, Ruby and Python are my main goto languages for scripting and web programming and I think Ruby is getting the short end of the three languages. It deserves better and I think more people, especially web developers and people that need a *NIX scripting language should give it a try.
What I don’t really understand is that we (Ruby programmers) still use indentation for block definition as a reason against Python. Especially since yaml, haml and sass are technologies we helped build and popularize and they are all indentation based. I still agree that Python is the less elegant and more importantly the less fun language.
Pythonistas generally consider that a misfeature.
Main power of blocks is not being multiline or being closure-like, many languages have this. But blocks are not just anonymous functions or lambdas, they have ability to return from the outer method (or from the method to which it was passed with break), acting as a powerful tool for creating your own flow control structures if needed, or just replacing "for". Of the languages I know or heard of only smalltalk does the same.
You can live without those, you can live even without early return, but blocks are not a misfeature, it's a great and intuitive tool. And python's rudimentary lambdas make me cry a little.
The article was written by an LLM[1], not a Ruby programmer.