loading...

Ruby and Python, them and the differences

rapidnerd profile image George Marr ・5 min read

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

  1. Faster to spin up new projects
  2. Less code to make everything happen
  3. Larger rails community
  4. Easier migration
  5. Incredibly easy to deploy

Rails cons

  1. Can become bloated - Rails is bundled with a bit of unnecessary code, less senior developers may not understand it
  2. If you need to bundle data analysis, big data functionality then Ruby wouldn't be the place to go
  3. Less code conventions to follow, sometimes code works and it's hard to know why

Django pros

  1. Tighter syntax
  2. Ships with comprehensive portal premade on setup
  3. Strong middleware layers
  4. Djangos REST framework is one of the best out there
  5. Scalable caching system

Django cons

  1. Isn't asynchronous by default
  2. Really overkill for smaller projects
  3. 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

  1. High performance
  2. Extensive support
  3. Wherever you look you'll find what you need
  4. User-friendly data structuring

Python cons

  1. Bundling the libraries and tools together can be a pain in the ass
  2. Some of the libraries/tools are paid
  3. Often Python version specific

Ruby pros

  1. Nicer syntax
  2. A lot of what's required is built into its standard lib and language (mutable strings, fragmentation etc)
  3. Highly scalable

Ruby cons

  1. Smaller community
  2. Some of the libraries/APIs required are no longer maintained
  3. 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

Posted on by:

rapidnerd profile

George Marr

@rapidnerd

My curiosity is easily stimulated

Discussion

markdown guide
 

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.

 

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 and Python are utilized for two different things and they can co-exist.

 

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-...

Python, the fastest-growing major programming language, has risen in the ranks of programming languages in our survey yet again, edging out Java this year and standing as the second most loved language (behind Rust).

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.

 

I think that was a nice article with a terrible title. It could have been "Here's a comparison of Ruby and Python" or you could have kept it the same but started the first sentence with "In my opinion no, ".

That's the definition of click bait, and people who make click bait, are going to burn in the fiery pits hell, as stated in the second edition of the internet hand book chapter 24 page 357. Good day to you George

 

I don't think that ruby will be ever popular as python is. By my opinion python is ruby killing.

 

Somebody mentioned Stack Overflow survey above, there's also Tiobe and Pypl rankings and they all show the same thing: python is on the rise while Ruby is in decline.
However, standard caveats regarding flaws associated with their significance and "correlation is not causation" apply.
Me personally? Let's just say I wouldn't bet on Ruby.

 
 

Cons.

Some companies don't use it so if you're going in as the only one good luck.

Is there a single language this isn't true for?

 

I continue to be baffled.

I just don't see Ruby's usage growing, I would be surprised if they were not shrinking, and that is from a Worldwide perspective. The only places it is continued to be used is mainly US / Japan and UK. And I did argue even in those places the jobs are shrinking as well. They are mostly looking for senior developers to pick up the mess they started with Rails. Statistically Ruby is ~90% Rails, with the rest spilt between Chef, Other Web Framework, and Security uses. All the Ruby Jobs in South Korea, China, Taiwan, India are mostly gone. DHH is right about developers being expensive and Server is comparatively cheap, but where in other parts of the world you can hire a whole team of dev with the same budget of one in Silicon Valley. ( Ok the quality aren't the same but you get the idea. )

Ruby and Rails as community needs to grow. I recently had a conversation with a Ruby developers in China, he said the love of Ruby does not feed you. At the end of the day you need companies willing to use and trust Ruby, more demand, and hopefully more supply. He is now doing Python and Java at work. Enterprise that originally used Ruby are also considering moving away. And that is a worrying sign. Just like the economy, you don't see the collapse until it happens. It just wish we could do something before it is too late.

 

The popularity of programming languages is very regional. I'm in the Phoenix area and so it's a bit of a head-scratcher to hear that Ruby is "popular". Around here Ruby on Rails completely died out around 2013/2014 and the only time your hear about companies using Ruby (that aren't geographically distributed teams) is if the company is using Chef. Whereas Java and .NET are (annoyingly) over-popular, but I've been told that the popularity of .NET diminishes when compared to the bay area.

Four years ago I was trying to join a team that is geographically distributed and the hiring manager mentioned he feels like he can almost tell where someone is located based on the technologies listed on their resume. He volunteered the difference in popularity between Matlab and R as being night and day between San Francisco and Dallas (where he is located).

Devs that I've worked with who are based out of Atlanta I've noticed are significantly more familiar with Ruby, and JavaScript libraries that "feel" very Ruby-like, such as Ember and Coffeescript (libraries that I've never yet seen in a front-end requirements list for a job in the Phoenix area).

So yeah, I think Ruby's popularity may be dependent on your geographical vantage point.

 

I think I just read a not so well put together article. I don't like this comparison at all. Superficial statements and no facts.

"Incredibly easy to deploy"
And Django not? Why?

"Scalable caching system?"
And Rails caching is not scalable why?

"Really overkill for smaller projects"
And Rails not? Why?

"Everything gets deployed together?"
And in Rails not?

Plus the sh*t title that does not make any sense either..... since you compare web frameworks and not languages, not to mention Python being around 10x more popular.

 

I'm honsetly surprised that Ruby didn't die on its own until now. 😂

But from what I read it seems like the community is simply super inviting and friendly.

 

"...some people like Brainfuck...." Those people are called sadists.

 

I don't think any language will really kill off any other language, and I don't really understand why there would be any competition between them.