Ruby vs. Python

Toptal freelance experts Damir Zekic and Amar Sahinovic argue the merits of Ruby versus Python, covering everything from speed to performance. Listen to the podcast and weigh in by voting on the superior language and commenting in the thread below.

Voting results

Debate comments

Top comments first
Sort comments by:
RubyRuby Logo
Extremely powerful, extremely readable. great community and tools.
Reply • over 1 year ago from Mark allen
PythonPython Logo
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Reply • over 1 year ago from Doğan Çeçen
RubyRuby Logo
More readable
Reply • over 1 year ago from Konstantin
PythonPython Logo
Broader community, platform ubiquity, amount of libraries, code legibility
Reply • over 1 year ago from Marcelo Gonçalves
RubyRuby Logo
Superior support for OOP, metaprogramming and because of the best web framework on earth: Ruby on Rails
Reply • over 1 year ago from Michal Hantl
PythonPython Logo
Clean, understandable code.
Reply • over 1 year ago from joe bloggs
PythonPython Logo
so much to say...
- functional programing is great...
- so much out-of-box
- awesome libraries from awesome community (like numpy or Scipy etc...)
Reply • over 1 year ago from Norman
RubyRuby Logo
Programmer friendly. Expressive DSLs. Awesome community. Fun.
Reply • over 1 year ago from Lenart
RubyRuby Logo
Beautiful syntax and easy to read
Reply • over 1 year ago from julio cesar villalba
RubyRuby Logo
I like Ruby
Reply • over 1 year ago from Vijay Kumar Verm
Load More
Ruby Logo
Ruby vs. Python - Looks like the big snake bit off more than it could chew
Tweet about Ruby
Python Logo
Ruby vs. Python - Python seems to be collecting gems for its personal collection
Tweet about Python

Debate transcript

Host (Eqbal): Hello everyone, and welcome to the Toptal broadcast. I’m your host, Eqbal, and today we’re going to discuss Ruby and Python, including their differences and the main things they share. We have two super awesome engineers here today: First, we have Amar. Amar is a Ruby-ist by day and Python-ist by night. Welcome Amar.

Amar: Glad to be here, hi!

H: Thanks. We also have Damir. Damir is a Ruby ninja. He’s adopted by two cats. Thanks for joining.

Damir: You’re welcome, I’m very happy to be here.

H: Amar, it seems that you have great experience with both Ruby and Python. Maybe you can tell us more about the similarities between the two languages, their heritages, and the philosophies they share.

A: Well, for the last couple of years, I’ve been working with Ruby and Python, about the same amount of work with each of them, and I’m working together with Damir on two projects involving Ruby on Rails and Ruby.

As far as languages go, the biggest difference in the two languages itself is the syntax, especially the significant white space in Python and an obvious way to do things, while in Ruby it’s made to make programmers happy, so everyone has their own way of doing things and there is usually more than one way to do something.

H: Well, that’s a very interesting thing, actually I would like to interrupt you, because I keep hearing the same thing you just said which is that you can do it in one way in Python, while you can do the same thing in multiple ways in Ruby.

What’s your thought on this, what do you think is the better approach? You know it’s always confusing when I hear such a thing, I don’t know which is supposed to be better: to do one thing in more than one way or the opposite.

A: I don’t think there is a better way. Either way is the better way because there are people who like obvious things, how something should be done and they like that, and there are people who like to do things differently.

And I don’t think that either way is better than the other, so it depends on the user who is using the languages.

H: True. I mean, it could be easier for maintenance at least if you do it in one way for the next developer. I’m just assuming, since I don’t have a long experience with Python myself.

A: Yeah, that’s one of the advantages, because if you are writing Pythonic code, when you get into the new code base, and when you see things you know, you can assume how things are weighed out. You can recognize patterns that are used in various Python programs so it can be easier to go into the code base and get familiar with it quicker.

H: I see, sounds cool, fair enough. How about you, how about you Damir, what’s your thoughts on that. What do you think are the main similarities between both languages? I keep hearing that both are dynamic languages, maybe you can share your thoughts on both the languages and what they have in common.

D: Well, both of the languages are kind of “let’s do things that we can do in Perl today”. That was the thinking like ten years ago, let’s make a language that allows us to do everything we can do in Perl, but with more understandable syntax.

H: I see.

D: I mean python is not really an offspring of Perl, Ruby actually is, but you know both languages actually can replace Perl at almost anything.

H: So it’s like both of the languages are productive and in some ways like both you can assure productivity using both languages, right?

D: Yeah definitely, definitely and you can do all the tasks that people used Perl for before. You can script things on your computer, you can write web applications, you can basically do anything, you just need a framework, or an environment, or a tool to help you put your language to appropriate use.

And definitely both increase productivity when compared to Java, compared to C++.

H: I see. I think you’re totally right actually from my experience with Ruby. I find that it’s more productive, at least compared to Java somehow. You know, on the same subject here, what are your thoughts on the performance if we compared both, C implementation to be more specific about one implementation.

If you compare Ruby, C implementation on Python, and C implementation. Would you notice a huge difference regarding performance at least?

D: No, I don’t think there would be a significant performance difference in Python and Ruby. I mean of course maybe one language would be better on one benchmark, and some other benchmark would show that the other language is better, but those are just some synthetic results, in practice both have approximately the same run time.

Both have evolved over many years, and I think they are at a very good stage right now with very powerful virtual machines behind them.

H: I see, that’s interesting. Amar, what do you think about the garbage collector in both the languages? I assume that both have their own implementation of the garbage collector?

What would you consider more advanced or what would you consider more efficient, if any? I’m just trying to provoke you here, it’s a Ruby vs. Python thing so feel free.

A: I’m not really sure about difference or what kind of garbage collector was implemented in Ruby. But I don’t think that, while I was developing in Python, I didn’t even really think about the garbage collector.

H: I see.

A: Same with Ruby, because it handles things for you in the background, and to be honest I didn’t really need to think about it while I was working, whether it was a one-time script in Python or it was web application, for example with Django or something more complex. It’s the same with Ruby and Ruby on Rails that I have experience with.

So, I didn’t notice any significant differences, and I haven’t really thought about it while working with those languages because you don’t have to really worry that much about reusing memory or allocating stuff manually, so it’s done for you.

H: That’s cool, that’s awesome.

D: Yeah, and I’m sorry to interrupt, but those garbage collectors are also improving all the time. I’m not sure about Python, but I know that in Ruby we are getting constant garbage collector updates and improvements in every new significant Ruby release.

For example, there was a huge problem with Ruby before 2.2 that symbols as a data type were not garbage collected, which actually introduced problems when working with Rails, because Rails had to make some work arounds to make sure it doesn’t create too many symbols because they would never get garbage collected and it could enable denial of service attacks on web applications created with Rails. So now, with Ruby 2.2 there is actually an improvement for all Rubyists, and especially those using Rails because many things will be simplified.

H: Well actually this is very interesting, what you just mentioned, and especially with the examples I’ve faced myself recently.

You’re absolutely right actually, I checked out the leaks update, it’s about the symbol and we couldn’t garbage collect the symbol, especially if you create a lot of symbols that’s a very interesting subject. I would like to get back to you Amar, on the frameworks. You just mentioned Ruby on Rails and Django and the celebrity for both Ruby and Python in web development. Would you mention more frameworks, especially with Python, not necessarily specialized to web development but trendy frameworks. I would like to know more about Python frameworks.

A: Well, I’ll start with web frameworks because you know primarily I’ve been a web developer so I’m most familiar with that. As far as frameworks in Python, the most famous one is Django, which is a full stack framework, and you have a couple of other full stack frameworks, like I think Pyramid is the second most famous full stack framework and another one that is very famous is Flask, which is basically a micro framework for people who don’t like the “batteries included” that Django provides. You can use Flask; it has a very small footprint and you have a bunch of extensions you can integrate, but it’s pretty much just a micro fiber.

H: So it is like Sinatra or Ruby?

A: Yeah, Rails, Django, Sinatra, and Flask.

H: Awesome. What would you consider to be not a mature framework, but like a new framework that you consider is worth checking out at least.

A: I don’t have much experience with other frameworks, mostly with Django and Flask. As far as other frameworks, I know there are wrappers for QT, GTK, and stuff like that, for the rest of development if you want that, but I don’t have really much experience in that area, so I can’t really recommend something. I know there is a framework called Kiwi, I just need to find the time to investigate a bit further.

H: Well, that’s very interesting actually, I’ll check it out. How about you Damir? I’m sure that you have more to say here about frameworks, with the recent boom of a lot of frameworks from the Ruby community. It would be great if we can mention some of the cool frameworks.

D: Well, of course. On our web front, we of course have Ruby on Rails, which is maybe one of the most important MVC frameworks today, but unfortunately for a long time that has been the only web framework for developing web applications with Ruby. Only recently we started getting new contestants. For example, there’s Lotus, which is also a RESTful MVC framework, but its architecture is a bit different and it tries to be more object-oriented than Rails. I won’t go into details with that. I would like to mention a few more frameworks, for example there’s also Volt.

H: Volt.

D: Yeah, Volt is not a RESTful MVC framework. Volt is a full stack framework that allows you to write web applications and write Ruby code that will be executed both on the server side and client side. It’s like Meteor.js, but you’re not using JavaScript, you’re using Ruby: win-win.

H: How can you write Ruby code for the front-end?

D: Yes, of course. There is Opal library.

H: I see.

D: Which basically transpiles Ruby into JavaScript so you’re writing Ruby code that will be executed, that will be transpiled into JavaScript code that executes in web browsers.

H: Awesome, just like CoffeeScript, but it’s more like a Java syntax, if I’m not mistaken.

D: No, CoffeeScript is kind of a mix between Python and Ruby, but here you’re actually just writing Ruby.

H: Ruby code, wow! That’s very interesting.

D: And that’s only on the web front of course. Then there are frameworks for creating OS6 applications, Android applications, and iOS applications of course. Actually there’s the Ruby Motion framework that enables you to write all three kinds of applications just using Ruby.

H: Well I actually got a chance to give it a try, Ruby in Motion, and it’s very nice. It’s Ruby, so it’s syntax is way better than Objective-C, codes and all.

D: Yeah, and it complies basically to the native application so you don’t even know if it’s written in Ruby or Objective- C or Swift or Java.

H: True, it’s like almost the same performance, so it’s a very cool project.

Actually, my only concern here is that introducing Swift is the only bad news for Ruby Motion.

D: I guess it’s not that bad of news because you still have many more Ruby programmers than you have Swift programmers. It is still a very new language that’s still kind of in development, whereas Ruby has been here for a very long time and you already have plenty of experienced engineers writing Ruby code for different tasks. Now, they can just use the same language to write mobile applications and they don’t have to learn new syntax and a new language that will maybe change in the next few months again.

H: You are totally right.

D: Yes, and once you learn Swift, you can’t use it anywhere else right now.

H: Yes, it’s just for your iPhone application, not even all your smartphones. It’s not a cross-platform application.

D: Yes, exactly.

H: I hear that Ruby Motion at the moment supports not just iPhone, not just iOS, but it supports Android as well.

D: Yes, Android and also writing OS6 applications, so it’s pretty cool.

H: I’m sure that you hear the same thing, especially from people using Java. They keep getting stuff like Ruby and Python, usually just for prototyping, and they don’t scale very well, and I would love to know what you think of it. Right now I’m sure that there are a lot of big companies with some enterprise projects using Python and Ruby. Do you still think that Ruby and Python are not mature enough for an enterprise project if they don’t scale? I would love to hear your thoughts here.

A: Well, I think if you consider the sites that are using either Ruby, Python, Django, or Rails in production, they will prove them wrong. Python and Ruby however, they make you productive more. They make you more productive than with Java or something else. But they are not a silver bullet, so you should not force it and use Ruby forever or Python forever. You should use the best tool for the job, but you can go a long way using the slow languages like Ruby and Python. You have sites like GitHub that use Ruby and Ruby on Rails, BitBucket uses Python, you have sites like Pinterest, Disqus that use Django.

H: They are all huge businesses.

A: I think the Washington Post and Guardian are also using Django, so those are huge sites and they are working pretty well. So you can go a long way with Django or Ruby on Rails, I mean it’s the same thing. But you need to know when to stop using Python and maybe replace some part of your architecture with some faster languages, more memory efficient. For example like Go, I know that Disqus was using Django a lot and they replaced some pieces of their architecture with some pieces of code written in Go which was running in a few megabytes of memory using a lot less CPU and doing the job. The rest of their architecture remained the same but they replaced one critical part that could benefit from a faster language.

And I think that’s the best way, because I don’t think when you start working with, for example, Rails or Django, that you need to think about “How am I going to handle 100 million users on my site?”, because when you get to that point you’re having nice problems to solve.

H: True, true.

A: And you can go a long way with vanilla Django or Ruby on Rails, so no need to worry.

H: So the design plays a big role here. As you just mentioned, most of the big sites, if they want to scale they just…

A: Yeah, I mean most of the sites are not, you know, not Disqus, they are not Pinterest, or not GitHub. So with a little bit of caching and optimizing your database code you can go a long way.

H: Oh! That’s very interesting. This way I mean you won’t pay for the performance, you still can achieve good performance with caching and with the right design. That’s very interesting.

A: Yeah, I mean memory is cheap.

H: [laughing] Right now what it is cheap, not ten years ago

A: No, well we’re talking about right now.

H: True, very true. I’ll get back to you Damir: would you like to contribute more about some success stories on Ruby on Rails? Amar mentioned a lot of sites using Python.

D: Well I guess we all know that one of the biggest sites of today started with Ruby on Rails. That was Twitter of course.

H: True.

D: Today of course it has huge problems, but then again, as Amar said, most of the sites don’t get to the point where they have similar problems and of course that was a problem that was solvable by replacing some of the parts that were previously written in Ruby with parts or libraries that are written in Scala of course, which is great pattern. You start, and you need to build out a product so you pick a productive language.

GitHub and SoundCloud are written in primarily Rails as well and both of them also moved to microservice-oriented architecture later.

H: Well, that’s a very interesting subject actually.

D: Yeah, SoundCloud actually has a great block post where they explain how they evolve their architecture from a monolith Rails application to a microservice-oriented architecture. I would recommend that read to everyone.

H: That’s very interesting actually. What do you think about the communities? For both Ruby and Python, they share that they have a great community. Would you tell me at least more about the way it goes with the community, especially when the community suggests something and how it usually goes, at least from a Ruby perspective?

D: The community is generally very open-minded and very inviting for both Python and Ruby, and both of the communities have great ideas about how to increase the diversity in the community and how to contribute more to the community in general, not just to specific Ruby and Python communities.

H: I see.

D: But when we are talking about proposing changes to the language itself that you mentioned, well in Ruby, it’s not really, there’s no perfect way to do it and proposing changes to Ruby basically is going to the bug tracker and filing your change as an issue in language. And then people will talk about it, consider it, but in the end there is only one person who will…

H: The godfather, Matz.

D: Yeah, only Matz will. Matz will have a final say in whether that feature goes into the language or not. And if he thinks about the feature, he doesn’t even have to share it with the others, he can just make it and put in the change. There is no process of suggesting features for improving Ruby as a language by the community, I don’t find that that’s the best part of the language.

H: I think, it’s funny that you mentioned that, because I think it’s the same even with Rails community. DHH is usually taking the right, I don’t know, the final decision about Rails just like Matz does with Ruby, that’s my understanding. Is my understanding right? Like you usually end up with one guy who created the framework who then takes the right decision or the final decision at least.

D: Well, yeah I guess when there are conflicts, DHH will make the final word, but I don’t think that suggesting a change to Rails is much easier than suggesting a change to Ruby. And getting your change inside Rails I think is a bit easier than getting it into Ruby.

H: Interesting.

D: I mean there’s the whole core team of Rails developers, and even when they propose a change and there’s a whole backlash from the community, he can change his mind about it.

H: It’s better with Rails community, it’s easy at least to…

D: No, to be honest I haven’t really spend so much time on the Ruby issue tracker, so maybe it’s just that I perceive the Rails community as more open to change, maybe because of my misconception.

H: That was very interesting I think actually, I didn’t know that about it, so you’re saying it’s like, and maybe Amar can contribute more here, but you’re saying that the Python community is more open minded to new changes. There’s at least more than a few people that make the decision by end of the day?

D: Well, I think that in Ruby, sorry in Python, there is at least a process where you are free to submit changes to the language, but maybe Amar should tell us more about it.

A: So I’m going to talk about promoting changes to the Python language, so you have something called PEP which is called Python Enhancing Proposals, and that’s basically the way to propose changes to a Python language, have the community discuss those changes, accept them or refuse them, and at the end if they are accepted, implement them. And hopefully including them in the standard Python library.

So it starts by somebody proposing a PEP: basically you need to write your ideas, what you want to change, what you want to improve, implement or something like that, and then you first discuss with people to find what they think about that idea, and the person submitting the PEP is responsible for all the communication handling to engaging discussions and collecting peoples opinions.

H: Awesome.

A: And he needs to draft a document which describes in detail the changes that are going to be made. So after, hopefully not too long of a discussion, the PEP will either be accepted or not accepted, and if it is accepted, then it moves to first stages where somebody needs to implement, for example a reference implementation or something like that.

For example, the best thing, best example is the recent addition of AsyncIO in Python 3.4 which is included in the standard library. Basically Guido van Rossum, who is Python’s benevolent dictator for life, wrote a PEP about AsyncIO which was code name Tut at the time. He wrote the PEP, discussed with the community, and wrote a reference implementation, and after the community accepted those changes and said it was a great edition, it was included in Python 3.4 as the part of the standard library.

So basically anyone can propose a change and has to stand behind it, convince the community that it is a good change that will benefit a lot of Python users, and if everything goes well, it will be hopefully included in the Python standard library.

H: Nice, so you are saying that the Python community is more in charge, is more of a democratic system, the way I see it.

A: Yeah, I mean you have people who are part of the core, core committers on the final repository and basically they agree on the things, how it should be done. In the case that nobody can agree on anything, you have Guido who can make the final decision, but usually people try to agree and see what the best thing is for the community.

H: Very interesting actually. Damir, Amar just mentioned PEP, is there an equivalent tool or gem for Ruby to do the same thing, to make it easier to contribute with any changes?

D: Basically no, there’s just that Ruby bug tracker that I mentioned before, you can only propose your change as a bug in the language and hopefully someone will read it and do something about it.

H: Is it like a web portal? To propose some of the changes?

D: Well there is just that bug tracker. I’m not sure which tool they use for bug tracking, but you just create your issue.

H: Interesting, what do you think, Damir, about the future prospects for Ruby? What would you like to see more in the coming future with Ruby? I hear so many people talking about concurrency at the moment. It’s a trendy subject and there’s no standard libraries, at least with Ruby, to support that. You end up using some third party libraries to support some of the patterns, some stuff like silly load to support the pattern.

What would you like to see in Ruby in the coming features that you would truly like to see?

D: Yes, improved concurrency would be much better, especially since Ruby has that virtual machine lock or global interpreter lock which doesn’t allow simple implementation of Ruby to actually use native system threads.

H: I see.

D: But there’s a workaround for that. You can use JRuby, a Java implementation of Ruby which doesn’t have global interpreter lock, or there is also Rubiness: Ruby mostly written in Ruby and C++.

H: And both implementations have no global lockers?

D: Yeah, so you can use native threads with both of then and improve the concurrency. But a change that’s really interesting that’s coming to Ruby, but eventually of course, we don’t know what exactly is in Matz’s head, but Matz has been speaking about adding typing to Ruby.

H: Typing?

D: Yeah, so that you can declare types, and then basically the code would tell you or some preferences would tell you if types are not compatible with the variations you specified.

H: Wouldn’t that kill dark typing or stuff like this since you are going to specify some of the types, if I got this right, maybe I’m getting it totally wrong.

D: Well, it definitely would change, I mean, the way I understood the current proposal is, typing would be optional so it won’t necessarily kill it, but it could change the way we are writing Ruby code, and they don’t think it would be for the worst, eventually because right now everything you write in Ruby has to have some kind of tests that act as a spell checker for you.

H: Sure, true.

D: And documented with typer notations of some kind you would be a bit more protected from silly mistakes.

H: True, but wouldn’t that kill a little bit the simplicity with Ruby. Ruby is very well known for its simplicity. One of the things that you don’t need to do is specify the type for a variable somehow.

D: Yeah, that really depends on how it’s going to be implemented.

H: I see, so…

D: I don’t know, I mean I can’t know much more about it.

H: [laughing] No one can.

D: But I mean, look at JavaScript where TypeScript is getting very popular because it actually allows typer notations, so I don’t know. Maybe it will improve the way we write Ruby code and improve the performance of the code if virtual machines can actually use the typer notation to optimize some parts.

H: Yeah, good point actually. I’m sure that specifying some types can improve the performance at least. That’s very cool, what do you think, Amar. What would you like to see in Python in the near future?

A: Well, the biggest issue right now in the Python community and the language itself is the split between versions 2 and 3. So, my biggest best thing that could happen is to resolve that in some way. Python 2 has support up to 2020, the year 2020, and after that I don’t think there will be official support.

Python 2.7 is the last Python 2 version that is going to be released they said there won’t be Python 2.8. And the committee is slowly starting to move to Python 3. It’s not there yet, we have a long way to go. But, I think that’s the biggest issue right now in the community that needs to be solved and right now the only way to have it solved is to port old libraries to Python 3 and our problem is that a lot of old, really old libraries, maybe they don’t have a maintainer anymore and there’s nobody to port them.

I think Debian recently started assembling a Python porting team. They basically want to port because they use Python a lot in a lot of their utilities and software, they want to port it to Python 3 in the next two or three versions of Debian that are going to be released, so people who are interested can help Debian port things.

And I think everyone should, whoever uses Python and if you encounter some library that isn’t used and it’s not ported already. If he has the ability to do so, he should help and make it work on Python 3. The biggest difference in Python 3 is the, I think it’s the handling of strings. Basically, in Python 2 you had strings which were basically, you could interchange bytes and strings, and in Python 3 it’s separated.

So you have strict separation of unicode strings and bytes. And a lot of code used to mix them interchangeably which could cause some issues when encoding and decoding you would get errors and exceptions which were pretty common. Right now it’s strictly separated and it causes issues for people who are working on the boundary, between string and text. Basically, when you’re working with a network, you receive bytes and you need to handle it as text in the rest of your program, so a lot of software worked with the bytes and strings interchangeably in Python.

Python 2 can’t really work that way, so you have a strict separation. You need to encode and decode stuff as you receive and send it. And I think that’s one of the biggest issues, and there were other incompatibilities that were… for example in Python 2 you had a U prefix that you could put before the string, before the quotes and it would represent the Unicode string and in Python 3 they removed the prefix. So a lot of code in Python 3 that had that prefix before the string just couldn’t work, it couldn’t compile.

So we took I think in Python 3.2 that they returned the prefix. It doesn’t do anything, but it’s there, it doesn’t cause an error when you try to run the program.

H: I see, I see what you mean more interesting actually.

A: So that was the biggest change text versus database.

H: Hopefully they are going to settle down soon.

A: Yeah, I mean the stats are improving. A lot more people are using Python 3, but it’s still not close to being the most used version.

H: Is it supported by Django, for example?

A: Yeah, I mean a lot of highly used libraries are supported. Django is, I think, for the last two or three versions. I’m not really sure it’s fully supporting Python 3. I think the last two versions were production ready for Python 3 and a lot of bigger libraries were supported, but you have a long tail of small libraries, or one off projects that people are using and they don’t have the time or the resources to port those things.

Those are causing issues.

H: Interesting. Damir, you just mentioned there’s not one technology for everything. I would like to know about the priority for both the languages, where Ruby stands, where it’s very popular to use Ruby, what are the cases for which Ruby is usually used, and what are cases where you usually use Python.

D: Ruby is mostly used for web applications because Ruby on Rails is what popularized Ruby in the first place.

And I think a lot of people are missing how useful Ruby is for other tasks, like for example, building apps for mobile devices or OS6 as we’ve discussed before, or maybe just for automating tasks like writing typical scripts or common line applications.

H: I see, I see.

D: There are nice libraries for helping you write common line applications.

H: Wouldn’t you agree that, for example with automated tasks, usually Python is more popular at the moment. Ansible is becoming the standard tool to do automated tests, and it’s written using Python, right?

D: Yeah, and before Ansible, Chef was more popular so…

H: True, very true.

D: I guess it just depends on what tool is trendy. Personally I’ve never really played with DevOps that much, so I’ve never used Chef or Ansible so I don’t know which one is actually better.

But I guess you would use one that fits into your ecosystem.

H: True, depends on the technology I’m using.

D: I know Python seems to be a bit more popular in other circles like maybe science I’ve heard at least.

H: What do you mean? Actually maybe Amar, you can tell us, because when you say science it’s a very genetic term. What do you mean?

Is it something like R language which statistics usually, if you can tell us more?

A: I mean Python is really popular in scientific communities and you have a lot of libraries, that make the work easier for data scientists. For example, you have libraries like NumPy, which is basically a package for scientific computing.

It’s written in C so it’s very fast, so you can use it from Python.

H: With extensions.

A: Yeah, it’s a very popular package. You have Pandas, which is basically built on top of NumPy which is basically for data manipulation and extracting data. You have some sets of data and you want to extract some meaningful information from them. You have matplotlib, which is a plotting library. Something worth looking into is the iPython and, more recently, the Jupiter Project which incorporate some of these libraries and allow you to easily interact with them and work with scientific data.

There is Ansible which is becoming very popular and there is SalesTech that is another tool. And you have a simpler tool like Fabric, which is basically a task runner for some simple things, so that’s it.

H: Very interesting. How about machine learning? Is there good support with machine learning in Python?

A: Yeah, I was just reading something yesterday but I can’t remember right now, I think there are a few libraries for stuff like that and some for example for natural language processing. NLTK, that’s what one of the libraries is called. So in scientific communities there are a lot of libraries for that.

H: I see, interesting so scientific users usually use Python.

A: Yeah, I mean the simplicity of the language and these libraries are mostly written in C so they are fast. You don’t have to write C, but you have a speed basically of C, so it’s pretty easy for scientists to learn and get on with it.

H: Are these libraries you’re mentioning part of the standard library for Python?

A: No, they’re third-party libraries and the best way to find them is for example, to go so there’s always libraries there and you can download them and check them out.

H: Interesting, and Damir I want to get back to you here about ease of use for beginners at least: what would you consider to be easier? To move from Python to Ruby or the opposite? What do you recommend for new users if they want to learn a new technology here?

D: It’s a difficult question, because I feel very responsible.

H: It’s just your point of view, so it’s fine. Worst case scenario, maybe the Python community will hate you and that’s it.

D: Well, being a Ruby user, I would of course recommend everyone to try to learn Ruby if they already know some other programming language.

Ruby as a language is very friendly to programmers and “making programmers happy” is the mantra, right. And it also helps people feel welcome to the language by providing multiple aliases to different methods. Previously we discussed how Python forces you to do everything in one way, whereas in Ruby you can do one thing in as many ways as you would like to and there is, for example in the standard library to get a length of an array you can either use a method called length or a method named size…

Then there is the map method that also has an alias of select, there is reduce which has an alias collect, etc, etc. And those aliases are there just to help newcomers complete the task. Yeah, to use the name that your are already familiar with, and when you Google how to map in Ruby you will get the map method and it is easy.

H: It’s true. Actually it’s funny, because that’s why I asked Amar before about it. Because usually Ruby developers would tend to think that you can do the same thing in more than one way like it’s a good thing. While it’s the opposite with Python guys, they keep saying that in Python you can do it in one way, which is supposed to be the good thing.

That’s why I get confused. Which is supposed to be more convenient? To do something in more than one way? I guess you understand that I’m just to make you fight guys, no more, no less.

D: Okay, you want us to fight? I will say that doing things in one way in Python is a lie.

A: Just to clarify, you can do things in other ways in Python, but the correct way should be one obvious way to do things. So with a list of strings you can write the for loop and use the plus sign to concatenate them or you can just join them using a method on the string. So you can do code that isn’t Pythonic, nobody is going to stop you but the people looking at the code are not going to think it’s good code. So basically you can write bad code, you can write code in any way you like it, but basically you have a set of idioms that are considered Pythonic, and that should be considered as the best practice so there should be an obvious way to do things, not mandatory.

H: Well, you have a good future in politics. You got the right answer here.

D: Well, I mean in every language you have a suggested way to do it, and I know like in Ruby when using plain Ruby it’s really relevant whether you’re using the size method or the count method to get the length of the array or maybe there is even a length method, I’m kind of forgetting which is in Ruby which is in Rails because Rails has some other… In Rails those three methods actually have three different meanings.

A: I think that could be a problem because for example, as you said if they were just an alias, yes they should do the same thing every time but as you said they’re not aliases. They look like aliases and, because for example if you’re on Rails you may think that they are the same thing, but you can shoot yourself in the foot later. Rails does a lot of stuff for you, a lot of magic behind it, and when you switch to something that isn’t Rails that removes the magic, it can be a bit different experience than the one Rails provides.

It’s better that you have other options, I personally don’t know the difference between for example map and select but maybe there’s a reason it’s there. Maybe map is better in some situations and select is better in others. Is it a good thing that Rails makes them the same thing? Maybe it is if you’re developing web applications because maybe you want to achieve the same result, but if a beginner learns that and doesn’t learn the difference it could be not good.

H: Damir it looks like Amar got you here.

D: Well, that’s why I would always suggest to people not to learn Rails first.

A: I agreed with that.

D: If they want to learn Rails they should first learn Ruby, at least to be proficient in Ruby, to know how to write a basic common line application, to write a script, and only then start learning Rails, because Rails is a piece of magic that is incidentally written in Ruby.

H: So you need to understand Ruby before understanding what’s going on.

D: Yes, you really need to understand Ruby to get Rails. You can start learning Rails but you’re doomed to make many mistakes. I’m not sure if it’s a similar situation with Django or maybe some other languages that are frameworks, but Rails really relies a lot on the magic that Ruby provides, like metaprogramming capabilities and the language being very dynamic and easy to change.

H: True, true I see with the next generation as well, once you create something by the common lang sometimes you don’t understand what’s happening behind the scenes, but while you create a bunch of files you won’t use actually.

You know with the same thing you just mentioned about Django and Ruby on Rails what do you suggest to the newcomers in Python? To go with lower level language like C++, Java, stuff like this or is it not really relevant?

D: When learning the first language, I would suggest someone to start with a statically typed language for the beginning, because understanding programming is really difficult and learning language that hides from you so many implementation details will probably not help you in the beginning.

H: I see.

D: At least that’s how I see it. I’m not saying you should start learning programming with assembler or something.

H: You definitely have a point. It’s the only way to understand lower level stuff at least.

D: I think that really when you’re learning programming for the first time, you should understand that numbers and strings are completely different beasts, and you can’t just compare a string to a number, that’s something that Ruby wont allow you to do easily. JavaScript would, and would say that zero is equal to the empty string. I think this for beginners it’s very important to know. To understand the memory of the computer and how it works so that they can understand what the computer is actually doing, what they are writing, and whether it performs well or not.

If they would just start with Python or Ruby, it hides so much complexity. I don’t think they would learn as much.

H: That’s a piece of good advice. Especially given that, once you spend the first few minutes in Ruby or Python you tend to think “that’s it, I got it all”. But with time, once you start digging deeper you understand that with a lot of the stuff happening, you don’t understand what’s going on. I think I totally agree with you here.

Amar, what do you think about them? I keep asking you stuff related to both Ruby and Python because you’ve worked in both. Actually both of you have worked in Ruby and Python. I would like to ask you here about Ruby blocks. This is a trendy subject. Usually it’s like Ruby blocks and Python lambdas, I keep hearing the same stuff over and over and it would be great if you can clarify the differences here.

A: Well, there is not really the equivalent of blocks in Python. That’s basically the way the language is structured, and there is no good way to implement that and have it still look like Python. You can emulate something like that with a “with” statement. It’s not the same thing but it can look the same way in certain situations. As far as lambdas in Python, they are limited to a single line because of the language and the significant white space, because in Ruby you can just continue and in Python how would you determine the end of the block or something like that? How would you determine the end of the multi-line lambda

H: I get it.

A: I think there were some discussions on how to implement that but nobody could come up with a good solution that would look like normal Python code and that could be readable, because you know readability counts in Python and so far nobody has a good solution for those things and if you need something similar to multi-line lambda but it’s not, you can always define a function in Python and just pass in the name as a variable and it works.

H: Without having blocks or lambdas as well. First of all in Python, do you have lambdas or is it not there?

A: Yeah, you have lambdas but they are single line lambdas. You have a keyword that allows you to define a lambda function.

H: So you can support the same function and type of programming with lambdas.

A: Yes, Python supports your procedural, functional, and object-oriented programming. So you have map functions and stuff like that that you can use. For example, one of the most used features in Python is of list comprehensions which look very functional.

Basically it is functional. It allows you in one word to can transfer lists into other lists and it’s one of the idioms of Python, so you can do functional programming in it.

H: Interesting, very interesting. Damir, Amar just mentioned that readability is a very important aspect of the Python community. What would you consider more readable?

In your case would you see at end of the day that Ruby class is more readable or Python class is more readable, and why?

D: I think that Ruby code is more readable than Python because Ruby tends to be very, well we say that Ruby is English-like and you have to put a very great effort into really making your code readable as English, but it’s possible. It’s very possible I’ve seen people do it, I’ve seen people reach it.

For example there’s RubyTapas for example. It’s basically a screen cast that’s five minutes long and teaches you how to write your Ruby code better and teaches you about not only about writing Ruby codes, it teaches you about many other things. But I really like what I’ve learned from it because it taught me how to write much more readable code in Ruby.

And Python tends to be overly…

A: You cant achieve…

D: I’m sorry?

A: You cant achieve the same thing with Python. You can’t achieve the same readability at least.

D: You can achieve the same thing of course, but you have to put, for example, something in a new line where you don’t have to put it there in Ruby, and putting the call command in one line makes it to my eyes a bit easier to parse and understand what’s going on.

Then in Python, you have all those dunder methods with double underscores in front and after which are kind of magical and you have to go through some hoops when you want to task them, at least that’s an issue I had when I was writing some Python projects. So, I think that well-written Ruby code is more readable than Python.

A: I agree with you. I had the chance to see some of the code with very senior developers, Ruby on Rails developers with re-factoring. We keep re-refactoring and we end up having code just like pure English and stuff just by re-factoring template methods. So you end up having very readable code.

H: What do you think about it Amar? What do you think about what Damir just said about the readability of Ruby and do you agree with him or do you believe that it depends more on the developer’s experience?

A: Well, it definitely depends on the developer. I mean, everybody can write bad code, but you need to put some effort to write good and readable code. And as far as which language is more readable… Well, to me, Python is more readable, I could be biased, but…

H: You are biased.

A: In the end it depends on the user who is going to use it.

It’s readable code at least compared to C++ and Java.

A: Yeah, Java with all the bullet points it can still be readable, but it can be a mess, it truly depends. I’ve seen good code in Java, I’ve seen bad code in Java so it really depends on the user. You can get smart in Python and Ruby and write something aligned that can’t fit on our large screen and nobody can decipher what you meant to say and you can write 10 lines of code which is 10 times longer but you have declared variables so it’s pretty obvious what your intention was, instead of one cryptic line. So in the end it all depends on the user and I think the Python idioms that when you see some code you can say it’s a Pythonic code, that it is recognizable. It has a structure that is recognizable to other Python programmers, so they know what to expect there.

H: I assume that would help developers to become better developers in the future since there’s like only…

A: Yeah, if you’re writing Pythonic code, it makes it easier for other developers to get familiar with that code faster, instead of writing cryptic stuff.

H: Interesting. Damir, I will get back to you: There is an interesting subject here because there’s no single answer for this. For IDEs and text editors, what would you recommend for Ruby? I’m going to get back to you, Amar, to get your ideas on Python.

D: Well I’ve been using just code editors for Ruby, I’ve never used an IDE.

Many people have praised RubyMine as a pretty decent IDE for writing Ruby but I’ve personally never used it. It provides help when refactoring code, but unfortunately can’t do as good a job as, for example Eclipse does for Java or Visual Studio does for C#. Because of the nature of Ruby, it’s very hard to statically analyze Ruby code because the languages is dynamic in nature.

H: That’s why we can see a lot of autocompletion with IDEs.

D: Yes, exactly.

A: I would like to interrupt here. Let’s face it, it’s not cool to use some IDEs with Ruby. It’s the community, they are going to look at you like you’re doing something totally wrong. You have to stick with text editors, that’s always the case. You can’t just code in front of your friends using IDEs, even if just for reputation.

D: I’ve never experienced that, but then again I have never used an IDE.

H: What would you recommend as a text editor here, what’s your favorite?

D: My favorite is Vim, but it may not be everybody’s cup of tea. Sublime Text is a pretty decent editor and I have used it also for a long time, but eventually I switched to… Well, used Vim before, then I switched to TextMate, then to Sublime Text, then to Vim again.

H: Well, I like Sublime. It was the standard to use TextMate, and right now Sublime seems to be decent.

I like the extension, what I would do with it. I guess it’s a cool tool.

D: I mean it’s a very decent editor but I think that’s Vim improves my productivity. I feel better when using it and it makes life easier.

H: With Vim if I’m not mistaken, right?

D: Yes Vim, exactly.

H: What are some of the plugins you would recommend to do to raise development using them?

D: I installed them a long time ago and now I forget.

H: It’s fine.

D: Of course anyone can go to my GitHub dot file and see exactly what plugins I’m using. There are plugins for Ruby and for Rails that provide autocompletion, syntax highlighting of course, and some shortcuts when developing in Rails to switch for example between controllers, views, specs, etc., which are pretty good and very helpful.

A: It’s very nice.

H: How do you handle, like if you lost your session with Vim. Is there any tool if it crashes or something to get back to where you left?

D: I tried to use tools for automatic session recording and restoration before but they didn’t work as well as I expected them to, so I just stopped using them and if it crashes or if I lose my session, I will just restart it, I don’t really care that much about it.

Oh, alright! I have to mention the most useful Vim plugin ever: Ctrl-P.

H: Ctrl-B?

D: Ctrl-P? It’s basically the same thing you have in Sublime built in with Command-T.

H: It’s a fuzzy search or something?

D: Fuzzy search, exactly.

H: This is the most important one.

D: Yeah, exactly you need a few others but it’s pretty cool.

H: Yeah, that’s pretty nice. It’s one good advantage of using Vim, that if you SSH a server you still can have them there.

D: Exactly.

H: Which is really cool. What’s your thought on that Amar? Can you share, what IDEs and text editors that you have known in these communities?

A: Me, I personally use Vim as Damir, but for some reason I really like to try other text editors, and I’ve basically tried all of them. I keep going back to Vim. I’ve been using it for a few years now and I’ve tried after switching to Vim to use other editors but I really can’t.

I even used other editors that emulate Vim to a certain degree, but there’s always a few things that are missing, and that just a habit that you acquired by using Vim and you just can’t go without it. For example, for some projects in C Sharp I’m using Visual Studio and it has a pretty solid Vim emulation but it is missing stuff and I keep finding myself grabbing the mouse.

I think that right now when I switch to an editor that isn’t Vim, I find myself grabbing the mouse to do things like selecting stuff that I want and I feel annoyed by doing that, and I know that Vim isn’t for everyone. I also tried playing with Emacs, but I couldn’t get it configured the way I wanted, especially when doing web development.

Some plugins would just break and mess stuff up. I also played with Sublime which is probably the best-looking editor, if that’s your thing out there. It’s a good editor, it’s fast, it loads fast, it works great, its files are large and small, but I really got accustomed to Vim.

H: Yeah, you are used to it.

A: Right now I can’t switch. If you want some IDEs, the most famous one is PyChar, which is basically from the same company as RubyMine. They also have a free community edition which misses some stuff, but you can usually go without that.

You have stuff like Komodo Edit, and there is the Eclipse-based PyDev, and I think if you’re using Windows, I think there is some support in Visual Studio for Python.

H: Interesting, very interesting actually. Actually, it’s like both of you are saying almost the same thing. If a very senior guy just moved to them, if you’re geek enough just move on and try to use it.

A: Right now it’s just, I think of habits. I got used to Vim. I mean I tried switching to, in the past I used stuff like NotePad++, but I tried switching to Vim once or twice and I couldn’t and after a certain point I said I’m going to try it and I’m going to stick with it and right now I can’t switch to another editor.

H: Well, you don’t have to it’s the most advanced one.

A: But I still have a bunch of editors always installed in my computer. I just like to try them to see what’s out there. They will always have some good stuff, some bad stuff but for now.

H: Nothing impressed you yet.

A: Yeah, I’m sticking with Vim and to a fork of Vim which has a lot of traction, and a very active community right now. For those that are using Vim, they should check it out because it brings some new features in Vim which in a short amount of time will achieve a lot and I think it’s going to be a great editor.

H: Is it a feature related to Python or a generic feature?

A: No, just for Vim users, that’s it.

H: I see, would you recommend any plugins by they way?

A: As far as especially for Vim, there is the Jedi plugin which is autocomplete. That’s the one I use that’s specific to Python, and the plugins which integrate to Python and allow you to check your code for errors and stuff. Unrelated to Python, Damir mentioned Ctrl-P which is one of the most acquired plugins, and I would also recommend Nerd Tree, which is a tree plugin basically to manage your directories and projects and navigating files in a visual way, if you prefer that.

H: Actually I was going to ask Damir about it, but I didn’t want to…

A: I usually use Ctrl-P, but sometimes it’s useful to see the hierarchy of the structure or the project.

H: Yes, it’s always helpful to see the structure, especially if you’re working with Nerd Tree.

A: Nerd Tree is a good one. Nerd Tree, yeah.

H: Yeah, cool. I get back to you Damir here about Ruby. So Ruby is very popular, one of the main reasons to make it more popular is using RubyGems right and you can find whatever you want as a library, as a third-party library to be used. What’s your thought on RubyGems and maybe you can tell us, is it the same with Python? Do they share the same mentality of publishing libraries?

D: I don’t know how to compare it to Python directly but I really like RubyGems and how they work.

I mean it’s very easy to, as a package manager, it’s a pretty great solution because you can install every library written in Ruby. It’s available as a Gem today and it’s pretty easy to search them from common line to install them, update them, upgrade whatever, uninstall, and publishing one is also pretty easy.

It’s great that there’s a community-backed free service for publishing those Gems and for delivering them. So I think RubyGems as a package manager for a language is a great solution.

A: Yeah, I think that it’s one of the main reasons, just like whole population in Ruby. You can’t think of anything without finding some library to do the job, which is awesome.

D: Yeah, I mean there are of course other languages have all sorts of open sourced libraries that do the same things you can do in Ruby. Although there are some tasks that don’t have such good solutions in Ruby as there are in other languages. For example, rendering PDFs, it’s actually very hard to find a decent library to do that in Ruby, but I didn’t want to get into that discussion.

Just finding those libraries is pretty easy because they’re all in one place and that’s RubyGems, so that’s what I was very excited when I started with Ruby it still works pretty well and keeps improving.

H: That’s cool. What do you think about it Amar, do you have the same Gems or whatever libraries in Python? How do you handle publishing new libraries and market it to other developer’s easily?

A: You have similar infrastructure in Python. Basically, it’s called packages instead of Gems, and you have repositories. PyPI repository and I think there’s a new one in development where you can register and upload your packages there. And you have PIP, which is basically an installer for the packages. Then you say for example PIP install Django and it goes to the repository for the PyPI and pulls the latest version of Django and installs it. You can also specify the specific version.

Bower is more advanced, and some people have a love-hate relationship with Python package management but…

H: What do you mean by saying that Bower is more advanced? You can’t specify the version of the package?

A: You can specify the version, but in Bower you can have multiple versions of the library and stuff like that.

And in Python you can’t do that, you have to emulate or to have something similar to that. We use VirtualEnv: basically it creates an virtual environment for example, Python 3 Version. And it creates an environment you name it for example, my awesome project, and then you install Python packages into that environment, and you can have for example, two versions of Django.

If you want to do with that, you need to create a second environment: environment one and environment two, and install different packages into different environments, and you need to switch between them by running a certain script which is created there. I think Bower is a better solution right now, but it’s improving in Python, so personally I don’t have issues with that. I mean it’s simple but I know there are people who complain, but for me it works. Basically, my needs are not that complex.

H: Do you consider the Python community as active as the Ruby community in publishing?

A: As far as the package itself, I think you have a package for basically everything.

As I said before, the biggest issue right now: is it supporting Python 2 or Python 3? And if you are mostly in web development and using the most popular tools, you basically can be sure that it is Python 3, but if you’re using some obscure old library then you need to look a bit harder to find the Python 3 version.

H: I’m done with my questions here, it’s up to you guys if you want to add anything. How about you Damir, would you like to recommend anything?

D: Yeah, I would like to recommend RubyTapas to anyone who already knows Ruby, and to people who want to learn it as well, because it’s a great resource for everything related to Ruby. Just to get to know all the details of the language and then you can use them whatever you’re doing, whether it’s developing iOS applications with Ruby Motion or maybe developing web applications with Ruby on Rails, and of course you’ll also get to learn some things about object-oriented design and object-orient programming that you can apply with any other programming language or environment. That’s, go check it out.

H: How about you Amar, would you like to suggest anything for the Python guys?

A: For those that want to learn Python, I think there are several online universities like Coursera offering programs that teach Python. Courser does one, I think CodeAcademy has a Python course, and I think Tree House also started one recently, so if you want to learn, that’s a good way. Also if you prefer to read books, there’s “Learn Python The Hard Way”, from Zed Shaw. He also has books for other languages like Ruby, for SQL, for C, so those books are good. And the best thing there: they’re free to read. You have the online version that you can read for free and you can buy the book if you prefer that.

If you’re into scientific stuff you should check out some of the libraries that are related to that. You can find them on I would also recommend subscribing to Pycoder’s Weekly. That’s basically a weekly email with some ways to start from the Python community.

H: Just like Ruby Weekly, it’s almost the same.

By the way you just mentioned Zed Shaw. I thought he was a Ruby developer. He’s more like a Python developer on the stage?

A: Right now I think he uses Python more than Ruby. I think he mostly paints right now judging by his Twitter [laughter].

H: That’s cool, that is really cool. I really appreciate your time here guys, I had so much fun talking to you, it was awesome and I hope that we can do it again soon.

Useful links: