Today's Question:  What are you most afraid of as a programmer?        GIVE A SHOUT

Technical Article => Programming =>  Programming

Why every programmer should learn Python or Ruby

  Tech Advice      2011-07-25 08:41:42      7,325    0

If you are a student, you probably know C, C++ and Java. A few know VB, or C# / .NET. At some point you’ve probably built some web pages, so you know HTML, CSS and maybe JavaScript. By and large, it is difficult to find students who have any exposure to languages beyond this. And this is a shame because there are a number of programming languages out there which will make you a better programmer.

In this article, we give some reasons why you must learn Python or Ruby2.

  • Compared to C/C++/Java – Python/Ruby allow you to write the same program with much, much fewer lines of code. It is estimated that a typical Python or Ruby program will require 5 times fewer lines of code than a corresponding Java code. Why spend that much more time on writing programs unless it is absolutely necessary? Also, someone said that a good programmer can reasonably maintain 20000 lines of code. It does not matter whether those are in assembly, C, or Python/Ruby/PHP/Lisp. So, if you write in Python/Ruby, whatever you do alone would probably need a 5-person team in Java/C/C++.
  • Compared to VB/PHP – Python/Ruby are much, much better designed languages than PHP/VB. PHP and VB are very popular for writing websites, and desktop applications respectively. The reason they’re popular is that they are very easy to learn and even non-programmers can pick them up quickly. But write any large program in these languages and you’ll start seeing the huge problems with these languages because they’re so badly designed. Friends don’t let friends program in PHP/VB.
  • Compared to Lisp/Scala/Haskell/Closure/Erlang – Python/Ruby are still quite “mainstream”. Sure these languages have some really cool features, and for advanced programmers, exposure to these languages can really improve the way they think about programming. But there will be time later in your career to decide whether you want to pick up one or more of these. But for now, Python/Ruby do a much better job of balancing the power of the language against commercial applicability.
  • Compared to Perl1 – Both Python & Ruby owe a lot to Perl, and Perl was the biggest and best dynamic language before they started gaining prominence. But now, Perl’s popularity is reducing and more and more people are adopting Ruby/Python. I find Perl’s object-orientedness a bit contrived and ugly. In general, I think Perl is a harder language to learn since it has so many different ways of doing things, and the syntax tends to be cryptic and non-intuitive until you get the hang of it. Overall, I feel that Perl is not the best language for a student to pick up, unless there is a very good reason to do so (i.e. if you have lots of regular expression processing, then Perl shines)
  • Compared to sh/sed/awk/bash – If you have exposure to Linux/Unix, you have probably done some shell programming, and might even have written non-trivial programs. But anything more than a few lines in these languages starts to become a bit painful and it’s much better to do this in Python. Of course, Perl is the best language for this, but Python is a close second. (Ruby is not so great for system shell scripting).

Just do a Google search on ‘Why is X better than Y’ – where you put Python or Ruby for X and put one of the other languages for Y – and you will find a whole bunch of material on why these languages are so good.

If you have the flexibility to choose the programming language for you final year project, then pick Python or Ruby and get done in half the time that it would have required you to do the project (except if it is a mobile app development project, in which case you’ll be forced to use Java or Objective-C).

Here is a cartoon from xkcd which gives an idea of how powerful you feel after having mastered Python:


How to get started? There are many, many website that give tutorials and classes on Python and Ruby. Here are just a couple of them that we’ve chosen:

Questions? Ask in the comments below, and we’ll try to answer them.


1: My post seems to have pissed of a lot of Perl fans, and in retrospect I realized that I was harsher on the language than I should have been. Hence I’ve changed the Perl section. Earlier it read:

Both Python & Ruby owe a lot to Perl, and Perl was the biggest and best dynamic language before they showed up. But Perl is now old. It’s object-orientedness is broken. It hasn’t really been updated in a while, and it is losing market share. For new, hot things (like web programming frameworks, web APIs) it is not as up-to-date as Python & Ruby. Basically, Python/Ruby are rising, Perl is setting.

Please keep this in mind when reading the comments of Lars, Torsten and Olaf.

2 All the language comparisons made in this article are for the context of students in Indian CS degree programs picking up a new programming language. A statement like “X is better than Y” will never make sense as an absolute statement because all languages that have survived the test of time are obviously better than other languages in some areas, and that is the reason they exist. In other words, there are always scenarios where PHP/Java/C/C++/Perl and others are better languages than Ruby/Python.

Source :



Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious



No comment for this article.



By sonic0002
Stackoverflow is celebrating its 10 million questions. This is a big milestone for this question-answer website. Here is the page to record all these amazing moments.