Saturday, 28 June 2014

Installing Red on Raspberry Pi

The Red programming language is still in the bootstrap phase using a compiler written in Rebol 2. Rebol 2 doesn't run on ARM processors so at the moment programs for ARM computers have to be cross-compiled on an Intel computer.

The Red REPL (known as "console") is simply a Red program that sits on top of the Red runtime. The Red runtime is written in the low-level Red/System dialect and can be cross-complied for Linux running on ARM.

The source of the console program is included in the Red Github Repository. Assuming that a Rebol interpreter is available, cross-compiling the console takes a single terminal command:

     rebol -qs red.r -t Linux-ARM  runtime/console/

One of the many things that I like about Red is how simple it is to compile for different targets. The output from the compiler looks like this:

-=== Red Compiler 0.4.2 ===- 

Compiling /Users/peter/VMShare/Languages/Red/runtime/console/ ...
...compilation time : 395 ms

Compiling to native code...
...compilation time : 20029 ms
...linking time     : 245 ms
...output file size : 618544 bytes
...output file      : /Users/peter/VMShare/Languages/Red/console

I followed the excellent advice from Milliways on the Raspberry Pi Stack Exchange and installed netatalk on my Pi. I can now connect to my Pi from my MacBook. I simply copied the compiled Red console program over to it using OS X Finder.

Red doesn't have to be installed on the Raspberry Pi, simply type its path on the command line to run it. (The Red compiler even sets the execute bit!)

Red on Raspberry Pi
Click to enlarge

1 comment:

James said...

This was super helpful! I got Red 0.5.1 running on my Pi with this. The only thing I needed to change was the file location of the file:

rebol -qs red.r -t Linux-ARM environment/console/

Thanks Peter!