{"id":212,"date":"2008-01-29T22:15:39","date_gmt":"2008-01-30T05:15:39","guid":{"rendered":"http:\/\/gregbaker.ca\/blog\/2008\/01\/29\/five-things-i-hate-about-python\/"},"modified":"2008-01-29T22:28:09","modified_gmt":"2008-01-30T05:28:09","slug":"five-things-i-hate-about-python","status":"publish","type":"post","link":"http:\/\/gregbaker.ca\/blog\/2008\/01\/29\/five-things-i-hate-about-python\/","title":{"rendered":"Five things I hate about Python"},"content":{"rendered":"<p>A while ago, I stumbled on somebody else&#8217;s blog entry <a href=\"http:\/\/pythonisito.blogspot.com\/2007\/03\/five-things-i-hate-about-python.html\">Five things I hate about Python<\/a>.  The game (apparently) is to pick your favourite programming language and pick five things you don&#8217;t like about it.<\/p>\n<p>This seems most common among the Python crowd: <a href=\"http:\/\/www.jacobian.org\/writing\/2007\/mar\/04\/hate-python\/\">Python 2<\/a>, <a href=\"http:\/\/ivory.idyll.org\/blog\/mar-07\/five-things-I-hate-about-python\">Python 3<\/a>, <a href=\"http:\/\/www.dougma.com\/archives\/16\">Python 4<\/a>.  It&#8217;s probably because everybody loves Python.  But, I did manage to find a few others: <a href=\"http:\/\/blog.micropledge.com\/2007\/10\/ten-things-about-c\/\">C<\/a>,<br \/>\n<a href=\"http:\/\/www.ihatethis.org\/2007\/04\/16\/5-things-i-hate-about-windows-vista\/\">Vista<\/a>, <a href=\"http:\/\/www.osweekly.com\/index.php?option=com_content&#038;task=view&#038;id=2524&#038;Itemid=450\">Linux<\/a>.<\/p>\n<p>So, here are my five things:<\/p>\n<ol>\n<li><strong>No parallelism.<\/strong>  The Python interpreter has a global lock that makes it impossible to parallelize execution. My processor has two cores, multiple pipelines, and a vector unit.  Wouldn&#8217;t it be spiffy to use those?  I have used the <a href=\"http:\/\/www.parallelpython.com\/\">Parallel Python<\/a> module to get around this (by spawning multiple interpreters), but it&#8217;s a hassle, and only applicable in certain cases.\n<p>To be fair, this is a common problem in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Imperative_programming\">imperative languages<\/a>, which force the programmer to precisely specify <em>how<\/em> thing are calculated.  It&#8217;s much easier for a compiler to parallelize things in functional language, which have the programmer specify only <em>what<\/em> is calculated.  Maybe <a href=\"http:\/\/www.haskell.org\/\">Haskell<\/a> is the answer to all of our problems?  Hey&#8230; why are all the 383 students looking at me like that?\n<\/li>\n<li><strong>Late Binding.<\/strong>  This is the mechanism that allows the beauty of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Duck_typing\">duck typing<\/a>, so it&#8217;s probably a net win.  It comes up in situations like this:<br \/>\n<blockquote><p><code>def add(a,b): return a+b<\/code><\/p><\/blockquote>\n<p>Until the function is called, there&#8217;s no way for Python to know whether the <code>+<\/code> there is addition, string concatenation, or something else.  So, when each statement executes, Python has to decide what operators (or whatever) to use at that moment.  The net result is slowing the language down a lot.<\/p>\n<p>Apparently <a href=\"http:\/\/codespeak.net\/pypy\/dist\/pypy\/doc\/home.html\">PyPy<\/a> has some improvement here, and <a href=\"http:\/\/www.cosc.canterbury.ac.nz\/greg.ewing\/python\/Pyrex\/\">Pyrex<\/a> allows extension modules with early binding.\n<\/li>\n<li><strong>Type confusion.<\/strong>  I don&#8217;t know if it&#8217;s the duck typing or weak typing, but beginning programmers (aka CMPT 120 students) often have problems getting the type that a particular value has.  I very often see students converting a type to itself.  For example:<br \/>\n<blockquote><p><code>name = str(raw_input(\"Name: \"))<br \/>\ncount = int(0)<br \/><\/code><\/p><\/blockquote>\n<p>That indicates some serious confusion about what&#8217;s going on.  Or maybe I&#8217;m a bad teacher.  I&#8217;d accept that as an explanation.\n<\/li>\n<li><strong>GUI libraries.<\/strong>  The standard Python install comes with only a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Tk_(computing)\">Tk<\/a> binding for GUI development.\n<p>I really wish <a href=\"http:\/\/www.wxpython.org\/\">wxPython<\/a> came with the default install.  Then, we could all use it and assume it would be there.  It would make Python a pretty serious contender for cross-platform GUI development.\n<\/li>\n<li><strong>Standard library.<\/strong> One of the principles of Python is that &#8220;the batteries are included&#8221;.  In other words, the libraries you need are there by default.\n<p>That&#8217;s usually true, but there are a few things I wish were always there.  The Python modules that I seem to have to install the most often are: <a href=\"http:\/\/biggles.sourceforge.net\/\">Biggles<\/a>, <a href=\"http:\/\/effbot.org\/zone\/pil-index.htm\">Imaging<\/a>, <a href=\"http:\/\/numpy.scipy.org\/\">Numarray\/Numeric<\/a>, <a href=\"http:\/\/www.parallelpython.com\/\">Parallel Python<\/a>, <a href=\"http:\/\/www.pygame.org\/\">PyGame<\/a>.<\/p>\n<p>As an aside, maybe if the Imaging and PyGame modules were accepted into the standard library, there would be some pressure to get some good documentation going for them.\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>A while ago, I stumbled on somebody else&#8217;s blog entry Five things I hate about Python. The game (apparently) is to pick your favourite programming language and pick five things you don&#8217;t like about it. This seems most common among the Python crowd: Python 2, Python 3, Python 4. It&#8217;s probably because everybody loves Python. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11,10],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-links","category-teaching","category-tech"],"_links":{"self":[{"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":0,"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gregbaker.ca\/blog\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}