Jeff is a DZone MVB and is not an employee of DZone and has posted 15 posts at DZone. You can read more from them at their website. View Full User Profile

Python vs Ruby: Maintainability

12.16.2011
| 18756 views |
  • submit to reddit

One of my favorite subjects is comparing and contrasting tools and frameworks available today. Python and Ruby are probably the big 2 languages right now in web development.

Now, a language is less important than the framework. However, the language sets the stage for framework's philosophies. Obviously all frameworks are different, but Django acts like Python and Rails acts like Ruby.

Writing a full article would be way too much. I've used both tools extensively for years. I am totally biased, I much prefer Rails to Django. Django does have its place though, and there are some things that the Python community simply does better.

Consider this the first in a series of articles comparing the two. This one, will be on the topic of maintainability. Maintainability is how easy it is to change/fix a product after it has been released.

Python culture

The Python culture is very idealistic. You get a total sense that there is a Right and a Wrong way to do something. Often times they will not have shortcuts you find in other languages, because the culture is very against having multiple ways of doing things.

The reason for this is readability. Something that Python excels at. I think it's probably the biggest goal of the Python community: to force readable code. It's actually difficult to make unreadable Python code.

It certainly isn't always concise (compared to Ruby, but very concise to Java/C++). Still, concise and readable are not the same thing.

Python also has this concept of 'Pythonic', which really means the Right way of doing something. They also have a king: Guido van Rossum. If you're in a debate with someone about Python, and you can find Guido saying something on the topic, Guido is always right.

This all moves towards this goal of simplicity and readability. For this reason, Python is without a doubt the easiest language to read. If I had to work on a project with developers I knew were going to suck, I would push hard for Python.

Ruby culture

Ruby has an incredible culture. It is similar to Python in some ways, open source is very much encouraged, it's practical, not run by a corporation, and it's just flat out an awesome language.

Backwards compatibility and readability though, definitely are not the main focus of Ruby. It's important, sure, but it takes the back-seat to productivity.

Ruby is very, very productive. There may be multiple ways to do things. As an example, with Django, authentication is built into the framework, there is one Right way to do it. Ruby has no built in authentication, and you can either do it yourself, use Warden, Devise, Sorcery or many other options. Each themselves has good and bad things about it, but they all work well.

You can absolutely get things done faster with Ruby. Especially when it comes to things like caching, nosql, workers. I know Python better than Ruby, but I still work much faster with Ruby.

Ruby has no king, it has a creator (Matz) but to be honest, I don't know much about him. I just know he works for Heroku. I'm sure he has a large influence on the community, but not like Guido.

Maintainability is also mitigated through other means. Rather than focusing on readability, it's taken care of simply by having less and better code. Also, the heavy focus on test-driven development absolutely reduces the amount of bugs, and can almost remove the chance of regressions.

I would also argue the gem system is much better than Python's packages, resulting in making it easier to share code between projects/companies/people. Python has always done this well, but things like Ruby's Bundler are just way better than anything Python has.

So in some ways, Ruby just doesn't need to be as readable to stay maintainable.

Summary

Still, Python wins in maintainability. This is both because the code is readable, and has a heavy emphasis on backwards compatibility.

However, maintainability is not everything. In fact, I think most developers focus TOO hard on it. Getting the product out the door is absolutely more important.

Also, while the language helps with maintainability, it's up to the developer. You can have super maintainable C code, and totally unmaintainable Python code. The language helps, but it is really nothing compared to the engineer.

My good friend Max Kanat-Alexander said this so well:

Python is the easiest language to read, Ruby is the most fun to write.


I could never have said it better myself.

Source: http://jeffdickey.info/python-vs-ruby-maintainability

Published at DZone with permission of Jeff Dickey, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Ryan Developer replied on Fri, 2011/12/16 - 9:13am

What does this have to do with Java and JavaLobby? Should I post Java focused articles on Python & Ruby sites because those languages can be run on the JVM?

Mitch Pronschinske replied on Fri, 2011/12/16 - 9:20am in response to:

I think a lot of Java devs are interested in knowing general things about various languages.  The general comparison of programming languages is a conversation that all developers tend to be interested in.

dieter von holten replied on Fri, 2011/12/16 - 10:43am

the only way to judge a software's maintainability is to take somebody else's 5 year old code and maintain that.

oh, problems to find that old software? probably it was scrapped and rewritten...

 

Robert Craft replied on Tue, 2011/12/27 - 11:11am

What are your thoughts on *operability* of Python vs. Ruby? Thinking about logging frameworks/paradigms, hooks for runtime instrumentation, version management, cross-platform use, etc., would be a good complement to the maintainability issues above.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.