Slashdot is powered by your submissions, so send in your scoop


Forgot your password?
Programming Technology

The Python Paradox, by Paul Graham 726

GnuVince writes "Paul Graham has posted a new article to his website that he called "The Python Paradox" which refines the statements he made in "Great Hackers" about Python programmers being better hackers than Java programmers. He basically says that since Python is not the kind of language that lands you a job like Java, those who learn it seek more than simply financial benefits, they seek better tools. Very interesting read."
This discussion has been archived. No new comments can be posted.

The Python Paradox, by Paul Graham

Comments Filter:
  • Re:FP (Score:2, Informative)

    by nyssa ( 250538 ) <greg@gr a h> on Thursday August 12, 2004 @03:46PM (#9951712) Homepage
    print "First Post" # is more appropriate
  • by jobeus ( 639434 ) <jobe-slash@j[ ] ['obe' in gap]> on Thursday August 12, 2004 @03:49PM (#9951751) Homepage
    Interestingly enough, knowing Python did get me a job... My company works a lot with Java too, but my job specifically deals with about 90% Python, and 10% Java... I never thought there was a use for it when I learned it in University...

    Too bad I'm maintaining code with two letter variable names all the time though, and now it's soured the language for me as well... heh.
  • by r.jimenezz ( 737542 ) <> on Thursday August 12, 2004 @03:53PM (#9951800)

    for( SomeType s : collection )
    doSomething( s );

    I think something along those lines is already possible [] in Java :)

  • by otisg ( 92803 ) on Thursday August 12, 2004 @03:53PM (#9951802) Homepage Journal
    Who says Python is not good for getting jobs? I know at least 2 places in New York City where you should send your resume, if you are a good Python hacker: and (also .com).
  • by tcopeland ( 32225 ) * <> on Thursday August 12, 2004 @04:03PM (#9951941) Homepage
    > for( SomeType s : collection )
    > doSomething( s );

    Yup, JDK 1.5 (or 5.0?) will introduce generics, enumerations, and a for-each construct - as soon as it gets out of beta.

    But it'll be about four years you'll be able to actually use them because it'll take that long for folks to move off of JDK 1.4 :-)
  • by Theatetus ( 521747 ) on Thursday August 12, 2004 @04:11PM (#9952025) Journal
    so long as he buys my theory that lisp hackers are better than python hackers.

    Ummm.... something tells me Paul Graham would agree with that. Read his Lisp books some time.

  • by Anonymous Coward on Thursday August 12, 2004 @04:23PM (#9952182)
    Sure, with these toy examples...

    But the thing to keep in mind is, the Ruby version is just a method on the collection, it is NOT a language construct. You can write your own like this:

    # do it in a random order
    collection.each_random { |x| x.do_something }

    # do it to every other item
    collection.each_even { |x| ... }

    # show a busy cursor during the operation
    collection.each_with_busy_cursor { |x| ... }

    You really don't realize the power of Ruby until you start coding BEYOND what you can already do in other languages.

    And if you play with Lisp, the *whole language* is fluid like this. For instance in a lisp program I needed to slow down a sequence of operations by sleeping in between. I wrote a macro that took a block of code and inserted (sleep 1) between every operation:

    (sleep-between 1

    How do you even begin to do this kind of stuff in, e.g., VB?
  • by SkeptiNerd75 ( 85087 ) on Thursday August 12, 2004 @04:24PM (#9952203)
    Until there is an IDE for Python that's as extensive, capable and sophisticated as Eclipse I'm going to stay with Java.

    Actually, you can use Eclipse as an IDE for Python: onIntegration [].

    And why choose between Java and Python when you can have both []?

  • Re:Yea (Score:3, Informative)

    by Inf0phreak ( 627499 ) on Thursday August 12, 2004 @04:35PM (#9952355)
    Then I think Unlambda [] or Whitespace [] would be better choices.

    Brainf**k is a relatively simple stack based language. The only thing about it that makes it hard to understand is its very terse syntax. Unlambda and Whitespace has this as well, and in addition to this they are completely unreadable. The reasons are quite different though: Unlambda because there is absolutely nothing like it (wrapping your mind around a myriad of s's, k's, i's and `'s == pain. I've tried) and Whitespace is just impossible to read (and program for that matter) without the aid of a program that can convert it to something where you can actually tell the instructions apart.)

  • by ArsonSmith ( 13997 ) on Thursday August 12, 2004 @04:35PM (#9952361) Journal

    foreach ( @collection ) {
  • by perdu ( 549634 ) on Thursday August 12, 2004 @04:36PM (#9952375)
    I guess the point I'm making is that this language has a strong appeal to people like myself who are just looking to use it to solve problems and/or make problem solving tools
    Thanks for the thought!

    We have a bioinformatics group where I work and Python is the language of choice when they need to crunch alot of numbers. I understand there is a nice interface to the R statistical engine and many other useful facilities. I've never gotten any of them interested in Java which we use for our systems in IT...

  • Re:Source? (Score:5, Informative)

    by kjd ( 41294 ) <(kdraper) (at) (> on Thursday August 12, 2004 @05:02PM (#9952671)
    Google turned this up, which cites a source: []
  • Re:Source? (Score:1, Informative)

    by Anonymous Coward on Thursday August 12, 2004 @05:07PM (#9952731)

    From Googling:

    This study is mentioned in this book excerpt [] and here [].

    The first reviewer here [] mentions a reference that would seek to discredit the cited study's author however.

  • Re:Python vs Java (Score:2, Informative)

    by chez69 ( 135760 ) on Thursday August 12, 2004 @05:07PM (#9952732) Homepage Journal
    I don't have to install anything in my classpath to use standard java classes.
  • by jesterzog ( 189797 ) on Thursday August 12, 2004 @05:16PM (#9952827) Homepage Journal

    That example seems a bit selective to me. Code blocks are nice given the rest of the way that Ruby is designed to make them useful and handy, but I don't think it's necessarily superior. Personally I'm a great fan of Ruby for it's consistency, which I suppose it inherited from Smalltalk. I really like being able to deal with anything in the same way, without having to worry that there might be exceptions.

    I've been using Python as my favourite scripting language for several years -- it's a neat language to code in. Recently though, I had a situation where I wanted to make adjustments to the String metaclass, and I hit a brick wall. Python's consistent in most places, and getting even moreso over time, but there are some bits of it that completely conflict with everything else. If you hit one of them it can be quite frustrating.

    Switching to try the same thing in Ruby, I found that the consistency between standard library classes and everything else made it so much easier. In my Python version, I had to design a wrapper around a string, which is very yucky because I really want all strings to act a certain way - not just those that I remember to put a wrapper around. With Ruby it was just a matter of re-declaring the String and adding the methods I wanted.

  • by kndyer ( 521626 ) <`moc.liamg' `ta' `reydnk'> on Thursday August 12, 2004 @05:17PM (#9952833)
    I agree completely, With its support for numerical analysis (and similarities with Matlab-y constructs) it is ideal for algorithm prototyping and in some cases even algorithm deployment.

    I certainly turn to Python first, rather than coding up new ideas in c++.

  • by mschaef ( 31494 ) on Thursday August 12, 2004 @05:18PM (#9952844) Homepage
    "Java is now frequently used in CS research as well. It looks almost certain that the next milestone in CS evolution will come in the form of Aspect Oriented Programming and AspectJ has been the leading implementation. "

    Ironically enough, AspectJ is heavily based on the Lisp/CLOS Metaobject protocol that dates back to the late 80's and early 90's. Not that this should suprise anyone, the same folks developed both tools. I'd characterize AspectJ as more an "industrial response" to CLOS/MOP than new research.
  • by lordpixel ( 22352 ) on Thursday August 12, 2004 @05:24PM (#9952916) Homepage
    I agree with most everything you say, but I don't think Design Patterns is a good example.

    It weighs in at 395 pages, which isn't the thinnest but way short of the 1000 page plus behemoths you're talking about.

    Most of that page count is actually showing you example implementations (in C++ and SmallTalk). Sure, you could leave those out, but examples are useful when your book is about abstract concepts.

    This book is worth its (light) weight in gold.

  • Re:Why I like Python (Score:2, Informative)

    by razeh ( 192191 ) on Thursday August 12, 2004 @05:42PM (#9953090) Homepage
    I disagree. Operator overloading is nothing more then syntactic sugar. Code that uses it is no more difficult to read then code that makes ordinary function callls.

    When you see:

    Foo a, b(3), c(5.3);
    a = b + c;

    You will be tempted to assume that addition is occurring. Do not! Treat the above code exactly as if it had been written:

    Foo a, b(3), c(5.3);
    a = b.add(c);

    Or better yet:

    Foo a, b(3), c(5.3);
    Once you've realized that it's all function calls your frustrations will vanish.
  • by cliveholloway ( 132299 ) on Thursday August 12, 2004 @05:51PM (#9953178) Homepage Journal
    Err, two things:
    1. You're not dereferencing the hashref ( $hr->{$_} )
    2. You're not doing what was asked - you're iterating through keys of a hash rather than an array.

    Damn Perl trolls ;-)

    for (@x) { do_something($_); }

    # or even simpler
    do_something($_) for @x;

    cLive ;-)

  • Eric Sink's reply (Score:2, Informative)

    by GeorgeMcBay ( 106610 ) on Thursday August 12, 2004 @06:08PM (#9953350)
    Eric Sink wrote a reply [] to the original Graham article that mentioned Python and Java that is worth reading....the gist being that for many companies, the best and brightest hackers might not be the best actual employees.

    From my own work experience, I think he is right (in some situations). There certainly are many great hackers I've worked with whose technical skills I respect but I would never want to work with again. Of course, I've also worked with a lot of great hackers who were also great employees, so it can go either way. But any hiring manager (or any employee for that matter) would be wise to remember that the person's technical skills are only part of a bigger picture.

  • by Paradox ( 13555 ) on Thursday August 12, 2004 @06:16PM (#9953414) Homepage Journal
    Consider that Graham's premiere hack was Yahoo! Stores. It wasn't a huge project in LOC count (PG says this is because it was in Lisp). However, it was big enough that Yahoo! had trouble reimplementing it in more conventional languages (and in the end, actually wrote a simple lisp interpreter to handle part of it).

    Yahoo! Stores wasn't a "small" project by any sense of the word. Maybe the upper boundries of "medium."
  • by eli173 ( 125690 ) on Thursday August 12, 2004 @06:22PM (#9953459)
    We use a fair amount of reflection, too (which makes debugging all kinds of fun). I'm fairly ignorant of Python, so if it doesn't do a lot of that, it sounds pretty neat. My only complaint is I'd prefer a compiled language, because watching production crash because of a typo is not fun.

    One approach to "compile-time" problems with python is to treat pychecker as your compiler. Basically, it looks for all those typos that C etc catch due to requiring variable declarations, and a whole lot more. Unused local variables included.
    Python doesn't really have private members like C++ does, so a lack of accessor functions doesn't have the same meaning.

    (I can't address the reflection thing; never really learned Java. My thinking went from C to Python... from what I saw, C++ was an incremental improvement (long story there...), Java was another, but Python was a leap from C, much the same way C was a leap from ASM.)


  • by Frater 219 ( 1455 ) on Thursday August 12, 2004 @06:30PM (#9953512) Journal
    My point is this: Graham seems to really like the "small is better" approach, for which interpreted languages really shine.

    Actually, the language that Graham is most associated with is Common Lisp, which is neither a small nor an interpreted language. It is relatively large for a Lisp dialect (much larger than Scheme), and a compiler is part of the specification.

    (I'm not counting Arc, since it doesn't exist yet.)

  • by Baki ( 72515 ) on Thursday August 12, 2004 @06:38PM (#9953596)
    With IDE's like eclipse, that compile any file on the fly as you save it, there is no more lengthly build process and even with a fast compiled language such as Java you don't have to suffer.

    You save and run the program right away, or in the case of an automatically reloading servlet such as tomcat you don't even run the program: your changed class file is detected and tomcat reloads the class in the running program. IBM websphere takes that concept even further.

    It feels like smalltalk, where you are also changing the program aka image in place without restarting it.
  • Re:Why I like Python (Score:2, Informative)

    by mvpll ( 542255 ) on Thursday August 12, 2004 @06:42PM (#9953637)
    I have objects of type A and B. Both handling strings, A as a single string and B as an array of strings.

    You seem to think that

    A3 = A1+A2
    B3 = B1+B2

    is just as easy for a human to parse as

    A3 = A1.concat(A2)
    B3 = B1.add_element(B2)

    I disagree.
  • by Piquan ( 49943 ) on Thursday August 12, 2004 @11:08PM (#9955339)

    I think that he was griping about the distinction between what you can do with a function, and what you can do with a lambda. In Lisp, you can put whatever you want in a lambda. In Python, you can only have a single expression.

    Example, with _s added to deal with ECODE's idiocy about leading spaces:

    _;; v1, in Lisp:
    _(defun make-spammer (n)
    ___#'(lambda (stream)
    _______(format stream "~A tons of spam!~%" n)))
    _# v1, in Python:
    _def make_spammer (n):
    _____return lambda stream: stream.write('%d tons of spam!\n' % n)
    _;; v2, in Lisp:
    _(defun make-spammer (n)
    ___#'(lambda (stream)
    _______(dotimes (i n)
    _________(format stream "A ton of spam!~%"))))

    As far as I know, you can't write v2 in Python using a lambda.

    Of course, somebody else pointed out that you can create a named function and use it, as in the following example. But that can sometimes be rather inconvenient.

    _# v2, in Python:
    _def make_spammer (n):
    _____def fn (stream):
    _________for i in range(n):
    _____________print "A ton of spam!"
    _____return fn
  • by Anonymous Coward on Friday August 13, 2004 @12:27AM (#9955748)
    was to learn python. I used it in my previous job for rapid development (easy interfacing with C, clean code, etc etc) and it did the job. But in the end (looking for a new job) this python experience is pretty much useless... everybody wants .net / .com /.c++ experience and nobody's even heard of python... they thought I was taking the piss... probably would've had a better chance mentioning perl or php.

    Anyway, I hope it's not going to take me a year to learn c++ to the same level I can do python because there are better places I could think of statying in than my parent's basement...
  • by Anonymous Coward on Friday August 13, 2004 @06:52AM (#9957000)
    I agree that tool availability is an important reason for selecting Java. Most "XXX vs Java" comparisons tend to assume that one is using some form of simple text editor (e.g. Vi, Notepad) to write code, yet few Java programmers work this way due to the plethora of IDEs (open source and commercial) and specialist editors (e.g. JEdit) that exist. These take a lot of the drudge-work out of Java programming by having:

    1) Systems that automate "boring-to-write" stuff such as RMI/CORBA/etc. classes/stubs, interface implementations, pure virtual method overrides in derived classes, etc.

    2) Refactoring support. This is not merely in the "nice to have" category if you have large amounts of legacy code to maintain and expand.

    3) Integrated debugging facilities which assume that one will be writing distributed, multi-threaded code.

    4) Javadoc integration that makes documenting one's classes a doddle.

    5) Ant and other build script integration.

    6) Automated use of CVS and other version control systems.

    7) Extensible architectures that allow easy integration of third party add-ons.

    8) Context-sensitive on-line help, javadoc searching for information on user-written classes, automatic method parameter prompting, and other stuff that can be a big help when writing code.

    Thus, while a Java listing may seem wordier and more complex than (for example) a Python equivalent, one must consider the fact that (a) most Java programmers won't have to write it all by hand, and (b) they will likely spend a lot less time managing, debugging, and refactoring when working on large projects.

    Note also that those who want to use Python, Lisp, Rexx, Smalltalk or whatever can do so from within Java - alternatively, they can avail themselves of those languages' facilities while maintaining Java-like syntax semantics. Have a look at: l

    for some of the language options available to Java programmers.

"It takes all sorts of in & out-door schooling to get adapted to my kind of fooling" - R. Frost