5 ms·
Not true, I remember a few years back being a major Perl shop. The advice from senior guy in the hierarchy to use Python was 'If Google is using it, it must be
by kamaal 16y ago
Not true, I remember a few years back being a major Perl shop. The advice from senior guy in the hierarchy to use Python was 'If Google is using it, it must be good'. And I know whole bunch of people around me in many projects used it just because of Google.
Every tool has its own merit Python is nothing special in this regard. Python's low barrier to entry has invited many newbie's to pick it up in a day or two and get going with solving problems. But it has its own flaws and isn't that great as often people project it to be.
My own experience with Python, after being a heavy Perl and Ruby user isn't that good. Especially if you are coming from a language like Perl, Python as a language has an interesting trend. At first you feel very happy that things are so simple with it. Then slowly once you learn the language and start getting deeper into it, you try to use it for day to day work. Suddenly you realize that text processing sucks badly, something that is very big problem on Unix based environments. Writing a single regex takes a 10's of lines of exception handling. You try to use it for quick dirty scripting, again the language runs out of steam very soon. Its just too verbose for scripting class.
Now coming to more important reasons. Sacrificing power for readability might be great for newbie's but isn't good experienced programmers. Lack of multiline lambda's, no good support for TOC, GIL, barely there object system(compared to Moose), lack of extensibility, lack of syntax plugins. Forcing one way of doing things, all this is great hindrance if one wants to climb upper steps in the ladder of programming. And above all lack of thing like CPAN is just something more than sufficient reason above everything else.
I left Python for Perl, but had to go back again. Python wasn't just serving the need for day to day quick scripting. Which I often need to do twice or thrice a day. Text is uneliminable part of large IT projects. Tools like Perl, sed , awk help me do my job quickly everyday.
Slowly I realized if I'm using Perl every 50 minutes, I might as well use it for long term projects. On the other hand, Best practices matter for every project. You can writeable and un maintainable code both in any language.
We are back to being a Perl shop again. And its the best decision we have made.
- deleted 16y ago[deleted]
- jergosh 16y agoIncidentally, I'm working on a language comparison which includes Perl and Python and I would be interested to see how Perl string handling is superior. Did you mean speed or syntax or both? I always thought that the Perl way is quite friendly if you have Unix background, but since Python does everything by function calls it's also fine. As for exception handling, I guess it'll always be shorter in Perl since it doesn't really support exceptions...
- kamaal 16y agoPerl has exception handling, its only that its not available via your usual try-catch syntax. If you want a more sugary exception handling syntax there is always Try::Tiny ( http://search.cpan.org/~doy/Try-Tiny-0.09/lib/Try/Tiny.pm http://search.cpan.org/~doy/Try-Tiny-0.09/lib/Try/Tiny.pm). Another advantage Perl has over Python in case of parsing is that regular expressions are first class elements in Perl, so they can be passed around like objects. Combine them with more powerful things like given-when(http://perldoc.perl.org/perlsyn.html#Switch-statements http://perldoc.perl.org/perlsyn.html#Switch-statements) and parsing becomes a lot more easier when compared to Python. Smart matching is a great feature. And all this obviously leads to better performance in terms of speed because less code to process means (to an extent faster code). And syntactically as well. Imagine doing such a thing in Python. There isn't smart match operator at the first place, there is no switch statement, and on top of that dealing with innumerable regular expression functions(compile,match,search) with try-catch statements inside if-else loops. This piece of code in Python won't be easy to read and solution isn't elegant and better than Perl either. Perl turns out to be better in all ways, the code is readable, concise, faster and powerful.
- jergosh 16y agoYeah, it's through eval() which is a questionable design decision at best. Regular expressions can be passed as objects in Python, too. Three functions is hardly 'innumerable'. "Perl turns out to be better in all ways, the code is readable, concise, faster and powerful." To each his own, I guess.
- 16y ago
- falcolas 16y agoWithout knowing anything about what you do aside from what you've written here, it seems like you've fallen into the same trap that most folks who move from Perl to Python fall into. They are used to having the swiss army knife of string tools with regex, and don't know what to do when handed the complete toolchest of specialized string tools that Python provides. I do a fair amount of text parsing in Python for my job, and only very rarely import the regular expression module - because most of the time I don't need it. My code is faster and more easily read for it, as well.
- jimbokun 16y agoWhat non-re modules should I look at for text processing in Python?
- kamaal 16y agoCould you please explain how I don't know anything about what I do aside from what I've written?(I don't know how you make such a comment without knowing anything about me). And what are those specialized toolchest of string tools that Python offers? I have clearly explained(In comments above and below) Perl's 'tool chest', now can you please explain how Python 'tool chest' beats it? Seems, languages like Python and Java are best when all your application needs a glue between one part of architecture(webserver, UI etc) and other(database, XML, JSON). Or at maximum some extra stuff like sockets. The problem with Python sort of languages starts when you alter you inputs and outputs such that they are no longer standard and structured. All examples that Python folks give as superiority of Python over Perl come around in areas where data input is structured enough. Things like scientific computing, web programming(Interaction with databases, XML, JSON). There are a lot of languages which can do this, The actual challenge is in areas dealing with unstructured data. There are very few languages which offer convenient tools to deal with those sort of problems. Unfortunately Python isn't one of them
- loevborg 16y agoDid you really misunderstand your parent? Strictly speaking "without knowing..." should refer to the subject of the main clause, but it is clear that he (your parent) intendend himself to be understood as the potentially ignorant person.