Thursday, December 16, 2010

Learning Python

One thing I'm working on right now is learning Python.

Why Python?  Well, a few reasons, really.  It is a "clear and powerful object-oriented programming language". Also from the Python page, "Data types are strongly and dynamically typed. Mixing incompatible types (e.g. attempting to add a string and a number) causes an exception to be raised, so errors are caught sooner."

It can be used for all sorts of things like web development, database access, graphics, game development, or even to control two huge robot grappling arms.  I plan to use it to interface with twitter, for one thing.

I had done a bit of Ruby programming a while back, and there's nothing wrong with it, but I think I prefer the overall Python philosophy.   For a good comparison of Python and Ruby, see Gary Bernhardt's presentation: Python vs. Ruby: A Battle to The Death.  One thing Gary laments though, is the difference in the testing community/philosophy, where he notes that the Ruby testing community is more developed, or advanced, shall we say.  Ruby's extreme flexibility allows for it to be easily used for some pretty innovative testing approaches.   But I'm okay with these differences, for now at least.

There are many ways to learn Python, but I'm doing it mostly by using Greg Malcolm's Python Koans.  The idea is to learn the language by getting a series of failing test cases to pass by filling in the missing details in the test assertions. It is essentially using Test Driven Development to learn a programming language, which is a pretty great idea.  Instead of just randomly playing around, the Koans provide you with a guided series of steps needed to learn.  You know exactly how many tests you have fixed, and how many you have remaining to be fixed.  It's great to see the progress you make as you fix the test cases and learn more things as a side effect.  And the tests don't limit you because you can easily add more tests to play around and explore any area you like.

By the way, this is a pretty cool visualization of the commit history of the Python project.  It kind of shows how software is like a living, growing thing.

So, anyway, I'll let you know once I'm finished with the Koans, and if/when I create anything cool using Python.

2 comments:

  1. Where is Phython used predominately?

    John Emrich

    ReplyDelete
  2. Python seems to be used extensively at Google.

    Here is a blog coauthored by the creator of Python, who now happens to work for Google. http://python-history.blogspot.com/2009/01/introduction-and-overview.html

    That blog post says that "Google’s first web crawler in Python. Today, Google employs millions of lines of Python code to manage many aspects of its operations"

    ReplyDelete