79a9c618260d9ee7203b19f22351e9ca91cda84a
commit 79a9c618260d9ee7203b19f22351e9ca91cda84a
Author: Simon Watson <spw01@protonmail.com>
Date: Wed Feb 16 08:24:17 2022 -0500

Bleh. Think I need to change directions here.

diff --git a/in-defense-of-perl.org b/in-defense-of-perl.org
index e31ccf2..d455ac1 100644
--- a/in-defense-of-perl.org
+++ b/in-defense-of-perl.org
@@ -320,8 +320,87 @@ gopher://

* Perl is /fast/

- You're right. It's not as fast as C, but below I will try and show that for a lot of cases, Perl is
- much faster than it's main competition, Python. Particularly in heavy regex/text streaming applications.
+ You're right. It's probably not as fast as C, but below I will try and show that for a lot of cases, Perl is
+ much faster than it's main competition, Python. Particularly in certain domains.
+
+ Note: I know bench marking can be delicate and if not handled carefully produce poor data and poorer conclusions.
+ I've tried to be as fair and accurate as possible in these comparisions, and I'm making an effort to act in
+ good faith. If you believe I've made a mistake or that there is a faster way to do something, please let me know.
+
+ In the basic example below, generate a file with 1,000,000 newline separated 5 char strings:
+
+ Perl:
+ #+BEGIN_SRC perl
+ #!/usr/bin/perl
+ # perl --version | head -n2 | tail -n
+ # This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux
+
+ use strict;
+ use warnings;
+
+ my @chars = ( "A".."Z" );
+ foreach ( 1..1000000 ) {
+ my $string = "";
+ foreach ( 1..5 ) {
+ $string = $string . $chars[ rand @chars ];
+ }
+ print("$string\n");
+ }
+ #+END_SRC
+
+ Result:
+ #+BEGIN_EXAMPLE
+ /tmp/tmp.G5LzZmzDQq λ time ./gen_words.pl > output.txt
+
+ real 0m1.065s
+ user 0m1.031s
+ sys 0m0.003s
+ #+END_EXAMPLE
+
+ Python:
+ #+BEGIN_SRC python
+ #python -V
+ #Python 3.10.2
+ import string
+ import random
+
+ word_list = list(string.ascii_uppercase)
+ print(random.choice(word_list))
+
+ for x in range(0,1000000):
+ string = ""
+ for y in range(0,5):
+ string = string + random.choice(word_list)
+
+ print(string);
+
+ #+END_SRC
+
+ Result:
+ #+BEGIN_EXAMPLE
+ /tmp/tmp.G5LzZmzDQq λ time python gen_words.py > output2.txt
+
+ real 0m3.986s
+ user 0m3.968s
+ sys 0m0.011s
+ #+END_EXAMPLE
+
+ Python ends up being almost 4x slower here.
+
+ In the basic example below, given a file of 1,000,000 newline separated 5 char strings, return how many are valid
+ words.
+
+ #+BEGIN_SRC perl
+ #!/usr/bin/perl
+
+ use strict;
+ use warnings;
+
+ foreach {
+ }
+
+
+ #+END_SRC

* There is no better Unix glue

@@ -334,6 +413,7 @@ gopher://

* Feedback/Topics/Notes To cover

+ - Top 10 things not to do in Python code
- People prefer python as more people know it
- Perception python stdlib is more complete
- People like Perl for it's portability