Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Python Paradox (paulgraham.com)
161 points by tswicegood on Jan 9, 2011 | hide | past | favorite | 78 comments


The single most reason why a language X (it's python for me today) wins my heart is not because it's extra fancy or anything but the times when it gets out of my way to let me think about the problem and then everything else seems clearer. I write a lot in both Python and Ruby, but the days when I have to dig into my old code, Python readability trumps over Ruby's (or anything else for that matter).


the times when it gets out of my way to let me think about the problem and then everything else seems clearer.

There are two different ways languages accomplish this.

Smalltalk and Lisp accomplish this through odd-looking minimal syntaxes. The code may not look like anything familiar (outside of longish intention-revealing names) but there are so few syntactic rules to process that a smart person should be able to master them in a few days or weeks at most. (Despite the lack of familiar operator precedence for arithmetic operations.)

Python and Ruby accomplish this by having moderate amounts of syntax. (Ruby has about 3X more syntax than Python, but you can ignore much of Ruby syntax for general purpose programming and leave it in the "sysadmin toolshed.") However, the moderate amounts of syntax are designed to closely resemble pseudocode your professor used to scrawl on the chalkboard. Hence, the language can stay out of the way while you focus on the problem domain.

On the other end of the spectrum are languages that expose everything. C, C++, and Assembly are like this. Everything is available in raw form or as powerful and arcane tools. The beginner might be a little lost, but the rewards to the virtuoso are tremendous.

This is an oversimplification, of course. Python and Ruby also give the power-programmer access to powerful, arcane, and easily-abused tools. It's also quite possible to write very clean pseudocode-resembling code in C or C++. (See the Taligent coding standards.) The difference is really only in design-focus of the languages. (Smalltalk as another example. Smalltalk was designed to be simple to the complete novice -- as in a grade school aged kid. This is why it's minimalist, yet manages to look odd to the hard-core Unix geek.)


Can you give me an example of Python readability trumping Ruby?


It's simple, If I don't indent properly - I don't get to run my code in python.

Yes, I know I can make my code look cleaner in Ruby, but I'm lazy. Call me shallow, but sometimes not having to type in blocks and "end" is kind of nice because of the inherent indentation constraint. And that indentation makes it easier to find lexical scope hierarchy easily too (at least for me). YMMV :-)


I think indenting and block syntax are absolutely trivial with any good editor.


You missed my point. I am talking about the code being cleaner to look at in general.


It's just a trade-off. You get cleaner-looking code, which is much trickier to copy off a random web page. The latter might seem trivial, but it's not so simple. In an environment with ubiquitous browsers, many programmers start as copy-pasters. (Just as many of us of earlier generations started out in BASIC.)

I'm not saying this is bad. It just is.


The programmers should hone their tools first, as they are going to be the most important part of their experience. For copy-pasting code, in vim -- surely other editors have similar, highlight the new code (and surrounding code) and hit "=" (equals) key.


If you're trying to copy a non-trivial amount of code from a web page, you're doing it wrong. In 2010, I think sharing code over the internet is a solved problem.


Newbies often try to "do it wrong." I also wrote lots of really horrendous BASIC. It was a learning experience. If you think of tab-soup as a Python newbie right of passage, that's your prerogative.



I don't know if that's tongue in cheek, but as a mainly python programmer i find ruby much more clear regarding operator overloading.


I have to agree. I am also mainly a Python programmer who had dabbled a bit in Ruby, but in the above examples, Ruby is definitely nicer.

I mentioned some of the reasons I stuck with Python here: http://news.ycombinator.com/item?id=1941594

Where _language_ is concerned, I think Ruby is every bit as nice as Python if not nicer.


I think the point of Python's horrible syntax is to make operator overloading so painful that you're less likely to abuse it (cough C++ cough Haskell). Either that or Guido really likes underscores.


It's part of the point. The idea being that when you're doing operator overloading or metaclass hacking there's a simple, easy visual guide.


I find python revolting to look at. I find Pyhton web frameworks confounding to work with. I find PHP to be the most enjoyable language to write web based applications in. PHP just never enters into the discussion of languages but all of it's shortcomings are peripheral to the experience of actually writing code. Minor version upgrades often break things being my biggest gripe.

To folk claiming PHP is to programming what white bread is to a healthy colon, I say that you are the inferior programmer for not being able to love it.

My claim is this: PHP (and most certainly Perl) are to web application development what paint is to painting.

Web application frameworks written in Ruby and Python are to web programming what paint by numbers is to painting.


You're missing my point - a great language (whatever it may be for one's choice) doesn't get in the way of thinking clearly. If that's PHP for you, that's great.

I never mentioned any context of web in my statement. Au contraire, python's greatest strength is in its vast number of libraries for non-web stuff as well (though it can handle a lot of web stuff very easily). I find python's vast science and math packages to be very handy.


Not sure how that post ended up in reply to yours. I meant to add it as a comment on the article.


Why are people down voting this comment? Seems vindictive.


Your paint by number analogy doesn't really apply.

PHP, or Python, or Perl, as a language are to web applications what paint is to painting. CakePHP, or Symfony, or Rails, or Django is to web applications what paint + scaffolding + tarpaulins + masking tape + ladders is to painting.

Yes, you can build a ladder in the programming language you like, or you can just import one (or, in many cases, not have to) with a framework. They both still use paint, and I completely disagree with the assertion that a framework tells you where or what kind of paint to put -- it just puts you closer to the walls, and makes the application of said paint a little easier.

For the record, I personally consider an application framework more like a Wagner spray painter, or something more like that, but I think that's more dependent on the framework itself. Yes, there are constraints with frameworks, but there are significant advantages to speed of development.

As for the whole PHP vs Python, I'm completely ignoring, since you seem to be conflating PHP vs 'application frameworks in other languages' instead of PHP vs 'another language', which is unfair at best, and ill-informed at worst. For what it's worth, I'd put either Ruby or Python up as a general purpose language above PHP any day of the week, and PHP is the language I learned to program on (and still like, despite its unpopularity.)


The real reason I prefer Macs to PCs is that I find the 'mental environment' more pleasant. Uncluttered. Spacious. While you're working at a computer you almost inhabit it, and while you may not have a luxurious apartment, you can probably afford an iMac. I take it a step further by avoiding any software that doesn't live up to the Mac 'feel.'

I describe it to people as 'feng-shui' for computers. I'm surprised I've not seen that concept mentioned more in connection with programming. Python is probably my favourite language. Probably due to the white-spacing more than anything. And lack of those damn brackets.


I feel the same way when I'm writing python on my mac, or sitting down to try out some crazy new idea with node.js. It can be very hard to explain aside from "doing it this way makes me feel a certain way" or "it's an interesting experience trying to approach solving X in this fashion."

It seems with so much writing on how to effectively program computers, something has been lost - namely what it feels like to do so.


I find it's worth extending the mental environment into the workspace around the machine too. The ideal for my was a coworker whose office looked like something from Arabian Nights (in a very pleasant and artistic way) with just the barest hint of the technology that he used for his work (a Mac, for audio/video editing).


I wholeheartedly agree. What's more, learning python and using textmate regularly has ruined me for writing in MS Word... Not that I was particularly attached to it before, but I now find it really hard to think or write with all that junk (mostly broken - I'm looking at you styles) just sitting there.


Try LaTeX, if you haven't already.


Purely meta: It would be nice if HN could automatically show links to the discussions that took place the numerous other times this and other links have been submitted and front-paged. Seems like a lot of waste if each batch of HN users has to re-discuss the article from scratch. I tried Googling for the rest of them but so many irrelevant pages came up that I just gave up.


RiderOfGiraffes scripted a bot that would do that automatically, but others here thought it was some cheap novelty trick he was pulling.


Yeah I remember. Freaking good idea and well executed, destroyed by a small but vocal bunch of whiners.


It was certainly novel, and probably cheap. In most other discussions on HN, that combination would be regarded as a good thing.


I don't really know what caused some - few? - people to have a fit. Maybe anything that remotely reminds them of reddit calls for outrage.


Excellent idea. Shouldn't be hard to implement since these discussions all target exactly the same URLs.


searchyc.com?


http://searchyc.com/submissions/The+Python+Paradox

Doesn't show the past submissions of this article.


Googling:

  site:news.ycombinator.com +"the python paradox"

  site:news.ycombinator.com http://www.paulgraham.com/pypar.html
Pulls up only a handful of results. There are comments pointing to this link, but I don't think there's any story submissions. I could have sworn that this has come up before, but maybe we're both remembering wrong (or those submissions were killed and are now '[dead]') and we're just thinking of discussions where someone mentioned it in the comments.


For me, I find Lua has more clarity and consistency than Python. From the design of the language, to its implementation, to it's C API --- it's a very beautiful language.


I'll have to disagree.

When I open up any substantial Lua project, I am flooded with local local local and local. It drives me nuts coming from a Python background. Not only is there that, but they decided to use "end" which is more cluttered and longer than using brackets.

Lua also has no standard oop system which means you have to guess which half-baked version the project is using. I'm sure there are other problems I forgot to mention here.


I concur with your points. These are some of the problems I had, too, coming from a python background. To add to your list: the # operator confuses a lot of people as can be seen on the mailing list (although its semantics are well-defined actually). Nevertheless there are also convincing reasons for these decisions. Have a look at e.g. http://lua-users.org/wiki/LocalByDefault. And the use of "end" certainly helps with anonymous functions.

Purely looking at the language resp. the consistency of the design I would even say that Lua is more beautiful than Python even though Lua has its share of warts. Note that this does not say anything about which language is easier to use in practice (which is Python imho).

But that aside, I think it is important to mention that comparing Lua and Python is a bit like comparing apples to oranges as they pursue different philosophies. Lua gives you just as much as you need but no more. This is the reason why it is so flexible and suited for embedding. Python, on the other hand, is a full blown general purpose programming language with a huge community/ecosystem.


'local' is too long, yes -- I wish they'd used 'let' or even Perl's 'my'. But syntactically distinguishing declarations from assignments was totally the right decision. (I wonder if anyone's made a more Python-like frontend to Lua. Coffeelua?)


"And people don't learn Python because it will get them a job; they learn it because they genuinely like to program and aren't satisfied with the languages they already know." This seems that is not the case anymore. I think that since Python became more popular even in big corporations (see Google) the Python Paradox should be in 2011 something else. You name it. The ideas expressed in the essay are of course still relevant but the example maybe has lost some of its accuracy.


The python paradox is not true anymore - since it is taught in so many schools these days. Unlike in 2004 when the article was written.

However the main thesis holds true still... just replace python with haskell, erlang, clojure, or some other esoteric language.


Ask a few questions and you can still work out whether they actually learned it or just had it in class. Details depend on the curriculum in question, but recently when we faced this problem at a university recruitment a simple "Hey, what's a generator and why would you want it?" seemed to separate out the real learners from the classroom coasters.

Not that it really mattered that much, you still want to see learning of languages not in the curriculum and no 4-year program will ever cover all the interesting possibilities. We just learned that where "Java, C++, C, nothing else" is a warning sign from one university, "Python, C++, C, nothing else" was the warning sign from that one. You could probably generalize to "C, (Java/C++), exactly one other" and still be right.


haskell, erlang, clojure, forth, google go, scala, F#, ocaml, racket, sbcl reasonably widely recognized as PL's.

The relatively new paradoxers are things like epigram, Agda, coq, ATS; mozart/oz, mercury, factor, io, D, newspeak, imho.

Probably others from emLangCamp:

http://www.oscon.com/oscon2010/public/schedule/stype/Emergin...

note hedge words, reasonably, relatively..


Helsinki University CS department has a Clojure course this semester


Just in case anyone doesn't notice, this essay is from 2004. The basic premise is still a good one, even >6 years later.


I still like the premise, although I feel that Python has become far less esoteric while still retaining the favourite for a large number of quality programmers. And I can't think offhand of any newer languages that have taken it's place (maybe iOS counts?). But that might just be my small sample size.


From SF at least, I'd have to say Ruby, followed closely by objective c and clojure.


Does anyone really think that Obj-C is elegant and powerful in the same way Python, Ruby, or Clojure are? If so, I would like to hear the arguments for it.

edit: I understand that the iOS SDK is well-thought-out and easy to work with, but there could have been an equally good API for Python, Ruby, or (if your argument is performance) one of the more performant lisps. I don't think the SDK alone justifies Obj-C.


Does anyone really think that Obj-C is elegant and powerful in the same way Python, Ruby, or Clojure are?

The iOS SDK is elegant and powerful in a different way. There is more syntax. Designs tend toward more exposed entities. However, there is less coupling to particular implementation strategies.

Let's take operations on dates as an example, specifically jumping to "the same day of the next month." This is not as simple as you might think at first, since months vary in length in an arbitrary pattern. In many high-level language libraries, you simply grab your date and you do a single call. (In Ruby: Date.today >> 1) With iOS, you end up having to use 3 different objects. (Calendar, Date, and DateComponents)

Working in Objective-C reminds me of the best of "mainstream" Object Oriented programming from the mid 90's. There is a bit too much arcana, seemingly too many entities, but if you work through some real examples, you find that some good thought was put into things.


I wouldn't say Objective-C is "elegant" in the same way a scripting language can be, but it and its common libraries (i.e., Cocoa/NextSTEP) illustrate some very sound API design, and object-orientation in the Alan Kay-intended/SmallTalk sense.

edit: sorry, missed your edit. I'd probably agree with you and chc now. Obj-C was a clever hack for its time, but compared to modern dynamic/scripting languages, it's not really that special -- outside from being relatively high-performance due to its C compatibility, as you mentioned.


That's how it always seemed to me. Objective-C is a slightly above-average language with really good APIs.


If there could have been an equally eloquent API for those other languages, why wasn't there?

Obj-C + stringent/verbose coding standards = powerful APIs.

I've been writing Cocoa apps since 2002 and I pretty much love everything about programming on it, from the First Responder chain, the view hierarchy, bindings/observing, the new GC, blocks, properties, etc. (and more I'm forgetting) but I especially like how clear the design patterns are implemented. It's very rare to not know where a particular responsibility lies.

When it comes to the state of Mac/Cocoa programming, my biggest gripe is that Xcode 4 isn't progressing anywhere near fast enough. The IB integration should have happened long ago.


I would venture that Ruby is more popular (at least Rails seems to be among web devs) than Python or at least ends up with more press about it, so I don't know if Ruby would be a good choice. I imagine that (at least in web development) Ruby/Rails is one of those languages that people learn because it seems like a requirement. I could be completely off-base here though. The real majority of web-devs could still be on PHP/MySQL, while the vocal minority are on Rails/Django/whatever.


The TIOBE index instead suggests that Python is getting more use: it just won their award for most market share growth in 2010, putting it now at 3.5x Ruby's market share. Rails has been (and still is) incredibly influential in the web dev scene, which is why it might seem otherwise.


Haskell has a tendency to steal people away from python too.


Actually, I learned it chiefly because what it would do for me on Windows: a REPL plus access to COM. Need to bash around Excel spreadsheets & do funky regexp stuff? Done. Do I like it? A lot? You bet. But I didn't pick it up out of some existential need to improve myself.


this article holds especially true for non-technical entrepreneurs deciding which language to choose. while the supply of developers may be lower for languages such as ruby or python, you find a much more enthusiastic crowd of developers who in general seem to already have graduated from another language such as php. thus, from a business non-technical background, by choosing an enthusiast type language such as ruby it made it easier to narrow down quality developers with the right mentality as a technical co-founder than say a language with a large supply of developers such as php.


That's exactly what I (business guy) did. I learned Python myself also though, which made a difference. Reading threads on sites such as this had already convinced me of the power of Python (over PHP) and I put together a couple of demo apps to be developed in Python. Some of our guys have moved to it, some have been more resistant, but the guys who have seem much more focused on what they need to do.


Last time I looked into Python, I was reading something where the guy was going on about how awesome it is to get rid of all the cruft of C syntax, the semicolons and braces.

Then as I started getting into it, and thinking to myself, yeah, a lot of that cruft is just unnecessary, getting rid of it would be awesome... I tripped over the underscores and passing of self in Python.

If the whole point of your syntax is to get rid of old ugly syntax cruft, don't introduce new ugly syntax cruft at the same time.


While I agree with the approach described, in practice things can be a little different.

We decided to start using python in our agency a couple of years ago. We really love it but since that time we've really struggled to hire good people. Even in a big city like London we can't seem to find python devs that also have the other skills required for the agency world.

When I interviewed for this job we bonded over a shared interest in erlang (4 years ago). You don't need to use it internally but if you have a candidate who is interested in something like erlang, they're (probably) deeply interested in programming.

That's going probably a safer approach. Find people who do have an interest in the more obscure parts of software development (easy to gauge in a phone interview) whilst still practicing a more common language.

My point is that there's a much bigger picture to language choice. I'd rather be trying to find perfect candidates from a flood of ruby cvs than struggling to find any candidates at all from insert lesser known language cvs.


The strange thing about python is it is almost TOO easy. I have worked with developers who preferred python because basically they were not great developers. The ease of development and attractiveness of the speed of development was a lure.

The only problem is the overall systems they wrote were bulky, not efficient and generally over-engineered. Very not hacker like. For example using threads in python, a very big no no that can and does cause many performance issues. Designing python middleware that had no reason to exist other than to be a cool project to build.

And so on and so forth. Painful.


> The strange thing about python is it is almost TOO easy. I have worked with developers who preferred python because basically they were not great developers.

I don't know what you're talking about.

Python requires some command line interaction. You have to edit text files, read online docs, have a mental model of lists, dictionaries, and strings. It doesn't come with a visual IDE, and it feels awfully foreign in a windows environment. Why would a less-than-average developer even bother with such a technology? It doesn't even come from Microsoft.


You're correct on all those points. And yet, to someone with no formal training in CS (I'm an arts grad), python is so much more transparent than any of the MS stuff I've had to use. I think it's primarily the predictability of the naming scheme and the resemblance to pseudocode. The command line is not that hard to get your head around, and you get dicts strings etc with the first few chapters of Dive into python or 'How to think the a CS'.

In fact, it may be that these introductory materials are explicit about basic language concepts which makes learning python so easy — they're not focussed on solving your immediate problem (coding X), but solving the problems you will face over the next few years/decades.


I don't know why you were modded down. To me Python will always be a "scripting" language rather than a programming language, and claiming to be a Python programmer is a bit like claiming to be a mechanic who only does carwashes.

I switch back and forth between Python for small stuff and C++ for stuff where performance is an issue, and writing Python feels like no effort at all.


Who is the Pixar of carwashes?


This essay does assume, of course, that you can find enough developers in your locality that can write software competently in Python.

A few years ago I developed software (engine diagnostic/programming) for a large semi-truck manufacture in the Midwest. Our primary concern when selecting a language for a new product/project was whether or not we could find developers who were competent in that language. That almost always meant we chose Java because that is what our local developer pool was competent in.


That actually makes a lot of sense. While the Python Paradox may be partially true, it only makes sense to use in selecting a language when you can't screen applicants.

Once one can screen applicants, I think you're just as likely to find good Java programmers as you are to find good Haskell developers.


  >> I think you're just as likely to find good Java programmers as you are to find good Haskell developers.
While there are certainly more good Java programmers than good Haskell programmers, I think that the percentage of Haskell programmers that are good is higher than the percentage of Java programmers that are good.

  >> Once one can screen applicants,
It is a lot of work to screen applicants. If I were hiring a C++ developer and had two similar looking resumes, I would certainly call the developer that listed Haskell experience first.


very nice article, python's also my choice of coding language. i started with c/c++ in college and then moved on to use c++/java at my first job. but for the past 5 years it's been all python. i'd like to say that the reason is the speed with which i can write applications; not having to think about types, managing memory, or compiling source code helps remove some of the barriers that plague software development for me. time is money and most of the time i feel that i'm able to write applications much faster in python.

the language seems to blend all the best things, i'm never at a loss of finding a good open source library for python and it's most of all relevant. so even while ruby seems to be really popular at the moment because of the rails framework, python also has equivalent* web app frameworks such as django. i remember reading an article by the creator of python where he was praising the php language for having purpose built the language for the web and how python was more generic and less suited for the web (no reference at the moment), today there are lots of excellent web frameworks for python such as tornado web. so python is modern, it has adapted over the years quite nicely, and most importantly it just lets me do what i need to do.


The now language is Haskell.


It's probably gonna be coffee script on top of node.js


I'm an avid nodejs lover and coffee irritates me for some reason, but I agree with you. It's combining some of the up points of python and ruby, and hopefully it begins to get more traction.


I'd comment that it's actually Erlang.


It's neither and all. As pg said, it's any esoteric language which is not strictly learned as part of standard commercial software development.


Has anyone coined the term 'language hipster' yet? Because now seems like a good time.


I don't think that many people learning those interesting-but-not-immediately-practical languages do it to appear cool (what I think is the defining characteristic of hipsters.)

Programming characteristics are quite different from fashion/lifestyle. It takes much more effort to learn a language than to choose an obscure band to listen to. And the payoff in perceived coolness is also much smaller - see for example http://steve-yegge.blogspot.com/2010/12/haskell-researchers-...


I agree. I play with new languages (I won't claim learning just yet) out of curiosity and as a very productive form of procrastination.


Lispter would be fitting, albeit a little difficult to say.


The .com is available.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: