Wednesday, March 25, 2009

Why Python?

I started reading Programming Collective Intelligence again on my flight to Chicago for PyCon 2009. I started reading it months ago but never found the time to finish it. So now I’m starting again at the beginning, but hopefully this time I’ll read the parts I've already read faster (and with better recollection), and hopefully get through more—if not all—of it. (Not that I find it difficult or dull reading; on the contrary it’s very interesting and well written.)

I read something in the preface I don’t recall noticing last time. (Though I wish I had noticed it earlier.) Toby Segaran (the author) explains why he chose Python for all the example code in the book. He lists six reasons. Python is:
  • Consise - Python code tends to be shorter than other “mainstream languages”. So there’s less typing, but also it’s “easier to fit the algorithm in your head and really understand what it’s doing”.

  • Easy to read - If I recall correctly, I’ve heard Guido himself describe Python as “executable pseudocode”.

  • Easily extensible - In addition to the “batteries included”, there are many other modules that free and easy to download, install and use.

  • Interactive - If you program in Python and you never use it interactively, you may be a figment of my imagination. (Though others may be shocked to learn I don’t use IPython. When I finish reading Programming Collective Intelligence, next on my list is another book I started and didn’t make time to finish: Python for Unix and Linux System Administration. Chapter 2 is on IPython.)

  • Multiparadigm - “Python supports object-oriented, procedural, and functional styles of programming…Sometimes it’s useful to pass around functions as parameters and other times to capture state in an object.” As I become more proficient with Python I’m surprised that I use all three styles.

  • Multiplatform and free - “The code described in this book will work on Windows, Linux, and Macintosh.”

I wanted to blog about this because I’m sure I’ll want to refer to this in the future the next time someone asks “Why Python?” (Though I find I hear that question less and less. The word is spreading.)

2 comments:

Jorrold said...

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.


Joannah

http://linuxmemory.net

yacitus said...

Thank you very much Joannah. It's good to hear someone out there is reading my blog and thinks it's worthwhile.

I wish I could make time to post more often. I have more ideas than I have time.

But while I'm at PyCon 2009 I'm going to try to write more, shorter posts.