Ruby vs. Python

4 min read

Ruby vs. Python

 

RUBY PYTHON
LANGUAGE 
  • More magical
  • Created in 1995 by Yukihiro Matsumoto
  • More Direct
  • Created in 1991 by Guido Van Rossum
PROS
  • Tons of features out of the box for web development
  • Quick to embrace new things
  • Very easy to learn
  • A diverse community with big ties to Linux and academia
CONS
  • Can be very hard to debug at times
  • Often very explicit and inelegant to read
WEB FRAMEWORKS
  • Ruby on Rails-Started in 2005 by David Heinemeier Hansson
  • Django-Started in 2003 by Adrian Holovaty and Simon Willison
COMMUNITY
  • Innovates quicker but causes more things to break
  • Very web focused
  • Very stable and diverse but innovates slower
  • Used widely in academia and Linux
USAGE
  • Apple
  • Twitter
  • Github
  • Airbnb
  • Github
  • Groupon
  • Shopify
  • Google
  • Pinterest
  • YouTube
  • Dropbox
  • National Geographic
  • The Washington Post

Which is better Ruby on Rails, or Python/Django?

This is a question we get asked repeatedly. It’s an important question too. You’ll hear Ruby vs. Python compared all the time. If you’re unfamiliar with them, it’s an impossible question to answer. I’ve used them both quite a bit and can tell you that while they’re similar, they’re also different in some important ways.

To set the stage, I first learned web development through Python and Django. After spending four years building Django apps, I got a job doing Ruby on Rails and expected the transition to be really simple. That’s when it became clear to me that the two languages and frameworks are different.

So… How are they different?

The Language:

The Ruby on Rails web framework is built using the Ruby programming language while the Django web framework is built using the Python programming language.

This is where much of difference lies. The two languages are visually similar but are worlds apart in their approaches to solving problems.

Ruby is designed to be infinitely flexible and empowering for programmers. It allows Ruby on Rails to do lots of little tricks to make an elegant web framework. This can feel even magical at times but this flexibility can be good and bad at times. Sometimes code works when you didn’t expect it to and l5eaves you feeling really impressed. Other times the Ruby magic can make it very hard to track down bugs for hours.

Python takes a more direct approach to programming. It’s main goal is to make everything obvious to the programmer. This sacrifices some of the elegance that Ruby has but gives Python a big advantage when it comes to learning to code and debugging problems.

One great example showing the difference here is working with time in your application. Imagine you want to get the time one month from this very second. Here is how you would do that in both languages

Ruby

require 'active_support/all'
new_time = 1.month.from_now

Python

from datetime import datetime
from dateutil.relativedelta import relativedelta
new_time = datetime.now() + relativedelta(months=1)

The Python version has you importing specific functionality from datetime and dateutil libraries. It’s a lot more explicit, but you can easily tell where everything comes from.

The Ruby version is a lot more magical. We import some active_support library and now all of a sudden all integers in Ruby now have these “.days” and “.from_now” methods. It reads well but it’s definitely not clear where this functionality came from inside of active_support. Plus, the idea of patching all integers in the language with new functionality is cool but it can also be abused and cause problems.

Neither approach is right or wrong, they just emphasize different things. Ruby showcases flexibility of the language while Python showcases directness and readability.

Web Frameworks

Django and Rails are both frameworks that help you to build web applications. They have similar performance because both Ruby and Python are scripting languages. Each framework provides you all the concepts from traditional MVC frameworks like models, views, controllers, and database migrations.

Each framework has differences in how you implement these features but at the core they are very similar. Python and Ruby also have lots of libraries you can use to add features to your web applications as well. Ruby has a repository called Rubygems that you can use and Python has a repository called the Package Index.

Community

Python and Ruby both have very large communities behind them. The community influences the direction of the language, updates, and the way software is built using them.

Python has a much more diverse community than Ruby does. There are a ton of academic use cases in both Math and Science that Python has thrived in. This gives it a lot of support in those areas and it continues to grow because of that momentum. Python is also installed on almost every Linux computer making it the perfect language for use on servers.

Ruby’s popularity really started when Rails came out in 2005. The community grew quickly around Rails and has since been incredibly focused on web development. As time goes on it the community around it has gotten much more diverse but it hasn’t seen the same diversity that Python has.

Usage

Who is using these languages? Quite a lot of companies. Both languages and web frameworks are pretty widespread in the tech world.

Python has been by companies including Google, Pinterest, Instagram, National Geographic, Mozilla Firefox, and the Washington Post.

Ruby has been used by companies like Apple, Twitter, Airbnb, Shopify, Github, and Groupon.

Conclusion

Anything you can do in Ruby on Rails you could also do in Python and Django. Which framework is better isn’t really a question of capability, it’s actually a question of what the support is like for you and your team.

My general rule of thumb is this:

If you plan on sticking with building web applications, then check out Ruby on Rails. There’s a very strong community built upon it and they are always on the bleeding edge.

If you are interested in building web applications but would like to learn a language that’s used more generally, check out Python and Django. You’ll get a diverse community and lots of influence and support from the various industries that it is used in.

Either way, you can’t go wrong. Almost everything you learn in Python can be translated to Ruby and vice versa. The same goes for Django and Rails. They both have supportive communities behind them. If you have friends doing one or the other, join them because you can always ask them for help along the way.

ruby vs. python


If you’re ready to learn Python? You can join over 60,000 students at One Month where we offer a 30-day Learn Python Online Bootcamp. The course is for absolute beginners, and we offer live human support for when you have questions. Ready for Ruby? One Month also has a course where you can Learn Ruby Online in 30 days

7 Replies to “Ruby vs. Python”

  1. The magic of Ruby is quite cool but when learning a first language it can indeed be confusing. Having a more transparent logical structure is definitely helpful. That being said, I abide and love your conclusion: Rails rocks for web applications!

  2. A lot of Rails’s “magic” goes away when you simply consult the documentation, literally just search for “from_now” and you’ll find the class that defines it: ActiveSupport::Duration. If something seems magic, it’s because you don’t know how it works, learn how it works.

    Choose whatever popular programming things you want, but don’t fall into the trap of feeling like you know better because you read a thinkpiece that jives with your own biases. All of these frameworks have their highs and lows especially so when real people start using what you build with them. Just choose something and BUILD SHIT, fail, improve, fail, try again, learn, learn, learn. There is no magic, there is only work to be done.

    P.S. Don’t work too much, you’ll end up losing your mind one day reading a blog post like this and ranting in the comments like an insane person.

  3. Truly Excellent Post.
    It is really helpful to self learners who learning ruby and python programming languages..
    Thank you for sharing your great knowledge with us.
    Looking forward to your further tips on similar topics Thanks…
    I really appreciate it.

  4. Hello , I like your great and amazing content , if it possible can you give me an advice about ‘ what coding language should i start learning to develop andriod apps like GROUPON APP , and DUOLINGO APP , Thanks in advance , looking forward your reply because it’s valuable for me.

Leave a Reply

Your email address will not be published. Required fields are marked *