| [ Web Proxy ] |
| Viewing: https://stackify.com/ruby-vs-python/ | [Back] [Original] |
[Comparison: Ruby vs. Python] Around 1996, when I attended my first programming classes, C++ was the language of choice if you wanted to have a job in this industry. The Internet was young and not as widely available as it is now. Ruby and Python were still in their infancy.
Now, in 2018, both have evolved and matured well enough to be in the top 10 most in-demand programming languages. In this article, Im going to highlight features and contrasts between Python and Ruby.
Lets start by listing similarities and differences between the two languages.
Ruby is common in organizations that create web applications. Programming with Ruby on Rails allows teams to rapidly develop and focus on business processes instead of coding functions from scratch. Rails provides an elegant modelviewcontroller (MVC) structure, so you can strictly separate your data, user interface, and business functions. Further down the stack, the configuration management software Chef is written in Ruby. So if you need to create a new Chef module, it would be in Ruby.
Django is Pythons most popular MVC framework, but Python is also famous beyond the domain of web applications. An example is the Pandas library, which is useful for data munging and preparation, along with other math libraries such as stats-model and numpy. TensorFlow is popular for machine learning tasks, and Matplotlib is powerful for data visualization. Also worth mentioning is SciPy, which has resources to solve math functions that used to make engineering students sweat.
In this aspect, Ruby has inherited Perls philosophy: Theres more than one way to do it. So, you will always find many different methods to achieve a task in Ruby. Depending on whos writing the code, this might lead to unnecessary complexity and obfuscation.
On the other hand, Python follows an approach where simplicity has more value than complexity (see The Zen of Python). Hence, its philosophy is, There should be oneand preferably only oneobvious way to do it. So, although Python code probably wont be the most flexible, it has a good chance of being more readable to an inexperienced programmer.
Looking at Octoverse 2018 from GitHub, we can see Rubys use slowly decaying in the top 10 languages, from fifth place in 2014 to tenth place in 2018. However, Python has steadily kept its popularity, moving from the fourth most used language in 2014 up to the third spot in 2015, where it remained through 2018.
Lets check out job offers as another criterion: searching remote jobs at Stack Overflow returns around twice as many results when you search for Python instead of Ruby. If you prefer LinkedIn, Python leads by 20% over Ruby. Therefore, if you want a skill set in high demand, Python should be your choice. On the other hand, if you prefer a niche job with higher pay, in the long run, Ruby shows a better salary range at PayScale in the U.S. market.
Publicly available and ready-to-use code is a relevant factor when you need to decide on a programming language. Python calls them modules, and theyre available via PyPI, where you can search more than 150,000 modules. On the other hand, reusable code in Ruby is called Gems, and there are close to 150,000 gems. But the differentiating factor is filtering; PyPI allows filtering by categories like development status, which is more straightforward than comparing many libraries and manually evaluating their code.
When it comes to packaging and automatic dependency resolution, both systems offer painless installation of dependencies in your environment. An advantage on the Python side is how virtualenv enables you to isolate different versions of the Python interpreter. Ruby has a similar feature throughrbenv or rvm, but I found this a bit cumbersome. You can gauge this better considering your particular case and how much reusable code there is for your purpose.
I wont beat around the bush here: Python is hands-down quicker to learn. The syntax is easier to understand, and its more readable to the beginner. But beyond that, youre going to need to make decisions on what framework to use beyond bare-bones Python.
Ruby might take more time to get used to, but Ruby on Rails has built-in featureslike scaffolding and Active Recordto accelerate your development. As soon as you know them, youll be able to build a CRUD application with API access in a matter of minutes.
Take a few minutes to answer these questions:
Your answers will determine who is going to operate, contribute to, and maintain this code in the long term. You need to decide how convenient each language is, depending on these answers and your plans with this code youre going to develop.
Testing code as early as possible is important, even more since we learned how shift-left increases teams performance. Thats why test-driven development (TDD) is one strategy you could use to your advantage. AlthoughPyTest and unittestexist, Ive not been able to find a mature framework for behavior-driven development (BDD) in Python. RSpec has this role in Ruby, andbehave seems to follow suit, but it doesnt look as mature as RSpec.
When it comes to troubleshooting and tracing, both languages have capable toolsets, but as an operator, I need to recognize that reading errors are more evident than the unforgiving stack traces in Ruby. Theres another learning curve thats not obvious to most decision makers. However, if you want to close that gap,Stackifys Retrace is starting to support Ruby and will start supporting Python in Q1 of 2019.
I didnt include performance as a deciding factor for several reasons:
I hope these guidelines allow you to make a well-informed decision, either for your career path or for that project you want to start.
In conclusion, I dont think youd make a bad choice picking Python in most cases. But if youre going to build a web application with minimum time to market, and your team already knows Ruby, then Ruby is the way to go.
Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.
| Web Proxy Viewer | New URL | Original Page |