Code Like a Pirate: Arrr!

Goodness, I has been a while. Ok, here is a little something for Talk Like a Pirate Day. Or as I like to call it, Code Like A Pirate Day. And so I present to you the language Arrr! The standard “Hello, World” example looks like this in Arrr!

Arrr! is case-sensitive, with all keywords in lower case. Pirates don’t bother much with capital letters.

Statements end with an exclamation point. When pirates speak, they speak emphatically.

Except as needed to separate individual words, whitespace is ignored: tabs, spaces and line breaks can be added as needed to improve readability.

Code libraries are linked using the keyword savvy.

Code blocks begin with ahoy! and end with avast!

Names cannot be a reserved keyword. They may contain any number of alphanumeric characters, but must always start with an alpha. Because Arrr! is case-sensitive, treasure, Treasure and TREASURE will be treated as different names.

Variables are declared with the syntax tharbe variable name as type! There are three intrinsic data types:

scrimshaw – string

dubloon – integer

pieceofeight – floating point

Array variables are declared using the keyword plundered, followed by the number of elements in the array. A variable named “treasure”, defined as an array of eight integers, would be declared using tharbe treasure plundered 8 dubloons! Individual elements of the array are accessed using square brackets. Pirates have more important things to worry about than figuring out zero-indexed arrays so the first element of the array would be treasure[1].

Input from the default input device is retrieved into a variable using extort variable nametext says I! Output to the default output device is sent using parlay text! The text can be any valid text, with string variables concatenated using +.

Like C, Arrr! has only functions. Functions are introduced using chart function name to return type. If a function has no return type, the keyword home is used. Parameters are declared using with, followed by the parameter list. By default, parameters are passed by value. To pass a parameter by reference, use the common keyword. The function’s code block is enclosed in ahoy!/avast! Here is an example of a function declaration:

Functions are called using the function name. If there are any parameters, they are introduced using with:

course with rum, polly!

Loops are written with the syntax divvy variable name atwix start value to end value! The code executed during the loop is contained within an ahoy!/avast! block. By default, loops iterate with a +1 step; this can be changed by adding step value wise to the end of the statement. For example, a loop that counts down from 10 to 1 could be written: