|The stupid question is the question not asked|
Pugs Baby Stepsby eyepopslikeamosquito (Canon)
|on Mar 18, 2005 at 12:26 UTC||Need Help??|
I took my first baby steps with Pugs and Perl 6 during the past week and thought I'd share the experience.
Though I doubt it really counts as Exploratory Testing I decided to help test Pugs simply by converting an existing p5 program to p6.
The tsanta.pl test program (from my first Pugs node Replaying Santa Claus Golf Apocalypse with Pugs/Perl6) has now been rewritten as tsanta.p6 so that it runs successfully using Pugs, as shown below. You will need a more recent Pugs than 6.0.11 to run it -- suggest you simply install Subversion on your machine and enter:
to get the latest Pugs release, then build it in the normal way. For full details on getting and building Pugs go to pugscode.org.
My other reason for attempting this is I feel we need more examples of real working Perl 6 code, both to help newbies learn the language and to provide valuable feedback to the Perl 6 design team. This is where I need some help from you. Though I can provide feedback on how easy Perl 6 is to learn and use for a newbie moving from Perl 5, a newbie cannot provide examples of good Perl 6 style. So, please feel free to suggest improvements to the code below (even if said improvements are not yet implemented in Pugs). It's nice to know the "right" way to do it.
The code below is constrained by the following assumptions about the current state of Pugs. If I am in error in any of these, please let us know.
So without further ado, here it is:
The code is remarkably similar to the Perl 5 version, indicating that many p5 scripts could be routinely converted to p6. I didn't try for any massive p6 improvements in converting this program -- mainly out of p6 ignorance.
I found writing this program a little frustrating mainly because of the lack of Perl 6 examples. The Synopses are important, but for learning a new language, my brain really needs lots of examples. Needless to say, if anyone knows of a good set of Perl 6 examples, please let me know.
I really like the new subs. Larry (or was it Damian) really hit the nail on the head when they said that p5 subs were, ironically, too orthogonal -- being implemented just with a special list @_ and without requiring any specialized language support at all! My first impression is that the new design of subs is a brilliant work of art and I salute the design team.
The new list stuff and functional programming support looks to be a huge improvement over p5 and I look forward to using it more in the future.
This little exercise uncovered one design bug and a couple of Pugs bugs also, so I feel it was worthwhile. If nothing else, it proves that real live working Perl 6 scripts can be written today. As a word of caution however, note that there are many p6 language features missing from Pugs today and working around them can be frustrating. On the other hand, the speed of the Pugs developers in implementing them is astonishing.
I knew there must be a better way than the slurp_file function above. As an example of the phenomenal enthusiasm and support by the Pugs developers, within an hour or so of posting a question about file slurping, autrijus has just now implemented the slurp primitive! Update: The latest version of tsanta.p6 (including replacing slurp_file above with the new slurp primitive) along with rg0now's excellent Santa golf solutions can be found under examples/golf in the Pugs distribution.
Finally, I would like to thank all the Perl 6 folks for being so helpful to a Perl 6 newbie and for not flaming me for my many silly questions. :-)