100 Languages Speedrun: Episode 84: Lingua Romana Perligata
Tags: perl, latin
Published: 2022-02-10 19:45:23

Lingua Romana Perligata is basically Perl in Latin.

You think Perl has too much punctuation? It's all gone. Instead you'll need to deal with word endings.

To enjoy Lingua Romana Perligata you need to install it with `cpan Lingua::Romana::Perligata` and put appropriate annotation at start of the program. It will run as normal Perl from that point on.

Just a forewarning if you want to try - a lot of examples from documentation just plain don't work.

### Hello, World!

```perl
#!/usr/bin/env perl

use Lingua::Romana::Perligata;

adnota Salve, Mundus! in Lingua Romana Perligana

dictum sic Salve, Mundus! cis tum novumversum egresso scribe.
```

```
$ ./hello.latin
Salve, Mundus!
```

Step by step:

* I'm using `brew` version of Perl instead of the one bundled with OSX, so `#!/usr/bin/env perl`
* `use Lingua::Romana::Perligata;` starts the Lingua Romana Perligata mode - we can pass some flags here to enable grammar debugging, and we'll definitely need that at some point
* there's no punctuation except `.` at end of sentences
* comments start with `adnota` and go until end of the line
* there's no quotes, there are a few other ways to create strings instead; documentation suggests `X inquementum` but that seems to work very unreliably depending on what's `X` exactly, which is one of many bugs in the language
* `dictum sic ... cis` seems to work a lot better for creating quoted strings
* there's no string interpolation, we'll need to concatenate
* `egresso scribe` means "write to standard output"
* `tum` means "and then"
* `novumversum` means "newline"
* so `dictum sic Salve, Mundus! cis tum novumversum egresso scribe` means "write to standard output the string `Salve, Mundus!` and then a newline"

### Loop

Let's print numbers `1` to `10`. Sorry, I meant `I` to `X`.

```
meis listis unum tum decem conscribementa da.

per quisque in listis fac
  sic
    hoc comementum tum novumversum egresso scribe
  cis.
```

```
$ ./loop.latin
I
II
III
IV
V
VI
VII
VIII
IX
X
```

Step by step:

* `meis listis` is `my @list` and declares a local plural variable - we'd say `meo varo` for `my $var`
* `da` means "is"
* `unum tum decem conscribementa` means `1..10` - you can also use `I tum X conscribementa` with Roman numerals
* `per quisque in listis fac` means `for each(@list)`
* `sic ... cis` is a block of code
* `egresso scribe` means "write to standard output"
* `hoc` is `$_`
* `comementum` (beautify) converts the number to Roman numeral form
* `tum novumversum` means "and then newline"
* so `hoc comementum tum novumversum egresso scribe` means "write to standard output `$_` converted to Roman numeral and then a newline"

### Greetings

Let's greet a specific person.

```
meo nomo vestibulo perlegementum da.

nomo morde.

dictum sic Salve, cis tum lacunam tum nomum tum novumversum egresso scribe.
```

```
$ ./greetings.latin
Marcus
Salve, Marcus
```

Step by step:

* `meo nomo ... da` means `my $name = ...`
* `vestibulo` (entrance) means `STDIN`
* `vestibulo perlegementum` means "read line from STDIN"

### FizzBuzz

```
meis listis I tum C conscribementa da.

per quisque in listis fac
  sic
    fizzo hoc tum III recidementum da.
    buzzo hoc tum V recidementum da.

    si non fizzum fac sic Fizz egresso scribe cis.

    si non buzzum fac sic Buzz egresso scribe cis.

    si fizzum atque buzzum fac sic hoc comementum egresso scribe cis.

    novumversum egresso scribe.
  cis.
```

It does the FizzBuzz:

```
./fizzbuzz.latin
I
II
Fizz
IV
Buzz
Fizz
VII
VIII
Fizz
Buzz
XI
Fizz
XIII
XIV
FizzBuzz
XVI
XVII
Fizz
XIX
Buzz
...
Fizz
XCVII
XCVIII
Fizz
Buzz
```

Step by step:

* `meis listis I tum C conscribementa da` - `my @list = (1..100)`
* `per quisque in listis fac sic ... cis` - `for each (@list) { ... }`
* `recidementum` means "modulo"
* `fizzo hoc tum III recidementum da` - `$fizz = $_ % 3` (these are maybe not the best names, as Fizz should be printed if `$fizz` is zero, that is false; and same for `$buzz`)
* `buzzo hoc tum V recidementum da` - `$buzz = $_ % 5`
* `si non fizzum fac sic Fizz egresso scribe cis` - `if (not $fizz) { print "Fizz" }`.
* `si non buzzum fac sic Buzz egresso scribe cis` - `if (not $buzz) { print "Buzz" }`.
* `atque` means `and`
* `si fizzum atque buzzum fac sic hoc comementum egresso scribe cis` - `if ($fizz and $buzz) { print Roman($_) }`
* if you remove `comementum` it will print ASCII numbers instead of Roman numerals, so you'll get exact match for the traditional FizzBuzz
* `novumversum egresso scribe.` - print a newline

### Fibbonacci

All right, one more thing, let's define Fibbonacci function.

```
fibonere
sic
  meis numero haec da.

  si numerum tum tres praestantiam fac sic redde unum cis.

  meo xo numerum tum I demementum fibonementum da.
  meo yo numerum tum II demementum fibonementum da.

  redde xum tum yum addementum.
cis.

meis listis unum tum XX conscribementa da.

per quisque in listis fac
  sic
    meo fibo hoc fibonementum da.
    fibum egresso scribe.
    novumversum egresso scribe.
  cis.
```

```
$ ./fib.latin
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
```

Step by step:

* we define the function with `fibonere sic ... cis` - it knows that's function definition by the ending
* `meis numero haec da` means `my ($number) = @_`
* the far more grammatical `meo numero haec da` would translate to `my $number = @_` and that means "number of arguments" not "first argument", not like anything here is proper Latin anyway
* `redde` means `return`
* `praestantiam` means less than
* `si numerum tum tres praestantiam fac sic redde unum cis` means "if $number is less than 3, return 1"
* `meo xo numerum tum I demementum fibonementum da` means `$x = fib($number - 1)`
* `meo yo numerum tum II demementum fibonementum da` means `$y = fib($number - 2)`
* `redde xum tum yum addementum` means `return $x + $y`

### Should you use Lingua Romana Perligata?

It's a joke language obviously, but it's not a very well executed joke. Rules are unclear (even if you know some Latin), there are too few examples, many of the examples in documentation don't even work, or break if you do a trivial change. If you use the wrong ending (or one that's correct in real Latin), you get terrible error message, or the program just happily doing something else like treating it as uninitialized variable. I don't find it particularly fun.

I wanted to try it out due to its notoriety in the Perl world, but I wouldn't really recommend it. I had a lot more fun with languages like Asciidots or Whenever.

Another thing - this might look like Latin to someone who doesn't know any Latin, but it's mostly gibberish not following either proper lexicon or proper grammar. It's impressive that it got that far to Latin-like, but it's still not all that close.

### Code

[All code examples for the series will be in this repository](https://github.com/taw/100-languages-speedrun).

[Code for the Lingua Romana Perligata episode is available here](https://github.com/taw/100-languages-speedrun/tree/master/episode-84-lingua-romana-perligata).