Python is a voluntary language

People who write Python choose to write Python.

I don’t hear people say “I use Python at work because I have to, but I’d rather be writing Java.” But often I do hear people say they’d like to use Python if their job would allow it. There must be someone out there writing Python who would rather not, but I think that’s more common with other languages.

My point isn’t that everyone loves Python, but rather that those who don’t care for Python simply don’t write it.

Since Python isn’t a common choice for enterprise software projects, it can resist the pressure to be all things to all people. Having a “Benevolent Dictator for Life” also helps Python maintain conceptual integrity. Python is popular enough to have a critical mass of users, but not so popular that it is under pressure to lose its uniqueness.

I don’t know much about the Ruby world, but I wonder whether the increasing popularity of Ruby for web development has created pressure for Ruby to compromise its original philosophy. And I wonder whether Ruby’s creator Yukihiro Matsumoto has “dictatorial” control over his language analogous to the control Guido van Rossum has over Python.

More Python posts

43 thoughts on “Python is a voluntary language

  1. To answer your question about Matz and Ruby: its pretty much the same situation. If a feature/change doesn’t fit Matz idea of the language, it won’t be accepted. He is pretty strict about such things as well.

  2. Full disclosure: I have written very little Python.

    I like a lot of things about Python, but one design decision that still makes my skin crawl is that the amount of whitespace is syntactically meaningful. I suppose with a decent editor / IDE this is not a big deal, but ugh. Even FORTRAN77 with the magic columns had the good sense to avoid this. Perhaps I’m showing my age (or decrepitude) but I believe my visceral reaction is Pavlovian.

    Of course, I dislike the syntactically meaningful whitespace in makefiles, as well, and for similar reasons don’t like a particular language’s “feature” (which may be mercifully eradicated by now) which made the underscore character shorthand for assignment, so you could avoid the onerous burden of typing two characters instead of one.

    But come on, can’t we learn from mistakes? Anyone want to use APL these days?

  3. Python also has made significant inroads into academia, both for research and education — much more so than Ruby. And there I think it’s seen as a more flexible alternative to Java. A lot of students I’ve spoken to prefer Python over Java unless they need the infrastructure that Java is noted for.

  4. John: The whitespace thing sounds like a big deal until you try it. Python only requires you to indent your code the way almost every C++ or Java programmer already does. So as long as you follow conventional formatting, the braces add no value. With Python, unconventional formatting is illegal, preventing bugs of the sort that come up in C++ due to misleading indentation.

    Makefiles are evil because invisible distinctions matter, i.e. a tab character versus spaces. You can use tabs in Python source, and Python has clever rules for handling them, but nearly everyone just uses spaces.

    Python doesn’t have the issue Fortran had with column numbers. You don’t have to squint at a file and check whether a character is in column 6 or 7. The spacing is relative. For example, the instructions that belong to an if block have to be indented more than the if condition, and all indented the same amount, but it doesn’t matter how much they’re indented.

  5. I’ve been in the Python camp for a long time. Wanted to learn Ruby for a while, mainly for Rails. Decided this week that Django is it for me. :)

    I found there great Python articles today.

    http://bit.ly/sdJ4w0 (decorators), http://bit.ly/uQ4Q0v (metaclasses), http://bit.ly/up3Cth (generators/yield). I had not previously dealt with decorators or metaclasses. Cool stuff indeed.

    I write C++ at work!!!

  6. A do use Python because my work requires it — it has become the standard scripting language for computational neuroscience. If I had a choice, though, I’d work in Ruby.

    Even after years of using Python I’m still not comfortable with the whitespace thing. And it’s less discoverable than Ruby; I still have to constantly look up stuff to recall how to do particular things. Why on earth, for example, do you have to do len(s) to find the length of a string, not s.len()? There’s even a method s.__len__() (quick, is that one or two underscores on each side?) that does it, but the natural way of finding it is missing.

    Yes, I am happy it’s Python and not Java, C or Forth. Given a choice, though, I’d still rather use something else.

  7. Alejandro: Thanks for the link to Paul Graham’s article. I agree that it’s important to look for evidence that a programmer candidate actually enjoys programming and takes the initiative to learn things that aren’t absolutely required.

    Janne: I heard an explanation for why len is a function rather than an object method or property, but I can’t recall it. I guess I wasn’t convinced or else I’d remember the reasoning.

    One quibble I have with Python is abbreviations like “len.” Why not use three more characters and say “length”? Oh well.

  8. Christopher Allen-Poole

    Python, to me, is the most mathematically pure language in common usage today. Along with Lisp, it is one of the true realizations of the definition of “function” as outlined in “The Calculi of Lambda Conversion” — if you read McCarthy’s history of Lisp he comments how “the only thing he understood” (yea, right) was the definition of a function f(x,y,z) as really f(g(h(z)y)x), this lead to the creation of the “inner most evaluation” which Lisp is known for. A major reason I view Python as so elegant is that it realizes the other definition proposed by Church in that treatise. The function f(x,y,z) can be described as f(*t*) where *t* is the tuple (x,y,z).

    I believe that this similarity in ideology is a primary reason that both of these languages place very little difference between the idea of a closure and the broader ideas of object-orientation. It is the reason that generators and continuations are so similar… I could go on.

    Python, for me, represents the second language construct which I have sat down and actually admired the language (Lisp being first, C being third). It is truly a thing of beauty and elevated van Rossum to my relatively short list of true heroes.

  9. Christopher Allen-Poole

    John: On the other hand, abbreviations like “len” are incredibly common in code in other languages. For example, I will generally use the variable name “len” as a part of a for loop to avoid re-calculating it every time. I’ll also use “ret” to mean “returned value”, etc. I don’t really see how this is any different.

    For that matter, why shouldn’t C/C++/Java require “integer” and not “int”?

  10. Just thought I’d weigh in on the whole whitespace thing.

    As far as I can see, whitespace being syntactically significant in Python is a good thing for the simple reason that it enforces code hygiene in terms of indentation and code formatting. There are some very good practical reasons why it’s important to be consistent with regards to indentation: diffing and merging in source control is one such example. Another is being able to speed-read your code and see where your code blocks begin and end: if you’ve ever had to make sense of a codebase with inconsistent indentation you’ll know exactly what I mean.

  11. Christopher Allen-Poole

    Personally, I think that anyone who’s ever decided to learn Python has had reservations about whitespace… until we start using it on a regular basis. Actually, I have had the thought, “Man, these {} are really a complete waste of time.” since then.

    The inclusion of “whitespace is significant” is actually something which was not a simple engineering decision (I’ve read at least one author who said that it actually causes some rather intricate problems), but it was very purposeful. It went along with the desire to make Python a very readable language and it works.

  12. I like the whitespace rules. I find that I do it naturally in any other language anyway. Of course, that could be a matter of having been conditioned by 12 years of coding in Python.

  13. @Christopher

    Yeah it’s funny everyone’s Python code has a certain way of looking the same. It’s a nice side effect of whitespace is significant. It certainly lowers the bar where reading other people’s code is concerned.

    With “{}” languages style and readability are so varied, so much in some cases as to make reading anyone’s code very difficult, even before you start trying to understand what it’s trying to do.

  14. Christopher Allen-Poole

    @Paulo

    I had a friend from High School who is into serious doctoral work (RNA combinatorics or something to that effect). He works a lot in Perl and Python. When I asked him his favorite language he replied, “whichever one I’m not using”.

  15. @Chris, that is certainly my feeling sometimes but not with Python. I really dislike Python. However, it is the language of choice for scripting in the company where I work. Most of my other work is with Assembler and C. In my free time I make myself happy by writing some Racket.

  16. @Chris, I re-read my last email and it feels like I dislike my job. Actually it is quite the opposite. I have never been happier with a job. I like 95% of it. That’s the part that doesn’t involve writing scripts in Python. :)

  17. @Christopher, if you appreciate LISP and Python for being “mathematically pure”, be sure to check Haskell out. I love all three languages (and I tend to write Python-code most) but when it comes to purity and consistency Haskell is in a league of its own.

  18. Christopher Allen-Poole

    @Daniel I’ve heard, and trust me, it is on my list of “need to learn”. Unfortunately, I am still tempered by use case — given the choice I would love to spend more time in something more functional or academic, but I have a career to mind and, for now, Python seems to hold the most elegance while still being useful in the business world.

  19. I’ve never done any significant work in Python, so this is not an attack on that language. But I will tell you what scares me about significant whitespace.

    I’ve been programming for nearly thirty years now. In that time, I’ve managed to smash the whitespace in a section of my code probably hundreds of times. If you’ve got braces, that’s just an inconvenience. It seems like it would be a much bigger issue in Python.

    Now, of course, given the modern-day world with undo and version control, that’s probably a very minor issue. But old prejudices die hard.

  20. Christopher Allen-Poole

    @Greg HEY! Don’t Be Hatin’ PHP

    Yes, it is in-elegant at times, but PHP is a very practical language and it is really good at the things which fall within its problem domain.

  21. We’re knee deep in a PHP project. I’m sneaking in Python with support services and scripts wherever I can, but the more time I spend in PHP, the more I enjoy Python.

    I agree with @Christopher, all these { }’s are really annoying. Well, PHP as a whole is pretty incoherent and a hideous mess.

  22. Christopher Allen-Poole

    @James & @John:

    Reminds me of my favorite van Rossum quote:

    Bill Venners: I once asked James Gosling about programmer productivity. His answer, which I consider to be the strong-typers view of weak typing, was, “There’s a folk theorem out there that systems with very loose typing are very easy to build prototypes with. That may be true. But the leap from a prototype built that way to a real industrial-strength system is pretty vast.”

    Guido van Rossum: The leap is also a folk theorem as far as I can tell. That the leap from prototype to system is so big is just as poorly documented as the ease of prototyping.

  23. I used python on a project that was integral to the electronics of Boeing’s new 787. We used it to interface with and maintain the database that held all of the physical (wire and fiber) and logical (messages) interfaces between all the electronics. I don’t know if you call that “enterprise” software, but it will have to be maintained for the lifetime of the 787 fleet which will be decades.

  24. James: I’m not saying Python isn’t used in enterprise applications. Only that it’s nowhere near as common as, say, Java or C# for such projects.

  25. John: Is this the article on `len` that you were thinking of?

    http://lucumr.pocoo.org/2011/7/9/python-and-pola/

    If not, it’s still an excellent article on the principal of least astonishment in Python and its rationale for such exceptions. Also, as someone who writes in Python because I very much enjoy it, thank you for sharing these thoughts. As always, a great read.

  26. John,

    I´m currently about to embark on learning Python. Before I do, have you got any recommendations for a good place to start?

  27. you seem to be implying that python represents a lofty ideal for discriminating coders. quite to the contrary, i have found that it has simply become the default “blub” scripting language for people who tend to hold few meaningful opinions about their tools.

  28. I agree with you here… I am often thinking “I would love to program something in python’, but perhaps because I am more used to C-like syntax I usually end up writing Java. And more often than not I use PHP instead (since I am a freelance front end developer). One day I might get a dedicated so that I can host python websites!

  29. Python isn’t that uncommon in enterprise settings. It’s mature enough that it’s no longer seen as risky. For example, it’s been one of the (very few) officially allowed languages at Boeing for years, and they’re about as big and stuffy an ‘enterprise’ as you’re likely to find.

    I admit that I liked it when I started, but very quickly grew to see its limitations. Boeing R&D works on some *really hard* problems, and on the abstraction scale, Python is higher than C or Java but lower than several other languages I could name. We had our own type-systems, and our own method dispatchers, and our own pattern matchers, and such. A lot of time was spent re-implementing (poorly) features which were built-in to higher-level languages.

    I still think Python is a nice little language, but I’m not sure I’d use it for research projects again.

  30. With node.js my use of Python for scripting and web-apps has pretty much complete dropped. Pythin is nice but there are very few places where it makes sense to use it.

  31. I’m glad you like Python. I hate it.

    I have used Python for about 2 years now, and I would not be using it if it weren’t for my job. I would far rather use: Perl, Ruby, or a Lisp. Those languages fit together. Python does not; it regularly reveals inconsistencies in library design and bolted-on features. I could and have ranted for hours about the drek that it is.

    One way to conceptualize the problem is that it’s descended from ABC, a teaching language.

  32. @vlion

    I’m no Python fanboy, but you think Perl is more put together? Honestly that sounds like the talk of a madman.

  33. Brian:

    The reason len() is a function is because it’s not specific to strings.

    How is that a reason? datatypes for which len() is appropriate could all have (and probably do; I am not a python programmer) an analogous method:

    string.length
    tuple.length
    function.length

    See, e.g., Ruby.

  34. Christopher Allen-Poole

    @Howard They actually all have a __len__ method, but len(obj) is easier than obj.__len__().

    Actually, len, repr, str, multiplication, division, and a number of other functions are merely wrappers around object methods. Eg:


    True.__repr__() #'True'
    True.__mul__(2) #2
    True.__div__(2) #0 (boolean inherits from int)

  35. I actually heard my friend say that he has to use Python in his work, but he would like to use Ruby. But I guess he’s not feeling too much unconfortable anyway.

  36. I am reluctant adopter of Python. Highlights: (1) libraries: “Pint,” “Hypothesis,” “Tensorflow,” “sympy,” “pygame,” “pybullet,” “pymunk,” “oslash,” so many great free libraries; (2) functionalism: it’s not difficult to write code in declarative style, despite passive-aggressive leaning to imperative style from the Python punditry. They’re losing that fight and they know it. Lowlights: (1) context-dependent import stuff. It can be difficult to get a big project to run BOTH from the command-line AND inside an IDE because contextual rules require the import statements to have different forms. (2) syntax. Ok, I don’t like infix operators in any language. Our coding conventions require full parenthesization of all expressions, but Python doesn’t help me enforce it. It’s a bit ironic that, while the Python zen says “explicit is better than implicit,” the language features operators with implicit precedence rules. The whitespace thing does not bother me at all.

    Overall, I’d rather be using Clojure, but I can’t get others to go along with me because of knee-jerk resistance to any Lisp. It’s ok, Python is a great middle ground.

Comments are closed.