Ruby and Python are recognised as two of the most used and popular languages out there with continuous growth each day. Both updated regularly and if you name it then there's likely a library, API or something made for your usage. But as Ruby grows so does it's user count, will Ruby become more popular than Python?
Quick disclosure: I'll look at some of the major aspects of each language, but will not be looking at APIs, libraries etc unless it's specific to that topic.
History
Before comparing anything I believe it's always important to look at history. Python invented in 1991 by Guido Van Rossum and Ruby invented in 1995 by Yukihiro Matsumoto are now two of the top 10 languages in the world. Ruby is intensively used in some of your favourite websites, Twitter, Github, Airbnb and even Dev.to. Python as well used in Google, YouTube and Dropbox. There's no doubt about it that since their inceptions they have changed the development industry.
Syntax
We all know that the syntax of a language is essential to a programmer, some people like Java syntax, some like Python heck some people like Brainfuck.
Ruby is designed to be a flexible and empowering language however the flexibility can cause some problems. The magic that makes Ruby when you never expect it can also make it a pain to track down bugs resulting in hours and combing through code while combing through your hair.
Example of Ruby's syntax
def hello_world()
puts 'Hello world'
name = gets.chomp
puts = "Hi #{name}"
end
Python, on the other hand, is designed to be a more simpler approach with indentation instead of curly brackets or keywords. The goal is to make everything visible to the developer and in some sense, it sacrifices some of the elegance that Ruby has to give.
Example of Python's syntax
def hello_world()
print('Hello world')
name = input('Enter your name')
print(f'Hello {name}')
Web development
Seeing as there are a lot of web developers here at Dev.to it'd be stupid not to talk about web development. There are two main frameworks for both languages. For Ruby rails is by far the most popular, with Python there are two depending on what the end goal is which are Django and Flask. For this, I'll be using Django as the comparison. Lets look at the pros and cons...this was hard to determine in some area.
Rails pros
- Faster to spin up new projects
- Less code to make everything happen
- Larger rails community
- Easier migration
- Incredibly easy to deploy
Rails cons
- Can become bloated - Rails is bundled with a bit of unnecessary code, less senior developers may not understand it
- If you need to bundle data analysis, big data functionality then Ruby wouldn't be the place to go
- Less code conventions to follow, sometimes code works and it's hard to know why
Django pros
- Tighter syntax
- Ships with comprehensive portal premade on setup
- Strong middleware layers
- Djangos REST framework is one of the best out there
- Scalable caching system
Django cons
- Isn't asynchronous by default
- Really overkill for smaller projects
- Everything gets deployed together
I won't comment on which is better as I'm newer to Rails/Ruby than Django/Python however from researching both they clearly have their merits and cons. If you're looking for something to use for a website then either of these will work perfectly for your website, but always dependant on the needs of the site.
Community
Both Ruby and Python have substantial communities behind them all over the place, forums, slack groups, discord servers etc wherever you look you will find an active community that is here to help and guide you. Each of the communities are influenced by the direction of the language and the software built behind it.
Python has a much broader community than Ruby does. Both languages have a ton of academic use cases in both math, science, programming etc. But this doesn't mean Rubys community is at a stand still, it's a language that continues to grow each day.
Ruby's popularity really kicked off when Rails came along in 2005, the community fell in love with and has been incredibly focused on web development. In addition it's diversity is still growing at a rapid pase.
Cybersecurity/Pen testing
Both Python and Ruby are highly used for cybersecurity, sec ops and pen testing with humungous communities behind them. Wherever you look on this topic you'll find what you're looking for, for example Ruby has Metasploit developed by Rapid7 one of the most used tools in pen testing with Python having Nmap and Scapy. Both developed and used on a daily basis.
Python pros
- High performance
- Extensive support
- Wherever you look you'll find what you need
- User-friendly data structuring
Python cons
- Bundling the libraries and tools together can be a pain in the ass
- Some of the libraries/tools are paid
- Often Python version specific
Ruby pros
- Nicer syntax
- A lot of what's required is built into its standard lib and language (mutable strings, fragmentation etc)
- Highly scalable
Ruby cons
- Smaller community
- Some of the libraries/APIs required are no longer maintained
- Some companies don't use it so if you're going in as the only one good luck.
Package management
Both Python and Ruby have incredible package managers. Neither of them can be faulted with Rubys RubyGem and Bundlr and for Python having Pip(3) and Anaconda both of them do an incredible job of installing, maintaining and finding packages that are required. Whichever language you look at you won't be disappointed with them.
Personal opinions
Both are exceptional languages, which like every other language have their pros and cons. As someone who has written Python a lot more than Ruby and is now learning Ruby extensively I can say with a slight margin I'm starting to like Ruby more than Python. The syntax, flexibility and capabilities are beyond my beliefs, it has turned out to be a fantastic language and now really starting to see why people love Ruby so much.
Conclusion
Will Ruby kill Python? In my opinion no. It's always going to be dependant on the end use case and the developer some people will always prefer X over Y because of personal preference but the way I see it is that Ruby will continue to grow alongside Python but Ruby will be more looked at for web development using Rails over Django/Flask, we can't predict the future but both of them are already incredible languages and will continue to grow as they go on.
What do you think?
EDIT: Changed the title
Top comments (24)
I like Ruby, I like Ruby on Rails, and I like comparing Python to Ruby, but it's common knowledge that Python is growing at a faster rate than Ruby. I don't think the title of the piece serves your content.
I find that the more specific my titles are to my content, the better results I get on my articles on this site.
Yeah, nice post—probably the wrong title.
Ruby and Python are similar languages but have found pretty different niches. Rails is probably more of a runaway success than Django, but Python is growing in popularity in areas that Ruby isn't even playing in.
Both exciting languages, I've always been drawn more towards Ruby but the Python community is constantly amazing me with the things people are building.
I prefer ruby over python but I was of the impression that Python might kill off ruby
Honestly I don't believe Python will kill Ruby, it's clear that it has a much larger gathering but with the state Rubys language, APIs, communities etc are in I believe it could be catching up to Python
Yeah, in the enterprise sphere I run in (silicon valley adjacent) rails is pretty much gone and replaced with react frontends and kube/serverless backends for new projects.
The java stuff has stayed steady, but I’m seeing more and more javascript from the new projects.
Python lives because of ML and ops now. Python 2 becomes EOL in 2020, and most projects have finished their conversion years ago.
Ruby... has metasploit, I guess? That codebase is a bit of a mess though... a testament to “clever” ruby.
Python isn’t going anywhere, in fact its popularity is growing because of its use in machine learning.
Of course Ruby won't kill off Python. I've spent almost all of my experience using Python, and I guess Ruby and Python can each do their own unique things, but I feel like I can achieve whatever I want to do in Python.
About Ruby having a "better" syntax, that's a matter of opinion. It ultimately depends on what you like more. I don't have a problem with either of them.
Both Python and Ruby are good languages, but I see Python used more for things in general.
Ruby and Python are utilized for two different things and they can co-exist.
I really don't think Ruby has much in terms of data science compared to Python. My experience has also been that Python is better for DevOps; the libraries are better and Python tends to be installed on machines by default. I'm also seeing newer configuration management tools being written in Python.
Ruby has some really serious design flaws. I wrote about them some years ago (madhadron.com/posts/2013-02-25-a-c...), and some of them, such as not having a well defined grammar, are truly appalling. But, as JavaScript has taught us, flaws in the language are trumped by other concerns.
See the StackOverflow Developer Survey: stackoverflow.blog/2019/04/09/the-...
I'm a personal fan of Ruby and I just think it's a wonderful language. I remember reading The Ruby Programming Language cover-to-cover my senior year of college and just falling in love. Up until then I had only written lower level languages, such as C, C++, Java, Verilog, and Matlab. It was such a breath of fresh air to see a language made for programmers and not for processors.
However, here's what I recall happening:
Python focused on pragmatism and ease of use.
This led to it's adoption in the scientific community and eventually as a great First Language to Learn and eventually as a go-to scripting language and eventually as the go-to general language of choice for many.
Ruby focused on being elegant and a joy for programmers. It focused on developer speed at the cost of execution speed. This was still a contentious topic at the time. It was under the radar practically completely until Ruby on Rails came out. It was HOT. But it also kind of shoehorned Ruby into being the language to use Rails with. I do remember the Agile community particularly loving Ruby exactly because of the developer vs processor speed tradeoff mentioned before.
Python won out by gathering momentum. People want to program in languages that others are using as well because that means there are useful libraries and frameworks to help you with your problem.
Unfortunately, Ruby got married to Rails, and when giant tech companies started moving away from Rails due to scaling issues, others followed suit (even if they didn't need to and they wish they had the scaling problems Twitter did). Once Rails lost the spot as the New Hot Thing, it also lost the appeal to developers looking for a fun, shiny thing to play with.
Regardless of which "wins" I think they're both quite enjoyable to write in. They let you focus on what you really want to do with your program.
The main worry I have about the future of both languages is their viability in the future where we have fewer and fewer individual CPU-core gains and move to more cores and more servers working on problems. To that end, I've begun looking into Go and have been impressed but find some things too low-level.
So to that end, for something that blends the best of Ruby and Go, I turn my sights on the new kid on the block: Crystal
P.S. It may sound like I hop between languages often, but that's only because in my 9to5 I use Java about 99% of the time, so I use my free time to play in the way that I often can't in my day job.
So many years spent in development. Never seen any language killing another. Developers usually use wishful thinking. VB is still alive in workplace. So is java, so is C#. Rust is not killing C++. Node is not going to die after Deno. Ruby is pain on Windows. Python runs smoothly everywhere. Nobody is dying.
Personally, I don't think any language can really kill off another. C++ didn't kill C, and neither Ruby or Python are likely to replace the other. Both Ruby and Python are great scripting languages with benefits and tradeoffs.