Thursday, April 30, 2009

Schwartzian Transform - Perl 5 vs. Perl 6

This isn't quite news, but it's a cool little bit of code anyway.

Perl 5:


@sorted = map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, foo($_)] }
@unsorted;


Perl 6:


@sorted = @unsorted.sort: { .uc };


I'm willing to claim that Perl 6 makes this a bit more readable, in spite of the smoke, mirrors and curtains.

Read more about the Schwartzian Transform in Wikipedia.

Monday, April 27, 2009

Perl 6 - how to get started

Are you curious about Perl 6, and wonder how to get started?

Use proto, Carl Mäsak's Perl 6 installer (which will download parrot and rakudo for you).

Just make sure you have Perl 5 (5.8.8 or 5.10.0), git and svn installed first!


jani@knuth ~/prog/proto >./proto

*** CONFIG FILE CREATED ***

Greetings. I have created a file 'config.proto' that you may want to review.
Next time you run './proto', these settings will be used to bootstrap your
system into a working Perl 6 installation.

If you're new to this, or if configure settings scare you, you probably want
the default settings anyway. The most important ones are:
Rakudo -> /ping/knuth/home0/jani/prog/rakudo
Projects -> /ping/knuth/home0/jani/prog

jani@knuth ~/prog/proto >./proto
Downloading Perl 6...downloaded
Building Perl 6...


This part may take a while; parrot is now building stuff for you, and when it's finished, you can run the perl6 binary:

Building Perl 6...built
jani@knuth ~/prog/proto >cd ../rakudo
jani@knuth ~/prog/rakudo >ls -F
CREDITS MANIFEST Test.pm parrot/ perl6.o perl6_s1.pbc tools/
Configure.pl Makefile build/ perl6* perl6.pbc src/
LICENSE README docs/ perl6.c perl6.pir t/
jani@knuth ~/prog/rakudo >./perl6
> sub sum (*@numbers) { return [+] @numbers; }; say +(sum <1 2 3>)
6



See? Easy! Now get testing!

Tuesday, April 21, 2009

Enlightened Perl Iron Man Competition

Well, if this isn't inspiring ...

This week, I hope to dedicate some time to what I said I was going to do at the NPW 2009 Hackathon, which was to spec complex number representation and presentation.

Thanks to pmichaud, I've at least confirmed my suspicions on which parts of the spec to do my changes in.

Maybe I fail, maybe I don't, but I think Perl 6 is definitely worth the effort.

Sunday, April 19, 2009

Group Photos

LR:
ilmari, nothingmuch, claes, szabgab, krunen, ingy, baest, masak, TimToady, Ellen\
trafl, jrockway, batman, pnu, jnthn, pmichaud, abigail, Gloria\
mst, sjn, mberends, marcus, sadrak
Photographer: frettled




And, finally, as prompted by Ingy:

NPW 2009 Hackathon

The NPW 2009 Hackathon is well into its second day, and I've learned quite a bit about Perl 6 and more about Perl 5 than I expected.

I didn't originally intend to participate in the Hackathon, and I'm not doing much, but it's definitely worth it.

Yesterday, I stated a goal of adding to the spec a description of how complex numbers should be represented and presented, since that was apparently at least partially unclear.

This lead me into a quagmire of other things I needed to do first, and the "ooh, shiny!" phenomenon lead me astray a few times, ganged up with my general desire to have a functional working environment (Unicode strings in PODs didn't go down well with my current Latin 1-based working environment and the then-installed Perl version), as well as problems getting irssi on my side
But I did get to participate and act as distraction in an entertaining and useful discussion regarding types in Perl 6, as well as host a social dinner for those who wanted a break from the hackathon.

Today, I'm picking up where I left off, trying to form a mental picture of the spec that's good enough to add and/or change relevants bits of it.

The rest of the guys are adding code and doing other useful things. :)