On Fri, 16 Feb 2007, Alan Burlison wrote: > Al Hopper wrote: > > > These days I write Python and find the resulting code far more readable > > than Perl. The time to develop in Python or Perl is about the same - but > > I've found even my own Perl code difficult to grok (in as little as) 2 or > > 3 months down the road. My personal experience is that, the more > > experienced a Perl developer is, the more difficult the resulting code is > > to grok and really good Perl developers produce code that is almost > > indecipherable. > > > > I'm not trying to start a Perl/Python war and too busy to participate in > > one .... but, please consider alternatives other than Perl. > > It's got absolutely *nothing* to do with the language, it's all about > coding style. Here's a case in point that came up only yesterday, a bit > of python and a bit of perl that do the same thing - print a specific > directory from the system search path, or print a blank line if the path > can't be found: > > $ python -c 'import sys;print([p for p in sys.path if > p.endswith("/site-packages")]+[""])[0]' > /usr/lib/python2.4/site-packages > > $ perl -e 'print((grep(m{/site_perl$}, @INC),"")[0],"\n")' > /usr/perl5/site_perl > > Which is the easier to read? I'd say the perl version is (slightly) > easier, not least because it is shorter and because perl treats regexps > as first-class citizens of the language. However, that's not the point,
Agreed (+1 for Perl because it "treats regexps as first-class citizens of the language"). But ... your supposition assumes that you already know what "@INC" means! > the point is that you could express both with a more 'traditional' > iteration over an array ('for', 'while' etc) containing a nested > conditional test and they'd look remarkably similar. Agreed. > I'm not a pythonhead, but I suspect that if I wrote python it would look > very much like the perl I write (dumb-ass indentation rules aside). The ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A lot of developers see this as a learning block to getting up to speed with Python. I agree that it is a learning block - but one that is overcome in a matter on minutes - usually accomplished with the simultaneous utterance of a bunch of 4 lettered words. > point of either of the languages is that they allow you to be terse (and > therefore "indecipherable"), but neither language forces you to do this. Agreed. But there is a natural tendency for developers to continue to use terse/indecipherable constructs once they (personally) have mastered them. > I suspect because of the relative ages of the languages there are fewer > python propellerheads around than there are perl ones, so python tends > to be written in a more long-winded way not because you can't cast > spells in it, but because there aren't quite so many python wizards > around (yet). I can't agree with this - OTOH, one of the downsides of Python is that subtle changes are made from one rev to another (2.2 -> 2.3 -> 2.4) which is unhelp for the developer whose primary langauge is C or Java and who uses Python for Q&D (Quick & Dirty) type scripts. > If we are going to mandate a particular language, let's do so on I would never mandate a particular language - but for Perl (heads) who have not looked outside Perl for more that 12+ months, I would urge them to re-evaluate their choice of preferred scripting language/environment. > something other than the ability of expert users to write executable > line noise in it. Again - agreed. No black/white answer :( - like most things in real life - a compromise. Regards, Al Hopper Logical Approach Inc, Plano, TX. [EMAIL PROTECTED] Voice: 972.379.2133 Fax: 972.379.2134 Timezone: US CDT OpenSolaris.Org Community Advisory Board (CAB) Member - Apr 2005 OpenSolaris Governing Board (OGB) Member - Feb 2006 _______________________________________________ tools-discuss mailing list tools-discuss@opensolaris.org