Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Howdy Monks,
I've used Perl in the past and was quite happy with it. But lots of folks use Python nowadays. So what is Perl better at than Python? Is my time better spent learning Perl or Python? And Perl faster than Python, especially when it comes to creating reports from text and putting in CSV or excel? Can Perl do parallel processing better than Python and most importantly, does regex and Perl Modules for CSV, ssh, excel, REST etc play well with parallel processing? I don't know anything about parallel processing but I'm sure I'll need it hence asking, because there's some text files that go 10000 lines or some that are 200MB PLUS in size..Asked a friend and he said Python is better at parallel processing so jus wanna know.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: What's Perl good at or better than Python. (FAQ)
by LanX (Saint) on Oct 15, 2021 at 20:31 UTC | |
That's a FAQ, please see Re: Honest question about Perl, Python and Ruby (Comparing Programming Languages References) by revered brother eyepopslikeamosquito
update> because there's some text files that go 10000 lines or some that are 200MB PLUS in size The bottleneck for file-processing nowadays is the filesystem and it can't be parallelized. I.O.W. even if you use a language which is dozens of times slower you will hardly notice. That's because the process is mostly waiting for the disk to deliver.
Cheers Rolf | [reply] [Watch: Dir/Any] |
Re: What's Perl good at or better than Python.
by stevieb (Canon) on Oct 17, 2021 at 05:21 UTC | |
What's Perl good at or better than Python. Making me money. I make a whole lot more money doing Perl work than I did when I was coding in Python. A company can hire 50 people out of school, then another 50 who have been in the field a few years to write Python for a dime a dozen. Perl experts are much, much harder to come by, so the jobs typically pay far more. I work for a company doing full time Perl work, and I still have several very well paying clients who use my services several times per year. The hourly rate for those clients is significantly more than I could (and have) made by doing similar work in Python. With that said, the jobs are much harder to come by. You're all but guaranteed a job if you're worth your salt with Python coding. Perl is and always been hands down my favourite language, and I never see that changing. I even prototype most of my code in Perl for most of the other languages I write in (C/C++, C#, Python etc), even my microcontroller code before I write it. | [reply] [Watch: Dir/Any] |
by LanX (Saint) on Oct 17, 2021 at 17:53 UTC | |
Which will drive the companies further away from Perl ... :( Don't you think?
Cheers Rolf | [reply] [Watch: Dir/Any] |
Re: What's Perl good at or better than Python.
by Marshall (Canon) on Oct 17, 2021 at 00:07 UTC | |
Python will be much less efficient than Perl in multi-threaded applications due to the GIL (Global Interperter Lock). To get around that, Python provides the multiprocessing module to run multiple instances of the Python interpreter on separate cores. State can be shared by way of shared memory or server processes, and data can be passed between process instances via queues or pipes. You still have to manage state manually between the processes. Plus, there’s no small amount of overhead involved in starting multiple instances of Python and passing objects among them. Perl multi-threading can be quite efficient. This is best seen in a "number crunching" task. I had one job with 20K items to process. Processing each object required a lot of CPU. When I split the job onto 4 cores, the overall task completed 3.7-3.8x faster. You can't get 4x because there is some OS and intra-thread overhead. I haven't coded that application in Python, but if I did, I don't expect those excellent results.
Python requires obscure statements to increase speed. Python is now the most popular programming language - there is little doubt about that because it is being taught in essentially all CS curricula world wide. If you are processing some very large file, with a very small amount of processing per line, multi-threading won't help at all if you are reading the file in serial, linear fashion. The processing time will be dominated by the time to read the file from disk! Even doing something complicated and "tricky" to say give 1/4 of the file to each of 4 threads won't help because at the end of the day, how fast you can read the bits off of the disk will be limiting (assuming again the processing per line is relatively "cheap"). Update: And Perl faster than Python, especially when it comes to creating reports from text and putting in CSV or excel? Perl has C libraries for CSV stuff - they run very quickly. I suppose that Python has those also. I am not sure that it makes much difference. We would have to write some benchmark code. Update2: Some years ago, I talked with a guy who wrote code for the high volume day commodity trading market in Chicago. They used Perl to parse the incoming trades and then C to crunch the data for the actual trading algorithms. I would have thought that C would have been used for all of it. But evidently not true (at least at the time). Perl is quite good at the right job. | [reply] [Watch: Dir/Any] [d/l] |
Re: What's Perl good at or better than Python.
by perlfan (Vicar) on Oct 16, 2021 at 17:59 UTC | |
Use Perl if: | [reply] [Watch: Dir/Any] |
by stevieb (Canon) on Oct 17, 2021 at 05:27 UTC | |
Both Python and Windows work equally well regardless of the OS. In fact, I code in both languages on both Unix and Windows, and even use the same IDE cross-platform and in many cases, cross-language. About the jack of all trades comment... I'm a jack of all trades in both languages, but I've also written some extremely complex and significantly focused applications and suites using both Perl and Python. In reality, it was Perl that allowed me to become such a good jack of all trades. That skill just transferred over to other languages nicely. | [reply] [Watch: Dir/Any] |
by Marshall (Canon) on Oct 17, 2021 at 04:40 UTC | |
The sheer number of new people who are learning Python vastly exceeds the number of new people who are learning Perl. The huge amount of code that is currently being written in Python will ensure its longevity. From what I can see, continuing Python 3.X releases show a vibrant language that is expanding with new features and capability. I will confess to also being somewhat of a "Perl bigot" and I love Perl. However, Python is a "growing force" whether we "like" it or not! There will be certain tasks that Perl is much better at than Python. There will also be a lot of tasks where the difference just doesn't matter. | [reply] [Watch: Dir/Any] |
Re: What's Perl good at or better than Python.
by Anonymous Monk on Oct 16, 2021 at 14:00 UTC | |
I have heard it said that Python is faster than Perl, but the only actual comparison I have done (parallel implementations of Conway's "Life") says that Perl is slightly faster but Python has a slightly smaller memory footprint. My opinion is that if speed is truly a consideration you will reject both languages in favor of a compiled language. My C implementation of Life had a much larger memory footprint (no readily-available hash implementation) but was orders of magnitude faster than either Perl or Python. | [reply] [Watch: Dir/Any] |
by eyepopslikeamosquito (Archbishop) on Oct 16, 2021 at 22:24 UTC | |
Multiple implementations of Conway's game of life in Perl and C with a focus on performance. Really? Any chance of seeing your source code? A few years back I became a bit obsessed with implementing Game of Life in both Perl and C++, as described in detail at: The benchmark timings above were for running the famous Lidka Methuselah for 30,000 generations. The code that produced the fastest benchmark times can be found here: Summary: The C++ version of the simple GoL algorithm was 450/36 = 12.5 times faster than the Perl version; memory use was 2.8 less, 517,340K v 1,455,004K. For the complex GoL algorithm, C++ was 17/0.08 = 212.5 times faster; memory use was 10.1 times less, 69,632K v 700,000K. The code that produced the fastest early benchmark times for Rosetta Code: Long List is Long can be found here: TODO (maybe): Benchmark Perl vs C++ for Rosetta PGA-TRAM and Rosetta Code: Long List is Long (and write a performance meditation with the results of GoL, PGA-TRAM, Long-List-is-Long). PGA-TRAM Benchmark done: Risque Romantic Rosetta Roman Race Update Instructively, tweaking the Perl code, via a long series of micro-optimizations, reduced the running time from 1635 secs to 450 secs (3.6 times faster), while finding a better algorithm reduced it from 450 secs to 17 secs (26.5 times faster). Similar numbers for the C++ code confirm the old Kernighan and Plauger adage: "Don't diddle code to make it faster -- find a better algorithm". Further Update
> My C implementation of Life had a much larger memory footprint (no readily-available hash implementation) This is very surprising! I suspect your implementation of hashes in C was sub-optimal. :) In my GOL code, the C++ version consistently had a much lower memory footprint than the Perl version. As detailed here the memory footprint of the fastest versions when hit with a nasty three million cell test case: 69,632K for my C++ version, 700,000K for my Perl version, and 18,138,504K (i.e. 18 GB!) for CPAN Game::Life::Infinite::Board. Performance References Added Later
Game of Life References Added Later
Rosetta Code (Many Different Languages)
Extra:
References on Comparing Programming Languages Added Later
See Also
| [reply] [Watch: Dir/Any] |
Re: What's Perl good at or better than Python.
by Anonymous Monk on Oct 19, 2021 at 22:45 UTC | |
| [reply] [Watch: Dir/Any] [d/l] |
Re: What's Perl good at or better than Python.
by Anonymous Monk on Oct 15, 2021 at 21:02 UTC | |
Ok, first reply and no hate, this was unexpected 😀. Just some good logical answer and update. You folks are not fanboys. But may be I said that too soon 😂 | [reply] [Watch: Dir/Any] |