<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Perl - Tag - In a past life…</title>
        <link>https://archive.jtimothyking.com/tags/perl/</link>
        <description>Perl - Tag - In a past life…</description>
        <generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 23 Jan 2022 21:31:22 &#43;0000</lastBuildDate><atom:link href="https://archive.jtimothyking.com/tags/perl/" rel="self" type="application/rss+xml" /><item>
    <title>The Weaknesses of Your Programming Language: a lament</title>
    <link>https://archive.jtimothyking.com/2022/01/23/the-weaknesses-of-your-programming-language-a-lament/</link>
    <pubDate>Sun, 23 Jan 2022 21:31:22 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2022/01/23/the-weaknesses-of-your-programming-language-a-lament/</guid>
    <description><![CDATA[<!-- wp:paragraph -->
<p>One of the questions we have asked potential recruits at The Perl Shop is, "What do you feel are weaknesses with Perl?" I feel it's high time that I give my own answer to that question.</p>
<!-- /wp:paragraph -->
<!-- wp:more -->]]></description>
</item>
<item>
    <title>On Returning to Java from Perl</title>
    <link>https://archive.jtimothyking.com/2020/04/11/on-returning-to-java-from-perl/</link>
    <pubDate>Sat, 11 Apr 2020 03:29:27 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2020/04/11/on-returning-to-java-from-perl/</guid>
    <description><![CDATA[<!-- wp:image {"align":"right","id":7191,"width":258,"height":172,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="alignright size-large is-resized"><a class="lightgallery" href="/2020/04/11/on-returning-to-java-from-perl/art-blur-cappuccino-close-up-302899.jpg" title="/2020/04/11/on-returning-to-java-from-perl/art-blur-cappuccino-close-up-302899.jpg" data-thumbnail="/2020/04/11/on-returning-to-java-from-perl/art-blur-cappuccino-close-up-302899.jpg">
        
    </a></figure></div>
<!-- /wp:image -->
<!-- wp:paragraph -->
<p>The last time I did any serious (or semi-serious) work in Java was in 2006. I used J2EE 5.0, which was the current version at the time, to demonstrate how we could migrate our enterprise web app package from spaghetti C++ to a more soundly architected framework in which most of the low-level work was done for us. I used Jetty as a servlet container for the demo because it was lightweight and easy to get going in a dev environment, although there were other options (most notably Tomcat). That was a long time ago and many versions away. I went into full-time LAMP work with Modern Perl and became a full-stack web developer.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>My current circumstances have encouraged me to revisit Java. Firstly, I have some experience with it. I started by going through the Java practice challenges on HackerRank. I'm pleased with how easily it all comes back to me. I guess programming is like riding a bike. I'm using Java for all the online coding assessments as I look for work (except for the Perl positions). And I'm putting together a <a href="https://github.com/JTimothyKing/TicTacToeJ" class="aioseop-link">Java version of a TicTacToe app</a>.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>This has inspired some thoughts on the current Java ecosystem… and how it compares to the Modern Perl ecosystem.</p>
<!-- /wp:paragraph -->
<!-- wp:more -->]]></description>
</item>
<item>
    <title>My Recent Posts at The Perl Shop Blog</title>
    <link>https://archive.jtimothyking.com/2018/06/28/my-recent-posts-at-the-perl-shop-blog/</link>
    <pubDate>Thu, 28 Jun 2018 21:11:56 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2018/06/28/my-recent-posts-at-the-perl-shop-blog/</guid>
    <description><![CDATA[<p>I also blog over at <a href="http://blog.theperlshop.com/">The Perl Shop Blog</a>. Most of what I write about Perl anymore is over there.</p>
<p>My recent pieces include:</p>]]></description>
</item>
<item>
    <title>The Most Powerful Programming Paradigm in the World?</title>
    <link>https://archive.jtimothyking.com/2014/03/27/the-most-powerful-programming-paradigm-in-the-world/</link>
    <pubDate>Thu, 27 Mar 2014 22:34:35 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2014/03/27/the-most-powerful-programming-paradigm-in-the-world/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2014/03/27/the-most-powerful-programming-paradigm-in-the-world/Cornell-Facebook-Camp-Hackathon-Benjamin-Golub.jpg" title="Cornell Facebook Camp Hackathon (photo by Benjamin Golub)" data-thumbnail="/2014/03/27/the-most-powerful-programming-paradigm-in-the-world/Cornell-Facebook-Camp-Hackathon-Benjamin-Golub.jpg" data-sub-html="<h2>Cornell Facebook Camp HackathonPhoto by Benjamin Golub</h2><p>Cornell Facebook Camp Hackathon (photo by Benjamin Golub)</p>">
        
    </a><figcaption class="image-caption">Cornell Facebook Camp Hackathon<br />Photo by Benjamin Golub</figcaption></figure>
<p>I&rsquo;m not a hackathon kinda guy. I don&rsquo;t get off on solving hard or novel problems. I don&rsquo;t believe in contests. I&rsquo;m not particularly energized by the idea that a whole bunch of us are trying to solve the same problem at once— I do believe in community, and I appreciate being able to interact with other developers, but on a different level than just getting into the same (virtual or physical) room together, eyes to the computer screen.</p>
<p>So why then did I participate in the Dallas/Fort Worth Perl Mongers
Winter 2013 Hackathon?</p>]]></description>
</item>
<item>
    <title>Mopping up with Perl</title>
    <link>https://archive.jtimothyking.com/2014/03/13/mopping-up-with-perl/</link>
    <pubDate>Thu, 13 Mar 2014 16:43:17 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2014/03/13/mopping-up-with-perl/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2014/03/13/mopping-up-with-perl/30-Ways-to-Shock-Yourself-2-Bre-Pettis.jpg" title="30 Ways to Shock Yourself #2, photo by Bre Pettis, from the book Elektroschutz in 132 Bildern" data-thumbnail="/2014/03/13/mopping-up-with-perl/30-Ways-to-Shock-Yourself-2-Bre-Pettis.jpg" data-sub-html="<h2>30 Ways to Shock Yourself #2,photo by Bre Pettis,from the book Elektroschutz in 132 Bildern</h2><p>30 Ways to Shock Yourself #2, photo by Bre Pettis, from the book Elektroschutz in 132 Bildern</p>">
        
    </a><figcaption class="image-caption"><a href="http://www.flickr.com/photos/bre/3100414330/in/set-72157611077138836">30 Ways to Shock Yourself #2</a>,<br />photo by <a href="http://www.brepettis.com/blog">Bre Pettis</a>,<br />from the book <em>Elektroschutz in 132 Bildern</em></figcaption></figure>
<p>I ported <a href="http://www.youtube.com/watch?v=HvqqRFGMZS0#t=47m57s" title="DFW Winter 2013 Deduplication Hackathon Smackdown - Results, Awards, and Code">my DFW.pm Hackathon entry</a> to the latest Perl dev release (5.19.9), the one with <a href="https://metacpan.org/pod/release/TONYC/perl-5.19.9/pod/perlsub.pod#Signatures" title="Perl subroutines: Signatures">built-in sub signatures</a>.</p>
<p>I had originally designed it using <a href="https://github.com/stevan/p5-mop-redux" title="A(nother) MOP for Perl 5">the latest p5-mop</a> and <a href="https://metacpan.org/pod/signatures" title="signatures - subroutine signatures with no source filter">Алексей Капранов&rsquo;s (Alexei Kapranov&rsquo;s) <code>signatures</code> package</a>. (I thought this was more in the spirit of <code>mop</code> than <code>Sub::Signatures</code>.) And that worked fairly well, with only a few glitches, and only a few complaints. But since sub signatures are now available (Yay!) in core (No hiding how I feel about that, eh?), it seemed a good time to bring the experiment fully into the present.</p>
<p>And here are some discoveries from my experiences with Perl mop+signatures.</p>]]></description>
</item>
<item>
    <title>Benchmarking Perl 6: How Ready for Prime Time Is It?</title>
    <link>https://archive.jtimothyking.com/2013/12/12/benchmarking-perl-6-how-ready-for-prime-time-is-it/</link>
    <pubDate>Thu, 12 Dec 2013 13:00:58 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/12/12/benchmarking-perl-6-how-ready-for-prime-time-is-it/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2013/12/12/benchmarking-perl-6-how-ready-for-prime-time-is-it/CamelRacingCamelCup2009Heat.jpg" title="Racing at the 2009 Camel Cup in Alice Springs, Australia Photo © 2009 Toby Hudson CC BY-SA" data-thumbnail="/2013/12/12/benchmarking-perl-6-how-ready-for-prime-time-is-it/CamelRacingCamelCup2009Heat.jpg" data-sub-html="<h2>Racing at the 2009 Camel Cup in Alice Springs, AustraliaPhoto © 2009 Toby Hudson CC BY-SA</h2><p>Racing at the 2009 Camel Cup in Alice Springs, Australia Photo © 2009 Toby Hudson CC BY-SA</p>">
        
    </a><figcaption class="image-caption">Racing at the 2009 Camel Cup in Alice Springs, Australia<br />Photo © 2009 Toby Hudson CC BY-SA</figcaption></figure>
<p>Here are the slides from the talk I gave at this month&rsquo;s Boston Perl Mongers meeting, this past Tuesday: <a href='Benchmarking-Perl-6-How-Ready-for-Prime-Time-Is-It-revised.pdf'>Benchmarking Perl 6: How Ready for Prime Time Is It?</a></p>]]></description>
</item>
<item>
    <title>More Simple Stats with Perl 6</title>
    <link>https://archive.jtimothyking.com/2013/10/08/more-simple-stats-with-perl-6/</link>
    <pubDate>Tue, 08 Oct 2013 11:00:34 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/10/08/more-simple-stats-with-perl-6/</guid>
    <description><![CDATA[<figure class="alignright size-thumbnail"><a class="lightgallery" href="/2013/10/08/more-simple-stats-with-perl-6/SEO-icon.png" title="This is what happens when I try to pick out images while I&amp;#039;m too tired to think straight." data-thumbnail="/2013/10/08/more-simple-stats-with-perl-6/SEO-icon.png">
        
    </a></figure>
<p><a href="http://sd.jtimothyking.com/2013/09/24/some-simple-stats-with-perl-6/" title="Some Simple Stats with Perl 6">Last time,</a> a time long, long ago, in a universe far, far away, I left you with the following Perl 6 code (or something like it). This code reads in a series of book heights and displays the number of books of each height (in order from shortest to tallest).</p>
<pre><span style="color: DarkRed;">my</span> <span style="color: DarkOrange; font-weight: bold;">%num_of_height</span>;
<span style="color: DarkRed;">for lines() {</span>
    <span style="color: DarkRed;">if</span> <span style="color: DarkMagenta;">m/^ \s* (\d+[\.\d+]?) [\s* x \s* (\d+)]? \s* $/</span><span style="color: DarkRed;"> {</span>
        <span style="color: DarkRed;">my</span> <span style="color: DarkBlue; font-weight: bold;">$height</span> <span style="color: DimGray;">=</span> <span style="color: DarkRed;">+</span><span style="color: DarkBlue; font-weight: bold;">$</span><span style="color: DarkGreen;">0</span><span style="color: DarkRed;">;</span>
        <span style="color: DarkRed;">my</span> <span style="color: DarkBlue; font-weight: bold;">$num</span> <span style="color: DimGray;">=</span> <span style="color: DarkRed;">+(</span><span style="color: DarkBlue; font-weight: bold;">$</span><span style="color: DarkGreen;">1</span> <span style="color: DimGray;">||</span> <span style="color: DarkOrange;">1</span><span style="color: DarkRed;">);</span>
        <span style="color: DarkOrange; font-weight: bold;">%num_of_height</span><span style="color: DarkRed;">{</span><span style="color: DarkBlue; font-weight: bold;">$height</span><span style="color: DarkRed;">}</span> <span style="color: DimGray;">+</span><span style="color: DarkRed;">=</span> <span style="color: DarkBlue; font-weight: bold;">$num</span><span style="color: DarkRed;">;</span>
    <span style="color: DarkRed;">} elsif !</span> <span style="color: DarkMagenta;">m/^\s*$/</span><span style="color: DarkRed;"> {</span>
        <span style="color: DarkRed;">note</span> <span style="color: DarkMagenta;">&quot;Invalid line ignored:</span> <span style="color: DarkBlue; font-weight: bold;">$_</span><span style="color: DarkMagenta;">&quot;</span><span style="color: DarkRed;">;</span>
    <span style="color: DarkRed;">}</span>
<span style="color: DarkRed;">}</span>

<span style="color: DarkGreen; font-weight: bold;">#| unique book heights seen, in order from shortest to tallest</span><span style="color: DarkRed;"></span>
<span style="color: DarkRed;">my</span> <span style="color: Brown; font-weight: bold;">@heights</span> <span style="color: DimGray;">=</span> sort { <span style="color: DarkBlue; font-weight: bold;">$</span><span style="color: DarkGreen;">^</span><span style="color: DarkBlue; font-weight: bold;">a</span> <span style="color: DimGray;">&lt;=&gt;</span> <span style="color: DarkBlue; font-weight: bold;">$</span><span style="color: DarkGreen;">^</span><span style="color: DarkBlue; font-weight: bold;">b</span> }<span style="color: DimGray;">,</span> keys <span style="color: DarkOrange; font-weight: bold;">%num_of_height</span>;

say <span style="color: DarkMagenta;">&quot;Histogram data:&quot;</span>;
<span style="color: DarkRed;">for</span> <span style="color: Brown; font-weight: bold;">@heights</span><span style="color: DarkRed;"> -&gt;</span> <span style="color: DarkBlue; font-weight: bold;">$height</span><span style="color: DarkRed;"> {</span>
    <span style="color: DarkRed;">my</span> <span style="color: DarkBlue; font-weight: bold;">$num</span> <span style="color: DimGray;">=</span> <span style="color: DarkOrange; font-weight: bold;">%num_of_height</span><span style="color: DarkRed;">{</span><span style="color: DarkBlue; font-weight: bold;">$height</span><span style="color: DarkRed;">};</span>
    <span style="color: DarkRed;">say</span> <span style="color: DarkMagenta;">&quot;</span><span style="color: DarkBlue; font-weight: bold;">$height</span><span style="color: DarkMagenta;"> x</span> <span style="color: DarkBlue; font-weight: bold;">$num</span><span style="color: DarkMagenta;">&quot;</span><span style="color: DarkRed;">;</span>
<span style="color: DarkRed;">}</span></pre>
<p>As you may recall, this little bit of somewhat less-than-useful P6 script was inspired by a homework assignment in my daughter&rsquo;s high-school statistics course. While she manually counted up the heights of the books we measured, in order to draw a histogram of the data, I wrote a Perl script to do the same counting.</p>
<p>Since then, for kicks, I&rsquo;ve also hacked together about 50 lines of code to display an actual histogram of these data, with horizontal bars of <code>*****</code>. I&rsquo;m not going to go into that code here, because I did not write it at the time, but if you want, you can <a href="https://github.com/JTimothyKing/sample-code/blob/master/book-heights/book-heights.pl6">check it out on Github</a>.</p>
<p>However, I did discover how succinctly Perl 6 could answer the other questions from the assignment.</p>]]></description>
</item>
<item>
    <title>Some Simple Stats with Perl 6</title>
    <link>https://archive.jtimothyking.com/2013/09/24/some-simple-stats-with-perl-6/</link>
    <pubDate>Tue, 24 Sep 2013 17:12:36 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/09/24/some-simple-stats-with-perl-6/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2013/09/24/some-simple-stats-with-perl-6/Bingo-numbers-Leo-Reynolds.jpg" title="Bingo numbers; ©2010 Leo Reynolds CC BY-NC-SA 2.0" data-thumbnail="/2013/09/24/some-simple-stats-with-perl-6/Bingo-numbers-Leo-Reynolds.jpg">
        
    </a></figure>
<p>When my daughter told me she was taking statistics, I wondered how she could do that without knowing any calculus. Then on second thought, I guess there is a certain amount you can do with statistics, even without knowing any calculus.</p>
<p>Ah, yes. And last night&rsquo;s homework assignment drilled that home. She asked me to help her. First, she needed to find a quantitative data set she could use to construct a histogram. Looking around the living room, I suggested, &ldquo;What about the heights of the books on my book shelves? You could measure the spines and write them down in a data table.&rdquo;</p>
<p>Now, I currently have nine full shelves of books in my living room, everything from Dave Barry and Dilbert to <em>Peopleware</em> to marketing and memoirs, theology and psychology, short stories and the theory of writing, to Holly Lisle, Douglas Adams, Robert Heinlein, and <em>The Sisterhood of the Traveling Pants</em>. (And I am not making this up.) And those are just the books that are actually on shelves, not the books that are still in boxes.</p>
<p>I think she was a little overwhelmed by the idea.</p>
<p>&ldquo;You don&rsquo;t have to include all the books, just one or two shelves worth. Maybe that one over there, half full of mass-market paperbacks all the same size.&rdquo; <em>Easy to measure, easy to count.</em></p>
<p>So we chose that shelf and the shelf just under it, a nice cross-section of fiction in mass-market, trade paperback, and hardcover. And then while she was manually collating the data, inspiration struck me. <em>Why don&rsquo;t I write a quick Perl 6 script to check her results. It&rsquo;ll give me something to write about; plus I&rsquo;ll see whether Perl 6 is really useful for anything, especially minor scripts.</em></p>
<p>And as it turns out, it might be.</p>]]></description>
</item>
<item>
    <title>How Fast (or Slow) Is Perl 6?</title>
    <link>https://archive.jtimothyking.com/2013/09/17/how-fast-or-slow-is-perl-6/</link>
    <pubDate>Tue, 17 Sep 2013 12:00:22 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/09/17/how-fast-or-slow-is-perl-6/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2013/09/17/how-fast-or-slow-is-perl-6/CamelRacingCamelCup2009Heat.jpg" title="Racing at the 2009 Camel Cup in Alice Springs, Australia Photo © 2009 Toby Hudson CC BY-SA" data-thumbnail="/2013/09/17/how-fast-or-slow-is-perl-6/CamelRacingCamelCup2009Heat.jpg" data-sub-html="<h2>Racing at the 2009 Camel Cup in Alice Springs, AustraliaPhoto © 2009 Toby Hudson CC BY-SA</h2><p>Racing at the 2009 Camel Cup in Alice Springs, Australia Photo © 2009 Toby Hudson CC BY-SA</p>">
        
    </a><figcaption class="image-caption">Racing at the 2009 Camel Cup in Alice Springs, Australia<br />Photo © 2009 Toby Hudson CC BY-SA</figcaption></figure>
<p>In my previous post, I created a short, simple, sweet, and <em>très élégant</em> <a href="http://sd.jtimothyking.com/2013/09/09/perl-6-and-the-price-of-elegant-code/" title="Perl 6 and the Price of Elegant Code">Perl 6 function to find all the primes up to a given maximum</a>.</p>
<p>Unfortunately, Rakudo spent over 11 seconds to find the 168 primes up to 1000.</p>
<p>Now, granted, this algorithm is exceedingly naïve. It divides every candidate integer by every prime that came before it, resulting in some 91,873 trial divisions (and another 91,873 boolean tests). Even so, that boils down to some 280,000 CPU clock cycles per inner loop (on my old 2.33 GHz Intel Core 2 Duo, with one core tied behind its back).</p>
<p>As a comparison, an implementation of the same algorithm in Perl 5 took only 44 milliseconds to find the same 168 primes using the same number of loops, or about 1100 CPU clock cycles per loop. Still not blazing fast, but more like what I would expect from an interpreted language&hellip; Of course I have Rakudo running on the JVM, and I&rsquo;m benchmarking it after the JIT compiler has squeezed every last little bit of performance it can out of the code it&rsquo;s given. A native-Java implementation ran even faster— but I&rsquo;m getting ahead of myself.</p>]]></description>
</item>
<item>
    <title>Perl 6 and the Price of Elegant Code</title>
    <link>https://archive.jtimothyking.com/2013/09/09/perl-6-and-the-price-of-elegant-code/</link>
    <pubDate>Mon, 09 Sep 2013 12:00:38 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/09/09/perl-6-and-the-price-of-elegant-code/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2013/09/09/perl-6-and-the-price-of-elegant-code/Camel_Profile_near_Silverton_NSW_07.07.2007.jpg" title="You lookin’ at me?!" data-thumbnail="/2013/09/09/perl-6-and-the-price-of-elegant-code/Camel_Profile_near_Silverton_NSW_07.07.2007.jpg">
        
    </a></figure>
<p>The project that first made me fall in love with Perl&hellip;</p>
<p>Perl 5 had recently launched, with new features for object-oriented programming, includable modules, lexically scoped variables, and references—including closures. At the time, I was writing boot code, diagnostics, and production test software for Kurzweil-brand electronic musical gear. Part of the challenge of doing embedded systems back then was getting the machine code into the actual machine. The C compiler, assembler, and linker generated a binary file, which needed to be physically programmed into multiple EPROM chips in order to run the code on our custom hardware. We actually had software tools to pad out, checksum, and split up the binary data so it could programmed into multiple EPROMs according to our specifications.</p>
<p>And then we started designing systems that exceeded the capabilities of our tools. And I had to hack together custom C programs to reformat the binary data according to the new requirements. I think I might have done that twice. And then I asked myself whether Perl, which was always very good with strings of data—and what is a binary file but a big string of data? I asked myself whether Perl might be able to do a better job.</p>]]></description>
</item>
</channel>
</rss>
