I bought Learning Python a couple days ago and have read maybe 100 pages in.
It’s no wonder people who like Objective-C like Python!
You get…
– Typeless variables, like Objective-C’s id
.
– Garbage collection without Java.
– String addition using overloaded + without C++.
– Automatic upgrading of numeric variables, something you can’t do with C types like int
, float
, etc.
– Mutable and immutable collection types like in Foundation.
What’s not to like?
What’s not to like? Having whitespace be meaningful. *shudder*
What’s to like better: Ruby. 😉
The whitespace issue is a non-starter for me for Python. I just haven’t been able to take it seriously. It feels too much like it was created in the 1960s, like MUMPS was (and unlike I was with MUMPS, I’m not getting paid to learn Python). My kingdom for an end statement!
I have also had trouble with the syntax, which seems really messy to me, but I haven’t dived down to figure out why.
Of course, it might be the book I’m using to learn Python: Mark Pilgrim’s Dive Into Python (http://www.amazon.com/exec/obidos/ASIN/1590593561/michaerawdonshom ), which I’ve found extremely difficult to read.
Contrast with Thomas Fowler & Hunt’s Programming Ruby (second edition out now! http://www.amazon.com/exec/obidos/ASIN/0974514055/michaerawdonshom ), which I find terrifically readable (like the language) and a great reference besides.
I’ve been doing a lot of programming in Ruby, and find it has all the advantages you list of Python, and in addition is readable and intuitive. It is not as mature a language as Python (it’s considerably newer, I think), but it’s got just about everything I want.
… and you can have the best of both worlds by using PyObjC, which puts the Java/Cocoa bridge to shame.
The whitespace turns out not to have been a good idea. It makes it difficult to paste code in from web pages. I’ve seen Python gurus post help on newsgroups with all indentation removed because they messed up their mailer settings. I have to be extra careful if I want to generate a Python script mechanically.
(Discount everybody who says, “Meaningful whitespace is always bad.” They haven’t thought about it, so their opinion is worthless.)
The syntax is also more verbose than I’d like. Certain things (like lambda) are too much trouble and too restricted. It’s strayed a little from it’s clean lines in recent years (the syntax for generators, for instance, is opaque).
I’ve also come to like Ruby, although it has its own big annoyances. (It really bugs me that you can call methods without brackets, because it means I can’t say “funcptr = foo.bar”, since foo.bar is a method call. There’s some syntax to get the function instead of calling it, but I shouldn’t need that!) I’ve discovered that some of the cool language-extension stuff I’ve done with Python has Ruby equivalents that are even easier and more powerful, but will crash the interpreter if you don’t implement them right, which makes me worry about the implementation – I’ve never been able to crash the Python interpreter.