Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: John Bokma Newsgroups: comp.lang.python Subject: Re: Why did Quora choose Python for its development? Date: Tue, 24 May 2011 20:48:30 -0500 Organization: Castle Amber Lines: 137 Message-ID: <87ipszsg7l.fsf@castleamber.com> References: <80d59383-36a3-4744-85c4-1a0577f1d3a6@dr5g2000vbb.googlegroups.com> <9CDC4B2CD1F445E994119A50F65155DF@teddy> <12225671E9654FECB49613D915FAEC19@teddy> <21A740B7AC6644248476DFADDF726C73@octavian> <629DAC3611EA49B0A36BCF70151CDE2F@octavian> <87sjs44qyk.fsf@castleamber.com> <87zkmcujl4.fsf@castleamber.com> <20110524133902.b5ad22b1.darcy@druid.net> <87mxibsn9l.fsf@castleamber.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net JsTkUr+50PaifF3htzEKBAKwTOrBejHR7E8hT17YshUzXQXkaa Cancel-Lock: sha1:gjcUJ95jqmbolmLDuG1azj9ofdE= sha1:PNmb6MN6+11GkAvPD9UmCoZI1ic= X-Url: http://johnbokma.com/ User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6192 Chris Angelico writes: > On Wed, May 25, 2011 at 9:16 AM, John Bokma wrote: >> Chris Angelico writes: >> >>> Yes, I believe that was Perl. And an amusing quote. But most of the >>> point of it comes from the fact that Perl uses punctuation for most of >>> its keywords, >> >> For example? >> >>> whereas (say) Python uses English words; it's a lot more >>> fun to crunch something down when you can use $| >> >> That's not a keyword but a special (global) variable. On top of that, >> you don't have to use it [1] and most people most likely encounter this in >> (badly) written CGI scripts originating in the last century. > > Okay, poor example. But there's a lot of Perl that uses concise > notation for things that in Python are keyworded; for instance, > regular expressions. Perl does have indeed operators for matching and substitution. It's: ( my $foo = $bar ) =~ s/ ... / ... /; versus foo = re.sub(r" ... ", " ... ", bar ) and: my $foo = qr/ ... /xi; versus: foo = re.compile(r""" ... """, re.IGNORECASE|re.VERBOSE) It's just a matter of taste IMO. The regular expression noise stays the same ;-). >>> and friends than when you have to put "x and y", complete with spaces, >>> for a simple boolean. >> >> Perl has also the and logical operator. This is legal Perl: >> >> if ( $x and $y ) { >>  print "yes\n"; >> } > > That's at a completely different precedence level, isn't it? Yes, /but/ in this case it doesn't matter. Of course there are cases that it /does/ matter: > For instance: > > $a = $b && $c ? $e : $f; > # versus > $a = $b and $c ? $e : $f; > > The first one is an assignment to $a, conditional on two variables. > The second is an unconditional assignment to $a, and then based on > that, evaluates either $e or $f and does nothing with it. > > Python: > a = e if b and c else f Yes, "recently" added to the language, before that you had to and or your way out of it (or use lambdas). > It's pretty similar, actually (although, coming from a C background, I > do prefer to have the condition first); but I could crunch the first > one down a lot, while the last one is almost as tight as it can be. > > $a=$b&&$c?$e:$f; > a=e if b and c else f > > It's that crunched appearance that makes Perl look like line noise, So you just agree with what I earlier wrote: one /can/ write harder to read in Perl, like you can jump off a cliff. And I have seen a lot of extremely badly written Perl code, but never seen a disaster like the one above ;-). > and the open keyworded appearance that makes Python look like > pseudocode. But that's not necessarily a good thing; a courteous > programmer can space out Perl to keep it readable, and he then has the > option of crunching pieces that are 'logically one' and spacing out > the parts that aren't: > > $a= $b&&$c ? $e : $f; > > Silly, contrived example, but in production code I've often had > situations where it makes sense to space out one part of an expression > and crunch another. And when everything's an English word, that's not > an available option. I would write it like $a = ( $b and $c ) ? $e : $f; > That said, though, I do find Python a lot easier for reading other > people's code in. A LOT easier. Like I wrote earlier: I find Perl easier to read. And honestly, I don't know why. Partially it might have a lot to do with having been exposed to it much more. But many years back, when I could pick between several languages, Perl was the one that stuck with me. And that was before everybody and his mom was hacking CGI scripts in Perl (badly). And while I do want to switch to Python (or use it more often), for one reason or another it's hard. Maybe it's for similar reasons that one loves Spanish but hates German as a second language (or vice versa)? Both Perl and Python are evolving. Perl has a lot of bagage from the beginning, and more so since a lot got slapped on later on. Things are changing, but you just can't make major changes since people, like me I guess, are used to how things are right now. I now and then have peeks at Perl 6 and each time my first reaction is: this is Perl only in name; it's very, very different. On the other hand it still shares what I consider warts with Perl 5. -- John Bokma j3b Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/ Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html