PiVersity Back to piversity.net

Download & Install

PUGofer

Pug is the interpreter for PUGofer, a teaching language built on Gofer 2.30a. Everything below is a ready-made program: there is nothing to compile and nothing else to install. Pick your machine, follow three short steps, and you will be running code in a couple of minutes.

1 Download

Choose the file that matches your computer. If you are not sure whether your Windows or Linux machine is 32-bit or 64-bit, the file below is the right one either way.

Your computer Windows Any modern version · 227 KB Download for Windows
Your computer Linux 64-bit Intel/AMD · 271 KB Download for Linux
Your computer macOS Apple Silicon · 130 KB Download for macOS

Every download contains the same four files: the pug program itself, plus three prelude files named pustd.pre, pusimple.pre and pucc28.pre. Keep all four together in one folder.

Pug looks for pustd.pre in the folder you are currently in, not the folder the program lives in. The simplest approach is to move into that folder before starting it. If you would rather start Pug from anywhere, see running Pug from any folder.

2 Install

There is no installer to run. Installing means unzipping the folder somewhere you can find again, then starting the program from a terminal.

Windows

  1. Download pug_windows.zip using the button above.
  2. Right-click the downloaded file and choose Extract All. Extract it to a short path you will remember, such as C:\pug.
  3. Press Win+R, type cmd and press Enter to open a Command Prompt.
  4. Move into the folder and start Pug:
cd C:\pug
pug.exe

Windows may show a blue Windows protected your PC box, because this program is not code-signed. Click More info, then Run anyway. This is expected for small independent programs and does not mean anything is wrong.

Linux

  1. Download pug_linux.zip using the button above.
  2. Open a terminal, move to wherever the file was saved (usually ~/Downloads), then unzip it and mark the program runnable:
cd ~/Downloads
unzip pug_linux.zip -d pug
cd pug
chmod +x pug
./pug

Nothing else needs to be installed. The line editor is built into the program, so there are no libraries to add. You need glibc 2.29 or newer, which means Ubuntu 20.04 or later, Debian 11 or later, or RHEL, Rocky and Alma 9 or later.

macOS

  1. Download pug_macos.zip using the button above.
  2. Double-click the file in Finder to unzip it.
  3. Open Terminal, move into the unzipped folder, and clear the download quarantine flag once:
cd ~/Downloads/pug_macos
xattr -d com.apple.quarantine pug
chmod +x pug
./pug

The xattr line is needed because macOS refuses to run downloaded programs that are not signed by a registered Apple developer. Without it you will see a message saying the program cannot be opened.

This build is for Apple Silicon Macs, meaning M1, M2, M3 and M4. Intel Macs are not supported.

3 Your first session

When Pug starts it prints a banner, loads the standard prelude and shows a ? prompt. That prompt is where you type.

Gofer Version 2.30a
Modifications for pugofer Rusi Mody
Copyright (c) Mark P Jones 1991-1994
Copyright (c) Rusi P Mody  1995-2016

Gofer session for:
pustd.pre
? 

Type an expression, press Enter, and Pug prints the answer together with its type. Type :quit to leave.

The one thing that surprises everybody

PUGofer does not use a space to apply a function to its argument. You must write a dot between them. This is deliberate: it makes the structure of an expression explicit.

Write this Not this
length . "hello" length "hello"
sum . [1,2,3,4,5] sum [1,2,3,4,5]
map . (*2) . [1,2,3] map (*2) [1,2,3]

If you see ERROR: Juxtaposition has no meaning. Use . then you have left out a dot. Ordinary arithmetic needs no dot at all: 2+3*4 just works.

A complete short session looks like this:

? length . "hello"
5 : Int
? sum . [1,2,3,4,5]
15 : Int
? map . (*2) . [1,2,3]
[2, 4, 6] : [Int]
? 2+3*4
14 : Int
? :quit
[Leaving Gofer]

Running Pug from any folder

By default Pug looks for pustd.pre in whichever folder you started it from, which is why the steps above tell you to move into the unzipped folder first. If you would rather start Pug from anywhere, set the PUGOFER environment variable to the full path of the prelude file. When it is set, Pug loads that file instead of searching the current folder.

Linux and macOS

To try it for a single command:

PUGOFER=~/Downloads/pug/pustd.pre ~/Downloads/pug/pug

To make it permanent, add these two lines to ~/.bashrc, or to ~/.zshrc if you use zsh, then open a new terminal. The second line lets you type just pug from anywhere.

export PUGOFER="$HOME/Downloads/pug/pustd.pre"
export PATH="$HOME/Downloads/pug:$PATH"

Windows

Run this once in Command Prompt, then close the window and open a new one. setx saves the setting permanently, but it only takes effect in Command Prompt windows opened afterwards.

setx PUGOFER "C:\pug\pustd.pre"

When it is working, the startup banner shows the full path it loaded rather than a bare filename:

Gofer session for:
/home/you/Downloads/pug/pustd.pre
? 

PUGOFER chooses which prelude is loaded, not just where it lives. Point it at pusimple.pre or pucc28.pre instead of pustd.pre to start with one of the other two preludes included in the download.

If something goes wrong

FATAL ERROR: Unable to load prelude

The whole message looks like this:

ERROR "pustd.pre": Unable to open file

FATAL ERROR: Unable to load prelude

Pug could not find pustd.pre. This is the most common problem by far, and it means you started Pug from a folder other than the one holding the unzipped files. Either move into that folder first, or set the PUGOFER environment variable as described under running Pug from any folder.

ERROR: Attempt to redefine syntax of operator

You passed a prelude file on the command line, as in ./pug pustd.pre. Pug already loads it by itself. Start it with no arguments: just ./pug, or pug.exe on Windows.

Linux: version `GLIBC_2.29' not found

Your distribution is older than this build supports. You need Ubuntu 20.04 or later, Debian 11 or later, or RHEL, Rocky or Alma 9 or later.

Linux: bash: ./pug: Permission denied

The runnable flag was not set. Run chmod +x pug in the folder, then try again.

macOS: the program "cannot be opened"

The quarantine flag is still set. Run xattr -d com.apple.quarantine pug in the folder holding the file.

Checksums, for anyone who wants to verify a download
9eea2ac3cd59a4a5863927db8d27228430fe0c5f48ab1315db04a7446875beee  pug_linux.zip
14637772b1f54e52eff1f7a60d2cd4d2b5c0b7567ae40177c30e704c9e9765b8  pug_macos.zip
252bff23ca1fd9917d27dba09446d8ac88019352d5aaafb56947e91ec9b74d57  pug_windows.zip

Check one with sha256sum pug_linux.zip on Linux, shasum -a 256 pug_macos.zip on macOS, or certutil -hashfile pug_windows.zip SHA256 on Windows.