On 2026-10-24 00:57, tusooa wrote:
Reply is below quoted content.
On Friday, October 23, 2026 1:25:01 a.m. Eastern Daylight Time Michael Galea via Talk wrote:
Alack and alas, I still like perl better than python though I code in each.
I have some perl programs that I want to pass on to my son, who knows python but not perl. So I converted the perl to python. Here are the line counts and the character counts for each: wc -l taxcalc.* 1305 taxcalc.pl 2157 taxcalc.py
ls -la taxcalc.* 64340 Sep 27 18:52 taxcalc.pl 77980 Sep 28 00:32 taxcalc.py
time taxcalc.pl .... 1>/dev/null; real 0m0.070s time taxcalc.pl .... 1>/dev/null; real 0m0.073s
The code implements the Federal/Ontario tax code, and I verify both programs output against the other, to the character, of output
In truth, I don't find the python much easier to understand or code for, although I have to admit I am more proficient in perl than in python. In perl I do 'print "index $index \n"; in python I do `print(f"index {index}")` Which seems more straightforwards to you?
-- Michael Galea
I would rather write 'say "index $index";'. With 'use 5.012' or so though.
Syntax of Python is obviously more verbose and less flexible, and there is nothing other than 'print reverse <>' that better demonstrates the ability of Perl to take shortcuts. (But hold on, never pass it with untrusted arguments, otherwise it's arbitrary code execution) Well, and there are things like 'print (2+3)*2' or `use constant CONST => 'a'; print $hash{CONST}` which will likely behave in a way unexpected by those who are not very familiar with Perl.
(Or something like https://github.com/karenetheridge/Tie-RefHash/commit/ 3dd3f18994f293307fff07be1d3a7e64e7d440df . I was able to spot the bug immediately upon seeing the code because I browsed metacpan / perldoc for fun)
So to me both languages have strengths and weaknesses, for example Perl does not have explicit typing and booleans are painful (when you want to convert to/from something like JSON), and there is poor multithreading; while with Python one probably won't have the best experience writing many regular expressions, or trying to pass or return lambda functions. It really depends on the use case.
Best regards, tusooa
Interesting. I use print rather than say, because I like my perl to look like C. I think that a world of issues that perl detractors posit, can be dealt with by restricting the language features and enforcing a clear style (perltidy is your friend).
------------------------------------ Description: GTALUG Talk Unsubscribe via Talk-unsubscribe@lists.gtalug.org Start a new thread: talk@lists.gtalug.org This message archived at https://lists.gtalug.org/archives/list/talk@lists.gtalug.org/message/J562A37...
-- Michael Galea