CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

Why should you learn Python?

Shortly after I blogged about learning Python in 2005, I found out via Steve that several other people (Sam Gentile, John Lam, and Steve Eichert himself) are doing it too. I wasn’t following their lead in picking a language, but I’m glad to be in good company! The reasons why I chose to learn a new language, and the reasons behind choosing Python, might help someone, so here they are.

Why learn a new language?

I was following the Pragmatic Programmers advice to learn a new language each year. Peter Berger also suggests that learning languages helps you learn to program. I had been researching from late November through early December (2004) which language to learn next to best broaden my developer horizons, and the short list was Python, Lisp, and Smalltalk.

Peter Norvig suggest in his excellent essay, Teach Yourself Programming in Ten Years, to learn at least 6 languages. But he doesn’t say to learn 6 languages that are all similar, like C, C++, Java, and C#! Instead he says:

“Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).”

Why Python?

Good question.

Lisp and Python both support functional abstraction in the form of functional programming (at least I think this is right, but I’m no computer scientist, so take with the proverbial grain of salt). Big deal; what is functional programming anyway? Some of the key characteristics of functional programming languages are (source):

  • Functions are first class (objects).  That is, everything you can do with "data" can be done with functions themselves (such as passing a function to another function).
  • Focus on LISt Processing (e.g. the name 'Lisp').  Lists are often used with recursion on sub-lists as a substitute for loops.
  • FP worries about -what- is to be computed rather than -how- it is to be computed.
  • Much FP utilizes "higher order" functions (i.e. functions that operate on functions that operate on functions).

Since this is quite different from imperative programming, it is sure to give that “Aha!” moment once you “get it” in the sense of learning to think in a new language. The “Aha!” moment was also what I was looking for with SmallTalk, since everything is an object, but Python also offers the “everything is an object” experience. That is not to say that I won’t learn SmallTalk, it is just that I won’t learn it in 2005 unless prompted by work.

I also wanted a strongly and dynamically typed language (more here). Research on Python also turned up some interesting articles. Bruce Eckel thinks that Python is all about making your life easier. The Artima interview continues with part 2 (programmer productivity), part 3 (type checking), and part 4 (minimizing the typing). And of course Paul Graham caused a stir when he said that smarter programmers use Python not Java. Maybe this is my search for intelligence. :)



Comments

Darrell said:

Jiho - the Pragmatic Programmers were big on Ruby. In fact, their first "language of the year" language was Ruby. Seems like they were pushing their own agenda (since they sell books about Ruby) a little too much. But the concept is great.
# January 7, 2005 2:49 AM

Johannes Brodwall said:

Well - since Dave and Andy are giving away the first version of their Ruby book for free at http://www.rubycentral.com/book/, I doubt that money is the motive for recommending Ruby ;-)

Personally, I have had great fun learning Ruby, and I've actually used it for work-stuff, something I didn't do with Python.
# January 7, 2005 3:44 AM

Darrell said:

Johannes - the up-to-date version costs $30. This is not unreasonable, but they *are* book publishers. Maybe I interpreted that wrong, though. :) And it's also not to say that the rest of their stuff isn't great. I own several volumes from their library.

I will take a look at Ruby eventually, especially since on the Ruby FAQ it says that Python programmers "may or may not be put off by the huge difference in design philosophy between Python and Ruby/Perl." It may help that I did do a good bit of Perl development years ago. I still have my Learning Perl and Programming Perl O'Reilly books!

I'm curious as to why weren't you able to use Python for work-related stuff?
# January 7, 2005 4:04 AM

Grig Gheorghiu said:

Glad to see you're looking into Python. I started to do the same about a year ago and it proved to be a very fortunate decision. It made me rediscover the joy programming. I work as a tester and I've been using Python quite heavily in conjunction with various test frameworks. In fact, I submitted a paper called "Agile testing with Python test frameworks" to PyCon 2005, but I have no idea yet if it will be accepted or not. So Python can definitely be used for work-related stuff.
# January 7, 2005 9:09 AM

Johannes Brodwall said:

Darrell - you are correct about the latest version of the pick-axe book. But despite its antiquity, the first (free) edition is still quite accurate :-)

I guess I expressed myself ambigously about using Ruby at work. The only reason I ended up using Ruby and not Python was my own motivation for doing so.

When I started looking into Ruby, I used it for simple Perl-like one-shot text manipulation. When I had the chance to choose a language freely for a project that had to generate lots of builderplate SQL, I was comfortable enough with the syntax and running environment to consider Ruby. I was able to very easily build SQL-code by inspecting the metadata in an Oracle database and using some clever (if I may say so), reflection tricks.

Thus I've experienced to areas in which Ruby is strong: Perl-like text manipulation, and reflection. For other projects, Python may be more appropriate, but my feeling is that Ruby is "Python, but more so", with the possible exception of the extensive libraries of Python. Ruby is catching up nicely, though. The only area where Python is far ahead is with implementation in alternative environments (Jython and the like).

Anyway: Whichever language you end up choosing, I think it will be rewarding. It's really a no-lose choice :-)
# January 8, 2005 11:00 AM

Darrell said:

Johannes - well it sounds like Ruby is a little further along than I had thought! ;)
# January 9, 2005 12:11 PM

Darrell Norton's Blog said:

How to Learn Python
# January 10, 2005 5:32 AM

see boo said:

"I can't wait for the python to really take off so that it is supported by the .NET community (i.e. IronPython and all)."

There is a python-like language that already works very well on .NET or Mono: http://boo.codehaus.org/
# January 10, 2005 6:30 AM

Darrell said:

Very interesting, though leaving your name next time would be a nice touch.
# January 10, 2005 6:37 AM

Grant said:

I see a Python and .Net session for WeProgram.Net on the horizon . . .
# January 13, 2005 4:49 AM

Darrell said:

Sure!
# January 13, 2005 5:36 AM

TrackBack said:

# February 2, 2005 8:36 PM

TrackBack said:

# February 2, 2005 8:39 PM

Jay Kimble -- The Dev Theologian said:

No, I'm not dreaming of Halloween.  I have been fooling with SharpDevelop and discovered that there...
# January 9, 2006 2:41 PM

Jay Kimble -- The Dev Theologian said:

[small update... I added the links to Nemerle and Boo].
No, I'm not dreaming of Halloween.  I have...
# January 9, 2006 4:02 PM
Check out Devlicio.us!