Why did Python win the war with Ruby? Was it purely the math community deciding this is where we throw our weight and left Ruby the runt of the litter?
The libraries. Ruby has Rails. Python has... everything else (plus Django, so it also kinda has "a Rails"). You'll likely be using something less well-maintained and shakier if you use Ruby outside of Rails stuff, than if you'd picked Python. Python's basically the modern Perl.
Why that all happened, IDK.
I write that as someone with a soft spot for non-Rails Ruby (after much consideration and repeated encounters, I kinda hate Rails). But it's rarely the best choice, unfortunately.
I'd reckon the parent's suspicion about the scientific community is correct in that it was a large influence. When ML and deep learning blew up, the academic Python community was in a great position -- you had numpy and scipy early on (both optionally BLAS and LAPACK btw), then scikit-learn for ML, matplotlib for plotting results, open CV ports, etc. As for why Python was adopted so early by the scientific community, I'm not sure. Maybe because it was a scripting language that was also very friendly for hooking to C and Fortran?
I genuinely love Python. Not in a shallow feature-to-feature way. But deeply that it has enabled a career and provides a livelihood to me and my family. It puts bread on the table. It taught me how to program and it taught me the power of computers.
Life changing tool. No other tool in my house comes close to what computers + python has done in my life.
Oh, I like it too. It's got problems like most languages that see any actual use, but it's totally OK, even good. I didn't intend my post as a put-down of Python, so if it came off that way—whoops, not what I was going for.
It's funny, you don't hear much about the Python/Ruby war anymore. Python was more of a general purpose language and had decent web frameworks (Django and Flask primarily). Ruby's main claim to fame was, and still is, Rails. Rails has lost a bit of steam over the years, partly due to node.js and the microservice revolution, so to speak. If anything, Sinatra is a better fit for microservices and yes, sure microservices aren't a perfect fit for all use cases, but they do exist now and are reasonably popular compared to when Rails first came out.
Additionally, Python made significant inroads as a teaching/academic language and a scientific/math/ML language.
Way back in 2004, I had been using C/C++, Java and Perl and was ready for something new and useful. I'd heard about Ruby and Python at that point and tried both. Ruby felt too much like Perl for my tastes (no surprise, it's kind of like OO Perl) and while I didn't love the significant whitespace in Python, it just looked cleaner and simpler to me.
I have been using Python off and on ever since. I have worked with Ruby a bit as well. What's funny is that they are fairly similar and I've long argued that the two language communities would be better and stronger if they "joined forces".
But of course people have strong opinions about programming languages. Myself personally, I like Python a lot more than Ruby, but I've been using Go for a few years now and it's my current language of choice.
True, but Python became more popular as a general purpose language. For example, Python starting shipping in most Linux distributions sometime in the late 2000s, Ruby did not.
I didn't mean to imply that Ruby isn't or can't be a general purpose language.
It was already in wide use for scientific computing by 2000, due to the comparative ease of writing interfaces to C code. The main idea was to use Python as a glue language to "steer" high-performance computing.
The Python/C API was easy to learn and use, Python's reference counts worked well for C-based objects, and it was easier to build non-trivial data structures than Perl or Tcl, which were its two main competitors at the time.
(Tcl extensions required manual garbage cleanup, I remember Perl's extension API as being rather complex, and I had to read the Advanced Perl manual to understand something as simple as having a list of dictionaries.)
> Python works around it by having so many libraries built in C or C++.
Which works quite fine, until it doesn't.
By than the needed rewrite in some language that delivers decent performance and safety all over the place in one package will be very expensive.
I'm not saying that you should avoid Python (and its native code kludge) altogether but when using it just pray that you never reach that point mentioned above. It's a dead end and will likely require an almost full rewrite of a grown, business critical (and already heavily optimized) application.
Prototyping in Python, then rewriting the performance critical parts in a speedier more difficult language is one of the most efficient paths a project could take.
I knew Python decently well before I ever played with Ruby.
Ruby to me feels like a very ugly version of Python. It's like Python and Perl had a baby, and I have very strong negative opinions of Perl's syntax. It baffles me how a language that people jokingly refer to as a "write-only" language ever got any sort of ground.
I also think it is easier to use, period. I've used Ruby professionally since the Rails 1 days, and still program in it most days. A couple of years ago, while working at an AI company, I helped out on an ML project due to a time crunch, and I needed to use Python to contribute. I wasn't asked to do anything ML-specific, but rather help by building out infrastructure and data processing pipelines, i.e. the stuff that used the ML models.
I'd never used Python before but within a couple of hours I was writing code and in less than a week I'd engineered a pretty slick, very robust pipeline. I was quite honestly fairly astonished at how quickly I became productive in the language.
I could be wrong about this (my experience with Python started and stopped in that one week) but the impression I got was that Python is smaller, more constrained (i.e. fewer ways to do the same thing), and syntactically less complex.
Python is easier to use if you come from almost any background, programming or not. I believe this is primarily b/c there isn't a lot of "special syntax" in Python, it's all very explicit and common. The same is not true with Ruby.
Could you point out specific parts of python that are easier for someone with C/C++ background as opposed to Ruby? I remember starting with Ruby (after rudimentary CS50-level C), and finding it quite reasonable and logical, and nicer than python. I still think it's nicer than python, although I've long since stopped using it.
I believe the issue isn't so much "vanilla python" vs "vanilla ruby" for a developer coming from a C background but rather that ruby's programming style leads to a significant bit of meta programming which (aside from being a bit of a challenge to get one's head around) leads various shops and frameworks having built their own DSL for writing ruby.
Open classes give me the security heebie jeebies.
irb(main):001:0> "foo".bar
(irb):1:in `<main>': undefined method `bar' for "foo":String (NoMethodError)
from /usr/local/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from /usr/local/bin/irb:25:in `load'
from /usr/local/bin/irb:25:in `<main>'
irb(main):002:1* class String
irb(main):003:2* def bar
irb(main):004:2* "foobar!"
irb(main):005:1* end
irb(main):006:0> end
=> :bar
irb(main):007:0> "foo".bar
=> "foobar!"
irb(main):008:0>
On one hand, that's really neat. On the other hand, the ability to add or modify a method in a system class is not something that I'd want near production code. I'm sure that other orgs have sufficient checks and style guide to prevent something from creeping in... but that sort of flexibility in the language is something that I'd prefer to stay away from if I want to be able to reason about ruby code.
See also Ruby Conf 2011 Keeping Ruby Reasonable by Joshua Ballanco https://youtu.be/vbX5BVCKiNs which gets into first class environments and closures.
Why that all happened, IDK.
I write that as someone with a soft spot for non-Rails Ruby (after much consideration and repeated encounters, I kinda hate Rails). But it's rarely the best choice, unfortunately.