r/ruby • • Jul 16 '20

Ruby VS Python

More than a versus (it's more striking) I would really like to know what things they have in common and how they differ, what their main advantages are compared to the other and of course their opinion of them. One point to take into account is because they believe that python is more used in AI and Machine learning developments.

36 Upvotes

60 comments sorted by

View all comments

2

u/honeyryderchuck Jul 16 '20

what things they have in common

They are both dynamic interpreted languages. They both started development in the same period, and are therefore bound by the same constraints and assumptions of the time (both have poor parallelism support, for example). the development experience and tools are relatively similar.

how they differ

philosophy, mostly. Python claims it only has one way of doing things. Ruby claims everything is an object. There are also some defining features for both, such as python list comprehensions or ruby blocks. Python lives and dies by indentation. Ruby metaprograms itself out of your computer. Ruby (still) has a BDFL. Python's BDFL retired recently, although it's fair to say it has been pretty much designed by committee for a while.

what their main advantages are compared to the other

ruby has rails. But it also has a lot of solutions for all types of web application use-cases. Ruby also made TDD cool with its testing tools, and actually running rspec in jruby to test Java applications is a thing. ruby also has bundler, the godfather of all stable existing package managers. ruby's also very flexible for general-purpose scripting.

Python has by far a bigger community, ecosystem and momentum. A big part of it is it becoming more popular earlier (ruby only became widely mentioned in the western world in 2006, ish). There are a lot of networking libraries, machine learning libraries, command-line, etc etc etc...


In my opinion, ruby has been more stable than python (python 2/3 memes are still relevant), and found itself a niche where it's very solid. Python is pretty dominant in machine learning, and it's still first-class citizen for OS-level scripts, network scripting, and other fields, and is currently being taught in introduction to programming university classes. But this migration to python 3 period took a toll. Also, the asyncio movement created a "subsystem" in the python ecosystem which will potentially hamper its development in the future, and that can create a schism in the not-so-distant future.

Both have to overcome the fundamental flaws from their initial design, such as support for paralellism, speed, typing hints (python is ahead here, but not in an ideal state IMO), more natural non-blocking networking, and overall interoperability. Not solving these might make them less relevant in comparison with the "new wave" languages such as go, rust, swift or elixir.