Saturday, December 12, 2009

[Protium] PLEAC 1.0

<@ OMT>-----------------------------</@>

<@ LETVARLIT>string|\n</@>
<@ OMT>two characters, \ and n</@>
<@ LETVARLIT>string|Jon 'Maddog' Orwant</@>
<@ OMT>literal single quotes</@>
<@ OMT>-----------------------------</@>

<@ LETVARLIT>string|
<@ OMT>a "newline" character</@>
<@ LETVARKEY>string|__Newline</@>
<@ OMT>a "newline" character</@>
<@ LETVARLIT>string|Jon "Maddog" Orwant</@>
<@ OMT>literal double quotes</@>
<@ LETVAREXPLIT>string|Jon &pipe;Maddog&pipe; Orwant</@>
<@ LETVAREXPLIT>string|Jon <&prot;>Maddog</&prot;> Orwant</@>
<@ OMT>Because | and <@ and </@ are significant there are ways to quote them</@>
<@ LETVARLIT>Bruce Goose|布魯斯鵝</@>
<@ OMT>a variable name containing spaces.
A variable containing Unicode.
Programming code in Unicode.</@>
<@ OMT>-----------------------------</@>

<@ OMT>Multi-line strings.
There is no equivalent to perl's "here" documents in Protium</@>

This is a multiline string
that spans 3 lines (it contains 3 newline characters).

<@ LETVARLIT>string|This is a multiline string
that spans 2 lines (it contains 1 newline character).</@>

<@ OMT>-----------------------------</@>

[Protium] PLEAC in Protium

PLEAC, for those unfamiliar with it, is the Programming Language Examples Alike Cookbook. This is a brilliant site which takes examples of Perl, given in Perl Cookbook by Christiansen and Torkington, and invites contributors to demonstrate how other languages implement the same functionality. Many languages are in the process of being compared and contrasted in this way, including Python, Ruby, Tcl and Haskell. All manner of functionality is covered, from Strings, Numbers, Dates and Times through to Internet Services, CGI Programming and Web Automation.

For the next few postings I am going to do a PLEAC for Protium. You won't find Protium on PLEAC's pages because PLEAC is limited to open-source languages. Protium is proprietary and closed-source (at present.)

The challenge with converting from Perl to Protium is similar to that faced by linguists translating from one human language to another: do you translate the sense of the utterance, or do you just translate word for word. For example, the Tok Pisin word rabisman literally means "rubbish man". However, it is almost never used that way. Instead it often carries the sense of "fool" or "good-for-nothing." So when converting the Perl to Protium, I've tried to give the sense of the Perl, rather than follow it line for line or word for word.

There will be the odd non-PLEAC posting, but I will try to work my way through the entire PLEAC, all 300K's worth.