<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Perl 6 - Tag - In a past life…</title>
        <link>https://archive.jtimothyking.com/tags/perl-6/</link>
        <description>Perl 6 - Tag - In a past life…</description>
        <generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 12 Dec 2013 13:00:58 &#43;0000</lastBuildDate><atom:link href="https://archive.jtimothyking.com/tags/perl-6/" rel="self" type="application/rss+xml" /><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>
<item>
    <title>Perl 6&#39;s Top 3 Coolest Features</title>
    <link>https://archive.jtimothyking.com/2013/09/02/perl-6s-top-3-coolest-features/</link>
    <pubDate>Mon, 02 Sep 2013 20:20:01 &#43;0000</pubDate>
    <author>J. Timothy King</author>
    <guid>https://archive.jtimothyking.com/2013/09/02/perl-6s-top-3-coolest-features/</guid>
    <description><![CDATA[<figure class="alignright size-medium"><a class="lightgallery" href="/2013/09/02/perl-6s-top-3-coolest-features/butterfly_dna_by_hederahelix88-d33hpxn.jpg" title="Butterfly DNA by HederaHelix31415927" data-thumbnail="/2013/09/02/perl-6s-top-3-coolest-features/butterfly_dna_by_hederahelix88-d33hpxn.jpg">
        
    </a></figure>
<p>Perl 6 has some really cool features. Features I&rsquo;d like to use in production projects. But is Perl 6 suitable for production?</p>
<p>I keep hearing, no, because it&rsquo;s unstable, the spec is still being hammered out, there are still too many bugs, it&rsquo;s still too slow, the documentation lacks (or is just plain wrong), key features are still missing, it has insufficient module support.</p>
<p>But I have never been one who blindly accepts the evaluations of the crowd, because the crowd is often dominated by zealots twisted by hate and zealots twisted by love, and I&rsquo;ve found a great beauty and symmetry in that nuance that lies in between zealotries.</p>
<p>Besides which, Perl 6 (hereinafter referred to as &ldquo;P6&rdquo;) includes a number of features that fit a particular real-world application that I happen to be thinking about. That&rsquo;s another post. But several P6 features struck me. Here are the top three:</p>]]></description>
</item>
</channel>
</rss>
