<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>dukeleto.pl</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/" />
    <link rel="self" type="application/atom+xml" href="http://leto.net/dukeleto.pl/atom.xml" />
    <id>tag:leto.net,2008-04-19:/dukeleto.pl//9</id>
    <updated>2010-07-01T01:27:34Z</updated>
    <subtitle>Ramblings about Perl 5/6, Rakudo, Parrot and their accoutrements &amp; impedimenta</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.1</generator>

<entry>
    <title>Rakudo Perl 6 in Your PostgreSQL Database!</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2010/06/rakudo-perl-6-in-your-postgresql-database.html" />
    <id>tag:leto.net,2010:/dukeleto.pl//9.225</id>

    <published>2010-06-30T20:42:39Z</published>
    <updated>2010-07-01T01:27:34Z</updated>

    <summary> It has been a very exciting few weeks in the Perl 6 world with regard to database access. mberends++ just wrote a nice blog post about how Perl 6 support for DBI is ramping up with work on MiniDBI...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="postgres" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="rakudo" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="postgresql" label="postgresql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rakudo" label="rakudo" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<p>
It has been a very exciting few weeks in the <a href="http://perl6.org/">Perl 6</a> world with regard to database access. 
<a href="http://blogs.perl.org/users/martin_berends/">mberends++</a> just wrote
a nice <a href="http://blogs.perl.org/users/martin_berends/2010/06/rakudo-perl-6-gets-into-databases.html">blog post</a> about how Perl 6 
support for DBI is ramping up with work on <a href="http://github.com/mberends/MiniDBI">MiniDBI</a> (formerly FakeDBI). Multiple developers recently made great progress
on <a href="http://postgresql.org">PostgreSQL</a> drivers and have been improving the <a href="http://parrot.org">Parrot</a> interface to 
<a href="http://www.postgresql.org/docs/8.4/static/libpq.html">libpq</a>, 
<a href="http://trac.parrot.org/parrot/browser/trunk/runtime/parrot/library/Pg.pir">Pg.pir</a> .
</p>

<p>
I have also been dutifully hacking on PL/Perl6, which embeds <a href="http://rakudo.org">Rakudo Perl 6</a> into
your PostgreSQL datbase via <a href="http://pl.parrot.org">PL/Parrot</a>, and just recently merged the plperl6
branch, which adds the first basic support for PL/Perl 6. Here is how it
currently works:
</p>

<ul>
<li>You must first install a recent version of Parrot and Rakudo Perl 6. I develop
with Parrot trunk and Rakudo master because I often need very recent changes/bugfixes</li>
<li>You will need a moderately recent version of PostgreSQL. PL/Parrot has been
known to work with versions as old as 8.3.8, but I mostly develop on the master branch,
so 9.x will probably work best</li>
<li>When you type "make install" for Rakudo Perl 6, you will see that it installs a file
called "perl6.pbc" into the lib/$version/languages/perl6 directory of the Parrot installation
that Rakudo was configured with. </li>
</ul>

<p>
To tell PL/Parrot that you would also like PL/Perl6, you
set the environment variable PERL6PBC to the full path of perl6.pbc like so:
</p>
<p>
<b>
export PERL6PBC=/Users/leto/git/rakudo/parrot_install/lib/2.5.0-devel/languages/perl6/perl6.pbc
</b>
</p>

<p>
A PBC file is <a href="http://docs.parrot.org/parrot/devel/html/docs/parrotbyte.pod.html">Parrot bytecode</a>,
and the perl6.pbc file basically bundles all of Rakudo Perl 6 into
a single file. You can play around with the Rakudo Perl 6 REPL by running:
</p>
<p>
<b>
$ parrot $PERL6PBC
</b>
</p>

<p>
which is pretty much the exact same thing as running the perl6 binary in your $PATH.
</p>

<p>
When you compile PL/Parrot with the $PERL6PBC environment variable set, it automatically creates
a separate Parrot interpreter with the perl6.pbc bytecode loaded, so that Perl 6 code can be executed.
</p>

<p>
To run PL/Parrot tests, you type "make test". You can also do this the
PostgreSQL way with "make installcheck", which will run the tests and verify
that the output matches a certain, known output. "make tests" just generates
the TAP output.
</p>

<p>
Currently PL/Perl 6 tests are not run by default, they have their own Makefile target:
<b>test_plperl6</b>
<a href="http://gist.github.com/459421">This</a> is what the output of "make test_plperl6" looks like currently, on
<a href="http://github.com/leto/plparrot/commit/44a985f123309783b43304bc4268cde93aba1ef3">commit 44a985f123</a> of the perl6_args
branch.
</p>

<p>
We run a total of 9 tests, 6 of which correctly run Perl 6 code and pass. You will notice that all the
failing tests are relating to passing arguments into Rakudo from PostgreSQL, which is what I am 
currently trying to get to work. Currently I am passing a 
<a href="http://docs.parrot.org/parrot/devel/html/src/pmc/resizablepmcarray.pmc.html">Parrot ResizablePMCArray</a> of the arguments
to a Rakudo function and executing it, but the function can't seem to see it. My guess is that 
Rakudo wants native datatypes and not Parrot datatypes. If you know how to create Rakudo datatypes
from <a href="http://en.wikipedia.org/wiki/Parrot_intermediate_representation">PIR</a>, please let me know :) I promise you will <a href="http://perlgeek.de/blog-en/perl-6/optimized-for-fun.html">-Ofun</a>.
</p>

<p>
What does PL/Perl 6 look like? Here is a nice example of a PL/Perl6 function which calculates the sum
of all <a href="http://en.wikipedia.org/wiki/Fibonacci_number">Fibonacci numbers</a> <= 100:
<p>
CREATE FUNCTION test_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$<br/>
[+] (1, 1, *+* ... 100)<br/>
$$;
</p>

You will notice three spiffy new Perl 6 operators in there, the summation
operator <b>[+]</b>, the new range operator <b>...</b> (which used to be <b>..</b> in Perl 5), and the <b>*+*</b> operator. What
exactly is the <b>*+*</b> operator? pmichaud++ jokingly referred to it as the
"cheerleading plus", but it is actually just a plain old infix "+" operator,
sandwiched by two "*" (a.k.a Whatever) operands. It basically takes the
previous two elements in a list, sums them together and returns the sum,
which is exactly how the Fibonacci sequence is defined.
</p>

<p>
If you are interested in hacking on PL/Perl 6, PL/Parrot or anything related, come
join us in #plparrot on freenode, join the
<a href="http://groups.google.com/group/plparrot/">mailing list</a> and fork us on 
<a href="http://github.com/leto/plparrot">github</a> !
</p>
]]>
        
    </content>
</entry>

<entry>
    <title>PL/Parrot Flies</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2010/04/plparrot-flies.html" />
    <id>tag:leto.net,2010:/dukeleto.pl//9.218</id>

    <published>2010-04-20T01:32:40Z</published>
    <updated>2010-04-20T02:55:57Z</updated>

    <summary>PL/Parrot recently started passing all tests and marshalling three basic data types of integers, floats and strings, between PostgreSQL and Parrot Virtual Machine. One of the important next steps for PL/Parrot is to improve the security subsystem, which will require...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="postgres" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="rakudo" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="nqp" label="nqp" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="pgcon" label="pgcon" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="pir" label="pir" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="postgresql" label="postgresql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rakudo" label="rakudo" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<a href="http://github.com/leto/plparrot">PL/Parrot</a> recently started passing all tests and marshalling three basic data types of integers, floats and strings, between<a href="http://www.postgresql.org/"> PostgreSQL</a> and <a href="http://parrot.org/">Parrot Virtual Machine</a>. <br /><br />One of the important next steps for PL/Parrot is to improve the security subsystem, which will require changes to Parrot core. Parrot has only a high-level <a href="http://docs.parrot.org/parrot/latest/html/docs/pdds/pdd18_security.pod.html">Parrot Developer Doc (PDD) that describes how security should work</a>, but still lacks an implementation. Thus, PL/Parrot finds itself in the situation of being able to drive the development of security features in Parrot. This is very exciting and I am researching various hardening solutions. Various ideas have been thrown around, but removing or replacing certain opcodes at the lowest level is the most secure solution. How to do this, properly at run-time, is the fun part.<br /><br />I will be talking about PL/Parrot at <a href="http://www.pgcon.org/2010/">PGCon 2010</a>, which will be very exciting. I am hoping to meet many people in the PostgreSQL community and show some PostgreSQL internals hackers why hacking on PL/Parrot is so fun and so important.<br /><br />PL/Parrot is so important because PL's are hard to write and maintain. My vision is that most of the hard work goes into PL/Parrot, and then languages built on top of Parrot (HLL's), will have a very simple time piggy-backing on top of that infrastructure. Currently, only PL/PIR exists. Stored procedures can be written in <a href="http://en.wikipedia.org/wiki/Parrot_intermediate_representation">PIR</a>. The next steps will be getting a HLL working on PL/Parrot, such as <a href="http://en.wikibooks.org/wiki/Parrot_Virtual_Machine/Not_Quite_Perl">NotQuitePerl (NQP)</a> or <a href="http://rakudo.org/">Rakudo Perl 6</a>. If you want to get your favorite HLL working on PL/Parrot, I surely won't stop you.<br /><br />There are also many benefits to writing stored procedures in PIR. PIR will have the closest possible speed to C than any HLL run on Parrot, so if speed is your main concern, you will want PL/PIR. Parrot has a garbage collector, so you don't have to do memory management in PL/PIR. This prevents crashing the server instance due to double-free errors and fun stuff like that. PIR is also platform-independent: no more need to figure out how to get your stored procedures written in C compiling on a new platform. <br /><br />If you have tuits or ideas for implementing PL/NQP or PL/Rakudo or any other comments about PL/Parrot, I would love to hear them. Feel free to<a href="http://github.com/leto/plparrot"> fork the github repo</a>, join us in #plparrot on irc.freenode.net or <a href="http://groups.google.com/group/plparrot">on our mailing list</a>. We also need a website and mascot. There are many ways to help, but patches are always welcome :)<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Google Summer of Code 2010</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2010/03/google-summer-of-code-2010.html" />
    <id>tag:leto.net,2010:/dukeleto.pl//9.207</id>

    <published>2010-03-09T06:47:41Z</published>
    <updated>2010-03-09T07:24:05Z</updated>

    <summary><![CDATA[I&nbsp;am working on the application for The Perl Foundation and ParrotFoundation to participate in Google Summer of Code 2010. GSoC is aprogram where Google funds eligible students to hack on open sourceprojects for a summer. It is a great opportunity...]]></summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="gsoc" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="gsoc" label="gsoc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gsoc2010" label="gsoc2010" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<meta charset="utf-8"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial,sans-serif; font-size: 15px; border-collapse: collapse;">I&nbsp;am working on the application for <a href="http://perlfoundation.org/">The Perl Foundation</a> and <a href="http://parrot.org/">Parrot<br />Foundation</a> to participate in <a href="http://socghop.appspot.com/">Google Summer of Code 2010</a>. GSoC is a<br />program where Google funds eligible students to hack on open source<br />projects for a summer. It is a great opportunity for the students and<br />the communities that mentor them. You also may be interested in this<br />summary of our involvement<a href="http://google-opensource.blogspot.com/2009/10/perls-of-wisdom-perl-foundation-parrots.html"> last year</a> . Our application will be<br />submitted by the end of this week.<br /><br />Please join us in getting prepared for this year. There is a page for<br /><a href="http://www.perlfoundation.org/perl5/index.cgi?gsoc_mentors">possible mentors to volunteer</a> as well as a page for&nbsp;</span><div><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial,sans-serif; font-size: 15px; border-collapse: collapse;"><a href="http://www.perlfoundation.org/perl5/index.cgi?gsoc_2010_projects">project ideas</a> . If you would like to help with the wiki, our&nbsp;</span></div><div><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial,sans-serif; font-size: 15px; border-collapse: collapse;"><a href="http://www.perlfoundation.org/perl5/index.cgi?gsoc">main GSoC page</a> is the best place to start. You are also invited to join&nbsp;</span></div><div><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial,sans-serif; font-size: 15px; border-collapse: collapse;"><a href="http://groups.google.com/group/tpf-gsoc">our mailing&nbsp;list</a>&nbsp; and come ask questions in #soc-help on&nbsp;<a href="http://irc.perl.org/" target="_blank" style="color: rgb(0, 84, 136);">irc.perl.org</a>&nbsp;.</span><br /><br /> </div>]]>
        
    </content>
</entry>

<entry>
    <title>Parrot In Your Database</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/11/parrot-in-your-database.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.204</id>

    <published>2009-11-14T07:38:52Z</published>
    <updated>2009-11-14T22:44:10Z</updated>

    <summary>Wouldn&apos;t it be awesome to write performance-critical stored procedures in a fast platform-independent language? That is the vision for PL/Parrot, a Postgres Language that will allow you to write stored procedures in PIR or NQP. Our current plan is to...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="postgres" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="plparrot" label="plparrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="postgres" label="postgres" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[Wouldn't it be awesome to write performance-critical stored procedures in a fast platform-independent language? That is the vision for PL/Parrot, a <a href="http://www.postgresql.org/">Postgres</a> Language that will allow you to write stored procedures in <a href="http://en.wikipedia.org/wiki/Parrot_Intermediate_Representation">PIR</a> or <a href="http://en.wikibooks.org/wiki/Parrot_Virtual_Machine/Not_Quite_Perl">NQP</a>. Our current plan is to embed the <a href="http://parrot.org/">Parrot VM</a> inside each postgres backend. If you have a better idea, let us know!<br /><br />Come hang out on #plparrot on irc.freenode.net or checkout the <a href="http://github.com/leto/plparrot">github repo</a> if you want to help! You may also want to visit #parrot on irc.perl.org for Parrot-specific help. It is very much in a prototype stage right now, but we have lots of smart people interested in making this work, so I am confident that we will have something working very soon.<br /><br />If you are a Postgres internals hacker or you want to learn more about Parrot Virtual Machine, we would greatly appreciate your help! <br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Real-Time Embedded Parrots</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/11/realtime-embedded-parrots.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.203</id>

    <published>2009-11-04T03:44:45Z</published>
    <updated>2009-11-04T04:43:13Z</updated>

    <summary>I am very proud to announce that Parrot Virtual Machine has been ported to RTEMS, a real-time embedded operating system (RTOS). Here is one of the first runs of Parrot code atop RTEMS, this example being the Fibonacci number benchmark...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="rtems" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="embedded" label="embedded" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rtems" label="rtems" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rtos" label="rtos" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[I am very proud to announce that <a href="http://parrot.org">Parrot Virtual Machine</a> has been ported to
<a href="http://rtems.com">RTEMS</a>, a real-time embedded operating system (<a href="http://en.wikipedia.org/wiki/RTOS">RTOS</a>). Here is one of the first
runs of Parrot code atop RTEMS, this example being the <a href="http://en.wikipedia.org/wiki/Fibonacci_number">Fibonacci number </a>
benchmark with debug tracing turned on, posted by Chris Johns:
<p>

<pre>
RTEMS SHELL (Ver.1.0-FRC):/dev/console. Oct 21 2009. 'help' to list commands.
fstst [/] # parrot -v p/benchmarks/fib.pir
debug = 0x0
Reading p/benchmarks/fib.pir
using optimization '-O' (0)
Starting parse...
sub _main:
        registers in .pir:       I3, N2, S1, P2
        0 labels, 0 lines deleted, 0 if_branch, 0 branch_branch
        0 branch_cond_loop
        0 used once deleted
        0 invariants_moved
        registers needed:        I3, N2, S1, P3
        registers in .pasm:      I3, N2, S1, P2 - 0
        4 basic_blocks, 4 edges  
sub _fib: 
        registers in .pir:       I5, N0, S0, P0
        0 labels, 0 lines deleted, 0 if_branch, 0 branch_branch
        0 branch_cond_loop
        0 used once deleted
        0 invariants_moved
        registers needed:        I5, N0, S0, P2
        registers in .pasm:      I5, N0, S0, P2 - 0
        5 basic_blocks, 5 edges  
1 lines compiled.
Running...
fib(28) = 317811 71.1315400600433s

Many many thanks to all who have helped. -- kiwichris

</pre>
<p>

I met Chris Johns a.k.a. 'kiwichris', a core RTEMS developer, at the <a href="http://tagal.us/tag/mentorsummit">Google
Summer of Code Mentor Summit</a> 2009, and we have been attempting to get
Parrot working on RTEMS ever since. With his extreme hard work and
hand-tuned Makefile kung-fu, he cross-compiled Parrot, totally bypassing our
configure/build system, which does not support cross-compiling!
<p>
Getting RTEMS working on Parrot definitely pointed out a few rough edges
on Parrot's part, such as using powl() from math.h without checking for it,
even though it is an <a href="http://www.mers.byu.edu/docs/standardC/math.html">*optional* POSIX extension</a>. RTEMS does not currently
have powl() so our string subsystem blew up. Thankfully, just replacing
it with pow() works just fine, for now. I've added a <a href="https://trac.parrot.org/parrot/ticket/1176">ticket to add support for
checking at Configure-time whether powl() exists</a>, and to only use it then, 
which is the correct behavior.
<p>
Also, the Parrot exit handler calls the system exit() after all other exit handlers
currently, which reboots a real-time OS like RTEMS. So we are going to have
to provide some interface to allow alternate final exit handlers.
<p>
But these issues are small, most of the hard work has already been done by Chris. At
this point, we will start fixing our configure/build system so that a RTEMS cross-compile can be done with a Configure.pl flag, such as 
<p>

<pre>
perl Configure.pl --cross=rtems-i386
</pre>
<p>

Thanks again to Chris Johns and all RTEMS/Parrot core developers that helped make this possible.

<p>

Stay tuned to the intertubes for more updates about Parrot on RTEMS!
<p>]]>
        
    </content>
</entry>

<entry>
    <title>Parrot Hacktivity Report</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/10/parrot-hacktivity-report.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.202</id>

    <published>2009-10-13T19:34:05Z</published>
    <updated>2009-10-14T22:47:11Z</updated>

    <summary>I hacked on various parts of the Parrot Virtual Machine and HLL&apos;s (High Level Languages) that run on it in the past weeks. One new interesting project that has recently taken off is called Parrot Plumage, which allows you to...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="nqp" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="partcl" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="plumage" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="testingparrotplumage" label="testing parrot plumage" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[I hacked on various parts of the Parrot Virtual Machine and HLL's (High Level Languages) that run on it in the past weeks. <br /><br />One new interesting project that has recently taken off is called <a href="http://gitorious.org/parrot-plumage">Parrot Plumage</a>, which allows you to install Parrot add-ons from the internet. Think of it as CPAN for Parrot. It lives on <a href="http://gitorious.org/%7Eleto">Gitorious</a>, which I had never used before, but is easy to use and somewhat more stable than <a href="http://github.com/leto">Github</a>, because it has fewer features. It does not have an issue tracker (that would be awesome) and it does not keep track of who forked from whom, which is the clearest distinction from Github.<br /><br />I added a very extremely naive test harness to Plumage, written in NQP (Not Quite Perl). No, I am not joking, there really is a language called Not Quite Perl. It is a subset of Perl 6 without all the bells and whistles. It is used as a bootstrap language that is slightly higher level than PIR. The Parrot Compiler Toolkit uses NQP for manipulating Parrot Abstract Syntax Trees and parsing/transforming the actual text of the program. A great introduction to NQP is available from <a href="http://en.wikibooks.org/wiki/Parrot_Virtual_Machine/Not_Quite_Perl">wikibooks</a>.<br /><br />As soon as I started hacking on Plumage I thought to myself <b>'we need a test suite'</b>. At first I fixed a build issue by reorganizing the source into logical directories (the build failed on case insensititive filesystems, like OS X). Plumage is written in NQP and PIR, so a test suite that depended on Perl being installed seems like an unnecessary dependency (yes, I am crazy). Since no one seems to have written a test harness in pure PIR, I set out to write one in NQP (with some PIR sprinkled in). With help from <a href="http://github.com/tene">tene++</a> on how to import all of the function's from Parrot's Test::More library into NQP, I had a nice little test environment set up. Currently Plumage has 8 passing tests and now I can confidently change code and verify that I haven't totally borked the universe.<br /><br />Further improvements to Plumage's test suite should definitely include a proper TAP parser written in NQP. Currently only passing and failing tests are supported. Comments are not parsed correctly and there is no concept of SKIP or TODO. These features will probably hold off until <a href="http://github.com/pmichaud">pmichaud++</a> can get the <a href="http://github.com/perl6/nqp-rx">newer version of NQP</a> that he has been working on merged in. Currently NQP does not support regular expressions (what!) natively, it must dig down to PIR with <b>Q:PIR{ ... } </b>and use Parrot regular expressions. The new version of NQP will have native support for regular expressions and make writing NQP much less bumpy.<br /><br />I also recently helped <a href="http://github.com/coke">coke++</a> migrate Partcl (TCL on Parrot) from a subversion repo on Google Code to <a href="http://github.com/partcl/partcl">a Github repo</a>. This went surprisingly smoothly and will hopefully encourage more people to work on Partcl, which is one of the most mature languages being developed on Parrot.<br /><br />Other recent ongoing hacktivity has been continuing to convert Parrot's test suite from Perl to PIR (lots of newcomers are helping with this, sweet!) and adding tests for CallSignature PMCs on the very-important <a href="http://github.com/leto/parrot/tree/pcc_reapply">pcc_reapply branch</a>. The pcc_reapply branch is a large refactoring of Parrot's internal <a href="https://trac.parrot.org/parrot/wiki/CallingConventionsOverview">Calling Conventions</a> and will most probably be merged in just after 1.7 is released. That reminds me, I will be releasing Parrot 1.7 next Tuesday, just before the Google Summer of Code 2009 Mentor Summit in Mountain View. Exciting times!<b> <br /></b><br />Until next time, happy hacking!<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Learning Parrot with the Parrot Shell</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/09/learning-parrot-with-the-parrot-shell.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.199</id>

    <published>2009-10-01T03:26:19Z</published>
    <updated>2009-09-30T07:45:06Z</updated>

    <summary>I recently have been working a lot on Parrot (I am the release manager for 1.7) and learning by the seat of my pants. The first thing that I yearned for was something REPL-like, for rapid prototyping and just hacking...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="repl" label="repl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="shell" label="shell" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[I recently have been working a lot on <a href="http://parrot.org/">Parrot</a> (I am the release manager for 1.7) and learning by the seat of my pants. The first thing that I yearned for was something REPL-like, for rapid prototyping and just hacking out code with immediate feedback. Enter the Parrot Shell. To start up the shell, go to the root of the Parrot source code and type:<br /><br /><b>perl <a href="https://trac.parrot.org/parrot/browser/trunk/tools/dev/parrot_shell.pl">tools/dev/parrot_shell.pl</a></b><br /><br />This should be after you have configured and compiled Parrot with<br /><br /><b>perl Configure.pl &amp;&amp; make</b><br /><br />You should see something like:<br /><br /><b>Welcome to the Parrot Shell, it's experimental!<br />Type h or help for some basic help<br />Type q or quit to flee the madness<br /><br />parrot_shell 0&gt;</b><br /><br />The Parrot Shell reads input until it sees a single period (".") on a line (ignoring whitespace), then executes the code that you gave it. That is it. As a simple first example, let's print something:<br /><br /><b>parrot_shell 0&gt; say "This Parrot talks!"<br />.<br />Time: 0.062809 wallclock secs <br />Output:<br />This Parrot talks!<br /><br /></b>But you may ask, there is no ".sub main" followed by a ".end" at the end of the code, so that is not valid <a href="https://trac.parrot.org/parrot/browser/trunk/tools/dev/parrot_shell.pl">PIR</a>. You would be correct. The Parrot Shell wraps the commands you give it in ".sub main" and ".end" if the first line of your input does not start with ".sub". So it allows one to be lazy for short pieces of code, but allows specifying the name of the main subroutine for when that is necessary. This shows how to do that:<br /><br /><b>parrot_shell 2&gt; .sub main<br />&nbsp;&nbsp;&nbsp; foo()<br />.end<br />.sub foo<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; say "foo"&nbsp;&nbsp; <br />.end<br />.<br />Time: 0.0438812 wallclock secs <br />Output:<br />foo<br /><br /></b>Some other things to know about the Parrot Shell are that you can type "h" or "help" to get a quick reminder of how Parrot Shell works and that each numbered Parrot Shell session is run in its own interpreter, so no registers or variables are shared/leaked between them. To leave the Parrot Shell, just type "q" or "quit" .&nbsp; <br /><br /><b>parrot_shell 1&gt; quit<br />Thanks for visiting the Parrot Shell, come back soon</b>!<br /><b><br /></b>Here is one more example which shows basic interaction with Parrot registers via the Parrot Shell<br /><br /><b>parrot_shell 0&gt; <br />$I0 = 42<br />$N1 = sqrt $I0<br />say $N1<br />&nbsp;.<br />Time: 0.0245831 wallclock secs<br />Output:<br />6.48074069840786</b><br /><br />The Parrot Shell is great for pasting code snippets from <a href="https://trac.parrot.org/parrot">Trac</a> tickets or from people on IRC asking "does this code do X on your system?" I also find it is very helpful to have a Parrot Shell open while reading <a href="http://docs.parrot.org/parrot/latest/html/index.html">Parrot documentation</a> (like the <a href="http://docs.parrot.org/parrot/latest/html/docs/book/pir/ch03_basic_syntax.pod.html">PIR book</a>), so that you can test things as you learn them. In addition to all the docs that Parrot comes with, there are some really good online guides popping up, like <a href="http://coolnamehere.com/parrot/learn/index.html">Brian Wisti's Parrot Baby Steps</a>.<br /> <br />If you are trying to write tests for a certain Parrot feature, the Parrot Shell can often help you figure out how to write it in the least amount of time.<br /><br />I hope that the Parrot Shell gives you an easy on-ramp to start playing with Parrot, please let me know how you use it and if you have any suggestions for improvement. As always, patches welcome!<br />]]>
        
    </content>
</entry>

<entry>
    <title>Blizkost is passing 102 tests!</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/09/blizkost-is-passing-102-tests.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.200</id>

    <published>2009-09-17T06:09:01Z</published>
    <updated>2009-09-17T07:18:13Z</updated>

    <summary>Blizkost, Perl 5 on Parrot, is really starting to pick up speed. I just imported the base Perl 5 tests (the ones that live in t/base) and Blizkost passes every file except lex.t and one TODO test about implementing the...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="blizkost" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="blizkost" label="blizkost" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<a href="http://github.com/jnthn/blizkost">Blizkost</a>, Perl 5 on Parrot, is really starting to pick up speed. I just imported the base Perl 5 tests (the ones that live in <a href="http://perl5.git.perl.org/perl.git/tree/HEAD:/t/base">t/base</a>) and Blizkost passes every file except <a href="http://perl5.git.perl.org/perl.git/blob/HEAD:/t/base/lex.t">lex.t</a> and one TODO test about implementing the -l command line argument. If you can make <a href="http://perl5.git.perl.org/perl.git/blob/HEAD:/t/base/lex.t">lex.t</a> work, you get super-cool ninja points. It is probably the use of the <b>package</b> keyword in lex.t that borks the test. If you feel like porting other tests from the Perl 5 Test Suite, they live in <b>t/spec</b> in the Blizkost repo.<br /><br />Currently, Blizkost cannot load XS modules, such as Data::Dumper. You get an error like:<br /><br /><b>Can't load '/usr/lib/perl/5.10/auto/Data/Dumper/Dumper.so' for module Data::Dumper: /usr/lib/perl/5.10/auto/Data/Dumper/Dumper.so: undefined symbol: Perl_sv_cmp at /usr/lib/perl/5.10/XSLoader.pm line 64.<br />&nbsp;at /usr/lib/perl/5.10/Data/Dumper.pm line 36</b><br /><br />If you can help get enough XS-loading machinery to work so that Data::Dumper works, that would really help development and testing. If you can try out Blizkost on your system and make sure that it compiles and the test suite passes, we would greatly appreciate it. Feel free to open an <a href="http://github.com/jnthn/blizkost/issues">issue</a> on github if you find a bug.<br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Parrot Hacktivity Report</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/09/parrot-hacktivity.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.197</id>

    <published>2009-09-15T06:19:07Z</published>
    <updated>2009-09-15T09:17:56Z</updated>

    <summary>Applied many patches from flh++ and darbelo++Translated lots of tests written in Perl to PIR. This makes the test suite faster! It also makes the code easier to debug. It has also uncovered lots of bugs. Fun!Implemented throws_like() in test_more.pir,...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<br /><ul><li>Applied many patches from flh++ and darbelo++<br /></li><li>Translated lots of tests written in Perl to <a href="http://en.wikipedia.org/wiki/Parrot_intermediate_representation">PIR</a>. This makes the test suite faster! It also makes the code easier to debug. It has also uncovered lots of bugs. Fun!<br /></li><li>Implemented throws_like() in test_more.pir, which allows for easily testing if a bit of PIR code throws an exception that matches a <a href="http://en.wikipedia.org/wiki/Parser_Grammar_Engine">PGE</a> pattern. This is inspired from warnings_like() in <a href="http://search.cpan.org/dist/Test-Warn/Warn.pm">Test::Warn</a> and uses the like() from test_more.pir under the hood, so it was reasonably simple to implement. Added lots of tests that use throws_like() to verify that proper errors are thrown.<br /></li><li>Fixed a bug in <a href="http://docs.parrot.org/parrot/latest/html/src/pmc/fixedpmcarray.pmc.html">FixedPMCArray</a> where it would not check for negative lengths and core dump Parrot. Oops!</li><li>Wrote an interactive Parrot Shell for REPL/rapid prototyping. Type <b>perl tools/dev/parrot_shell.pl</b> in the Parrot source code to start it up. More about this soon!<br /></li><li>Wrote many tests for the proper handling of Inf/NaN, which exposed some bugs in fdiv, cmod and mod when using PMCs . <br /></li><li>Updated editor documentation regarding generating tags</li><li>Updated documentation about math functions in Ch04 of <a href="http://docs.parrot.org/parrot/latest/html/index.html">The PIR Book</a></li><li>I will be the release manager of Parrot 1.7, which is getting released October 20th. Exciting!<br /></li></ul>]]>
        
    </content>
</entry>

<entry>
    <title>Parrot Hacktivity Report</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/08/parrot-hacktivity.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.195</id>

    <published>2009-08-18T06:46:42Z</published>
    <updated>2009-08-18T16:16:41Z</updated>

    <summary>What I&apos;ve been hackin&apos; on in Parrot-land, gonzo-style:Note: PMC&apos;s are PolyMorphic Classes or as the Parrot hackers like to call them, Parrot Magic Cookies.Wrote a bunch of tests, fixed some bugs and updated documentation for the parrot_debuggerAdded the ability to...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="parrot" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="parrot" label="parrot" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[What I've been hackin' on in <a href="http://www.parrotcode.org/">Parro</a>t-land, gonzo-style:<br /><br /><b>Note:</b> PMC's are PolyMorphic Classes or as the Parrot hackers like to call them, Parrot Magic Cookies.<br /><br /><ul><li>Wrote a bunch of tests, fixed some bugs and updated documentation for the parrot_debugger</li><li>Added the ability to assign to most registers in the parrot_debugger, <a href="https://trac.parrot.org/parrot/ticket/901">since eval is currently broke :(</a> . Assigning to PMC registers still needs to be implemented.<br /></li><li>Added the <a href="https://trac.parrot.org/parrot/ticket/871">rand and srand dynops</a> (dynamically loadable opcodes). Parrot does not need to be recompiled to change or modify dynops.<br /></li><li>Wrote tests for the other dynops, <a href="https://trac.parrot.org/parrot/ticket/819">slyly named obscure</a><br /></li><li>Got rid of the deprecated Random PMC as well as updating all tests and documentation which referred to it. This involved fiddling with fun stuff like the befunge interpreter written in <a href="http://en.wikipedia.org/wiki/Parrot_intermediate_representation">PIR</a> and the OpenGL examples (<a href="https://trac.parrot.org/parrot/ticket/924">which evidently don't work on the latest OS X</a>)<br /></li><li><a href="http://rakudo.org/">Rakudo</a> was using the Random PMC internally and it's test suite, so my commit to Parrot broke Rakudo from even compiling on the latest Parrot. I attempted to switch Rakudo over to use the new rand/srand dynops, but they were not being installed. I <a href="http://github.com/leto/parrot/commit/33a9522d37e90cd590543074ece00760cdf276d7">added the files to Parrot's MANIFEST.generated </a>(thanks to jnthn++ for the hint), which stores where all installable files live. Rakudo was then able to find them and I had a once again compiling Rakudo with a passing "make test". With help from moritz++, <a href="http://github.com/rakudo/rakudo/commit/56372080883f2204224912b4213b3a0383e0198e">my patch was accepted</a> and Rakudo was once again passing "make spectest." The turn-around time on this was amazing and I would like to thank everyone in #parrot and #perl6 for making it happen.<br /></li><li>Added <a href="http://github.com/leto/parrot/commit/d44bfb889490e3eba67c554e0a309e18935121d8">more tests for correct handling of NaN/Inf</a></li><li>Added the test directory t/pir for compiler-agnostic tests for PIR, after talking to bacek++. I attempted to test the<a href="https://trac.parrot.org/parrot/ticket/911"> broken .macro_local feature</a>, but it seems that it is not currently possible to write TODO tests in PIR for PIR that does not parse. Punted on that and just wrote some simple tests for basic macro expansion.<br /></li><li>Wrote tests for <a href="https://trac.parrot.org/parrot/ticket/101">pbc_disassemble and pbc_dump</a></li><li>I have a mirror of the <a href="http://github.com/leto/parrot/commits/upstream">Parrot subversion repo on github</a>, with all of the currently active Parrot branches mirrored as well. The github <a href="http://github.com/leto/parrot/network">network mode</a> lets you see the relative states of each branch (flash required).<br /></li></ul> ]]>
        
    </content>
</entry>

<entry>
    <title>GSoC Bird of Feather Session at OpenSourceBridge</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/06/gsoc-bird-of-feather-session-at-opensourcebridge.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.193</id>

    <published>2009-06-27T21:25:21Z</published>
    <updated>2009-06-27T19:41:07Z</updated>

    <summary>The first day of OpenSourceBridge was amazing and we finished it off by having a Bird of Feather session for people involved and/or interested in Google Summer of Code.I know that it was very helpful to hear and talk about...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="gsoc" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="osbridge" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="gsoc" label="gsoc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gsoc2009" label="gsoc2009" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="osb09" label="osb09" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="osbridge" label="osbridge" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[<br />The first day of <a href="http://opensourcebridge.org/">OpenSourceBridge</a> was amazing and we finished it off by having a <a href="http://opensourcebridge.org/sessions/282">Bird of Feather session</a> for people involved and/or interested in <a href="http://code.google.com/soc/">Google Summer of Code</a>.<br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://leto.net/dukeleto.pl/pics/2009/gsoc_bof_osbridge1.html" onclick="window.open('http://leto.net/dukeleto.pl/pics/2009/gsoc_bof_osbridge1.html','popup','width=1024,height=768,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://leto.net/dukeleto.pl/pics/2009/gsoc_bof_osbridge1-thumb-400x300.jpg" alt="gsoc_bof_osbridge1.jpg" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" height="300" width="400" /></a></span>I know that it was very helpful to hear and talk about how the current GSoC is going with my fellow organization admins, mentors and students. Cat Allman, Ellen Ko and <a href="http://www.hawthornlandings.org/">Leslie Hawthorn</a> contributed a lot of knowledge and experience about how to deal with things when they go pear-shaped, and I even met an organization and mentor that are my neighbors! Some of the great ideas that came out of this were that first-year organizations would be greatly helped by having a "buddy" organization that has been involved in GSoC before, so that a brand-new organization admin can have a friendly ear to bend when they need help. I mentioned this because I usually bend <a href="http://web.cecs.pdx.edu/%7Ebart/">Bart Massey</a>'s ear when I need some GSoC guidance, and I thought that other first-year admins could also greatly benefit from something like this.<br /><br />I was a mentor for the <a href="http://www.perlfoundation.org/">The Perl Foundation</a> last year, with the <a href="http://leto.net/code/Math-GSL/">Math::GSL</a> project and this year I find myself the organization admin as well as a mentor for the <a href="http://github.com/leto/math--primality/tree/master">Math::Primality</a> project, which implements advanced prime-checking algorithms for Perl 5. It is definitely a big step to go from mentor to admin and meeting up with people in the same situation really helps!<br /><br />I will definitely be going to OpenSourceBridge next year and hope that we have a GSoC meetup there again. <br /><br /><br />]]>
        
    </content>
</entry>

<entry>
    <title>Google Summer of Code Updates</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/06/google-summer-of-code-updates.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.192</id>

    <published>2009-06-14T20:32:01Z</published>
    <updated>2009-06-14T21:04:27Z</updated>

    <summary>If all the dates and timelines of Google Summer of Code have you confused, this nice color-coded visualization of each part of the summer may help make it more sense.Next week is the super-cool-with-extra-awesomesauce conference Open Source Bridge, which is...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="gsoc" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="gsoc" label="gsoc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gsoc2009" label="gsoc2009" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="osbridge" label="osbridge" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[If all the dates and timelines of <a href="http://code.google.com/soc/">Google Summer of Code</a> have you confused, this nice <a href="http://nuigroup.com/?ACT=28&amp;fid=87&amp;aid=2773_08qYtJL80RoO5rMiSnMp">color-coded visualization of each part of the summer</a> may help make it more sense.<br /><br />Next week is the super-cool-with-extra-awesomesauce conference <a href="http://opensourcebridge.org/">Open Source Bridge</a>, which is all about being an "open source citizen." ( I recently had to explain to someone that it was not an "Open Sores Conference". Much hilarity ensued) . There will be many open source folk from around to globe, including many GSoC mentors, students and the program manager, <a href="http://www.hawthornlandings.org/">Leslie Hawthorn</a>. This prompted me to create a <a href="http://opensourcebridge.org/sessions/282">Bird of Feather session for GSoC people</a>. This is for anybody that has every been part of <a href="http://code.google.com/soc/">GSoC</a> or is interested in participating in the future. Come on by and hang out!<br /><br />As always, you can find us in <b>#soc-help</b> on<b> irc.perl.org</b> if you want to get involved.<br /><br /><br /><br /><br /><br />]]>
        
    </content>
</entry>

<entry>
    <title>The Perl Foundation GSoC2009 Roundup</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/06/perl-foundation-gsoc2009-roundup.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.190</id>

    <published>2009-06-07T01:41:30Z</published>
    <updated>2009-06-07T02:34:10Z</updated>

    <summary>So much has been going on this summer of code! As a recap, TPF got nine student slots this year, which means we have nine mentors and nine students working on various things this summer. Here is a sample of...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="gsoc" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="gsoc" label="gsoc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gsoc2009" label="gsoc2009" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[So much has been going on this <a href="http://code.google.com/soc/">summer of code</a>! As a recap,<a href="http://www.perlfoundation.org/"> TPF</a> got nine student slots this year, which means we have nine mentors and nine students working on various things this summer. Here is a sample of what has been going on recently.<br /><br /><a href="http://fooko.blogspot.com/">Pascal Gaudette</a> describes his <a href="http://fooko.blogspot.com/2009/05/week-1-thrill-of-hunt.html">love for debugging tricky HTTP/1.1 issues in Mojo</a> <br />and has even <a href="http://fooko.blogspot.com/2009/06/week-2-ghosts-deeper-bugs-first-feature.html">added a "featurette."</a>&nbsp; <a href="http://www.codedright.net/">Devin Austin</a> has been talking about <br /><a href="http://www.codedright.net/2009/05/ripping-the-guts-out-of-catalysthelper.html">eviscerating Catalyst::Helper</a> and <a href="http://www.parrot.org/darbelo">Daniel Arbelo Arrocha</a> has thoughtfully<br />detailed the difference between <a href="http://www.parrot.org/content/bonding.-not-bondage.-theres-difference.">bonding and bondage</a>. My student, <a href="http://blog.bobkuo.com/category/google-summer-of-code/feed/">Robert Kuo</a>,<br />has been busy reading the <a href="http://mpqs.free.fr/LucasPseudoprimes.pdf">mathematical paper</a> and example C implementation&nbsp; of<br />the <a href="http://mathworld.wolfram.com/StrongLucasPseudoprime.html">Strong Lucas Pseudoprime</a> primality test for <a href="http://github.com/leto/math--primality/tree/master">Math::Primality</a> . While installing <a href="http://search.cpan.org/dist/Math-GMPz/">Math::GMPz</a>, which we use to access the <a href="http://gmplib.org/">GNU Multiprecision Library (GMP)</a>, he found a small issue which caused some test failures and submitted a bug report.<br /><br />Math::Primality also <a href="http://github.com/leto/math--primality/commit/3c40e129611b868f4818ced7fe3f669a4257ef77">very recently gained a working is_prime() method</a>, which <br />works for arbitrary sized integers, due mostly to Robert Kuo's implementation<br />of <a href="http://github.com/leto/math--primality/commit/3daed338644b93a8a6c046892254698a96052aac">is_strong_lucas_psuedoprime() being finished</a>. Now you can test for prime numbers in Perl without installing<a href="http://search.cpan.org/dist/Math-Pari/"> Math::Pari</a>! More about this in a separate post!<br /><br /><a href="http://use.perl.org/%7Edoubi/journal/39078">Ryan Jendoubi</a> is working on a Perl interface for wxWebkit and <a href="http://blog.nix.is/">Hinrik Örn Sigurðsson</a><br />is working on the command line utility to read Perl 6 documentation called grok.<br /><a href="http://warpedreality.org/">Justin Hunter</a> has been hacking on his blogging software so that he can blog about<br />his work on <a href="http://search.cpan.org/dist/SQL-Translator/">SQL::Translator</a>. Sometimes it's a vicious cycle...<br /><br />Back to hacking on some code!<br /><br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Why would you ever store a reference to a Perl string?</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/06/why-would-you-ever-store-a-reference-to-a-perl-string.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.191</id>

    <published>2009-06-06T03:12:26Z</published>
    <updated>2009-06-06T09:31:17Z</updated>

    <summary>To use less memory! You may think thatmy $x = &apos;foo&apos;; my $y = $x;would store the string &apos;foo&apos; in one place, and then when $y gets changed, use the new string. It doesn&apos;t. To see this, we can use...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="optimization" label="optimization" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[To use less memory! You may think that<br /><br />my $x = 'foo'; my $y = $x;<br /><br />would store the string 'foo' in one place, and then when $y gets changed, use the new string. It doesn't. To see this, we can use<a href="http://search.cpan.org/dist/Devel-Peek/Peek.pm"> Devel::Peek</a> from the <a href="http://search.cpan.org/dist/perl-5.10.0/pod/perldebug.pod">perl debugger</a>. We start it up with <br /><br />perl -de0<br /><br />which I have aliased to<b> p</b> in vim, because yes, I am that lazy and I loves me some debugger. Once we are in the debugger you have to use the module. Note that the debugger output is bolded.<br /><br />&nbsp;<b>DB&lt;1&gt; </b>use Devel::Peek<br /><br />Then define a variable<br />
<br />
 <b>&nbsp;DB&lt;2&gt;</b><i> </i>$x = 'foo'<br /><br />PROTIP: You can't use <b>my $x</b> in the interactive debugger because each line of input to the debugger gets wrapped in it's own lexical scope, a lexical variable (i.e one defined with my) will not exist outside of this inner scope.<br /><br />Now we use the "x" debugger command, which prints out the result of executing some Perl code. We give it the code Dump $x, which calls Devel::Peek's Dump method on $x, which prints out low-level information about the internal properites of a variable.<br />
<br />
 &nbsp;<b>DB&lt;3&gt;</b> x Dump $x<br />
<b>SV = PV(0x9542ca4) at 0x9565924<br />
 &nbsp;REFCNT = 1<br />
 &nbsp;FLAGS = (POK,pPOK)<br />
 &nbsp;PV = 0x95731b8 "foo"\0<br />
 &nbsp;CUR = 3<br />
 &nbsp;LEN = 4<br />
 &nbsp;empty array</b><br />
 <br />SV is Perl-internals-speak for "scalar value" and the PV means that it is a string. The reference count is 1, which means only one thing, itself, points to itself. When a variable goes out of scope, the REFCNT goes to 0 and the Perl garbage collector recycles it. The FLAGS containing POK tells us that is a valid string. Take note that the PV line shows us the memory address that the string is stored at, as well as it's value and that it is null-terminated. <br /><br />Now let's set a new variable equal to $x. <br /><br />&nbsp;<b>DB&lt;4&gt;</b> $y = $x<br /><br />
Now let's take a look at it:<br /><br />
 <b>&nbsp;DB&lt;5&gt;</b> x Dump $y<br />
<b>SV = PV(0x9542c2c) at 0x958ab70<br />
 &nbsp;REFCNT = 1<br />
 &nbsp;FLAGS = (POK,pPOK)<br />
 &nbsp;PV = 0x958b968 "foo"\0<br />
 &nbsp;CUR = 3<br />
 &nbsp;LEN = 4<br />
 &nbsp;empty array<br /><br /></b>The PV line is the most interesting. If you compare it to above, you will see that it is a <b>different</b> memory address! Not just the overhead of each Perl variable is being stored, but the string 'foo' is being stored in two different places! <br /><br />Now imagine that our string is a few hundred megabytes, and you are manipulating it. You are really going to notice having a few extra copies of it around, aren't you! If you know that you have a lot of data structures that have the same string in them, use a reference to save memory. If you are running up against "perl Out of memory!", this could be a trick that gets you out of that bind without buying more RAM. <br /><br />Let's check out the memory savings with <a href="http://search.cpan.org/dist/Devel-Size/lib/Devel/Size.pm">Devel::Size</a>, a nice module which can tell you how much memory your Perl variables are using.<br />&nbsp; <br /><b>DB&lt;1&gt;</b> use Devel::Size qw/size total_size/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /><br />Next we create a longish string.<br /><br /><b>DB&lt;2&gt; </b>$x = 'i like eating memory' x 1000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /><br />We can use the size() function to see how much memory it is using:<br /><br /><b>DB&lt;3&gt;</b> x size($x)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />0&nbsp; 20036<br /><br />Now let us dump a hash which has this string repeated as two values. We use the total_size() function, which follows references:<br /><br /><b>DB&lt;4&gt;</b> x total_size( { a =&gt; "foo", b =&gt; $x, c =&gt; $x } )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />0&nbsp; 40253<br /><br />Now we do the same, but we store references to the strings:<br /><br /><b>DB&lt;5&gt;</b> x total_size( { a =&gt; "foo", b =&gt; \$x, c =&gt; \$x } )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />0&nbsp; 20249<br /><br />Roughly half the size!<br /><br />And that is why you would use references to Perl strings. Why else would you?<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Test::More eating your memory?</title>
    <link rel="alternate" type="text/html" href="http://leto.net/dukeleto.pl/2009/05/testmore-eating-your-memory.html" />
    <id>tag:leto.net,2009:/dukeleto.pl//9.188</id>

    <published>2009-05-15T13:30:20Z</published>
    <updated>2009-05-16T01:36:26Z</updated>

    <summary>It always humors me when I am having some issue with a Perl module, thinking that I am the only one, and then reading my RSS feed and seeing someone having exactly the same issue. I wrote an eXtended Test...</summary>
    <author>
        <name>Jonathan Leto</name>
        
    </author>
    
        <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://leto.net/dukeleto.pl/">
        <![CDATA[It always humors me when I am having some issue with a Perl module, thinking that I am the only one, and then reading my RSS feed and seeing someone having exactly the same issue. <br /><br />I wrote an <a href="http://leto.net/dukeleto.pl/2009/04/testxt-standardizes-author-tests.html">eXtended Test</a> (xt/verify_strong.t) for <a href="http://search.cpan.org/dist/Math-Primality/">Math::Primality</a> which verifies that it correctly identified all strong pseudoprimes less than 1e15. That is 1,000,000,000,000,000 ! There end up being&nbsp; 419489 such numbers, so I thought nothing of writing<br /><br />use Test::More tests =&gt; 419489;<br /><br />Needless to say, I was a bit worried to see my test process constantly eating RAM, ending up utilizing about 650MB of RAM before exiting. I thought that maybe there was a memory leak in <a href="http://search.cpan.org/dist/Math-GMPz/">Math::GMPz</a>, which Math::Primality uses to access the <a href="http://gmplib.org/">GNU MultiPrecision (GMP) library</a>. But after <a href="http://github.com/leto/math--primality/commit/cb1319da22687f187755ac80f20ede19b5fec6c9">making this small patch to roll my own ok() method</a>, my memory usage plummeted to about 50MB, over a 90% memory usage decrease!<br /><br />The <b>very next day</b> I see <a href="http://onionstand.blogspot.com/2009/05/testmore-memory-issues.html">garu talking about the very same issue</a>. Evidently it is <a href="http://code.google.com/p/test-more/issues/detail?id=43">"working as designed"</a> according to Schwern and it comes down to Test::Builder saving the history/output of every test, which is not currently configurable. This is one of the many things that <a href="http://www.perlfoundation.org/test_builder_2">Test::Builder2</a> will hopefully solve.<br />]]>
        
    </content>
</entry>

</feed>
