Python: Making easy things easy
July 31, 2007 In the last couple months, I’ve been writing a lot of Python code, and damn, I’m getting addicted. I’ve always enjoyed Python, but there were a few minor syntax issues that bugged me (NOT the indentation though). But lately, I’ve gotten over my stylistic qualms, and realized that the language is just so much fun to code in.
One of the things I really appreciate about Python is that it’s a “pay as you go” language in many ways. As a newbie, you don’t have to worry about learning advanced concepts like anonymous functions, generators, or list comprehensions. You don’t really even need to understand object-oriented programming to be productive in Python. Compare that to C# and Java, where you need to understand OO and generics before you have a fighting chance.
Many of the standard libraries take the same approach — they have a really low barrier to entry, but you can dig deeper if you need to. For example, writing unit tests is as simple as creating a subclass of unittest.TestCase, adding a test method, and calling unittest.main(). A grand total of three lines of overhead to turn a chunk of code into a test suite (four if you count the import statement).
I called this “pay as you go”, but I guess it’s really just “make easy things easy, and hard things possible”. I think both of these are excellent design goals for almost any piece of software. Usually, I just want to get something done. I don’t want to spend hours or days wrapping my brain around “The <such-and-such> Way of Doing Things”. Especially with programming languages and APIs, I want working code as quickly as possible. I may have to tweak it later; that’s fine. Just don’t be the annoying record store clerk who insists on “educating me”, when all I want is a Lionel Richie single.