Beginner

Hello World in REXX

Your first REXX program - the classic Hello World example with Docker setup using Regina REXX

Every programming journey starts with Hello World. REXX makes this incredibly simple—the language was designed from day one to be readable and intuitive.

The Code

Create a file named hello.rexx:

1
2
/* Hello World in REXX */
say "Hello, World!"

That’s it! Just two lines—a comment and a single say instruction.

Understanding the Code

Let’s break down this simple program:

  • /* Hello World in REXX */ - A comment enclosed in /* */. REXX uses this C-style comment syntax exclusively (no line comments).
  • say "Hello, World!" - The SAY instruction outputs text to the console. No parentheses needed, no special formatting—just the keyword and the string.

The REXX Philosophy in Action

This simple example demonstrates REXX’s core design principles:

  1. Minimal syntax - No main() function, no imports, no boilerplate
  2. English-like keywords - say does exactly what the word suggests
  3. No declarations - You don’t need to declare variables or program structure
  4. Case insensitive - SAY, Say, and say all work identically

Running with Docker

The easiest way to run REXX without installing anything locally is using Regina REXX in a Docker container:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Pull the Regina REXX image
docker pull rzuckerm/rexx:3.6-5.00-1

# Create the source file
cat > hello.rexx << 'EOF'
/* Hello World in REXX */
say "Hello, World!"
EOF

# Run the program
docker run --rm -v $(pwd):/app -w /app rzuckerm/rexx:3.6-5.00-1 rexx /app/hello.rexx

Understanding the Docker Command

  • docker run --rm - Run a container and remove it when done
  • -v $(pwd):/app - Mount the current directory as /app inside the container
  • -w /app - Set the working directory to /app
  • rzuckerm/rexx:3.6-5.00-1 - The Regina REXX Docker image
  • rexx /app/hello.rexx - Run the REXX interpreter with our program

Running Locally

If you have Regina REXX installed:

1
2
# Simply run the program
rexx hello.rexx

Installing Regina REXX

macOS (Homebrew):

1
brew install regina-rexx

Ubuntu/Debian:

1
sudo apt install regina-rexx

Windows: Download from Regina REXX SourceForge.

Fedora/RHEL:

1
sudo dnf install regina-rexx

Expected Output

Hello, World!

Clean, simple output—exactly what you asked for!

Alternative Styles

REXX’s flexibility allows several ways to write Hello World:

Without the Comment

1
say "Hello, World!"

Yes, a one-line program! REXX doesn’t require any structure for simple scripts.

Using String Concatenation

1
2
3
greeting = "Hello"
target = "World"
say greeting || ", " || target || "!"

The || operator explicitly concatenates strings.

Using Adjacency Concatenation

1
2
3
greeting = "Hello"
target = "World"
say greeting", "target"!"

REXX can concatenate strings simply by placing them adjacent to each other.

Using the Abuttal Operator

1
2
3
prefix = "Hello"
suffix = ", World!"
say prefix||suffix

Without spaces, || performs abuttal (concatenation without space).

Multi-line Output

1
2
3
/* Multiple SAY statements */
say "Hello,"
say "World!"

Each say produces a new line.

Key Concepts

1. SAY Instruction

The SAY instruction is REXX’s primary output mechanism:

1
2
3
4
say "Text in quotes"        /* String literal */
say variable                /* Variable value */
say "The value is" variable /* Mixed output */
say 2 + 2                   /* Expression result: 4 */

2. Comments

REXX uses /* */ for all comments:

1
2
3
4
5
6
7
/* Single line comment */

/* Multi-line
   comment spanning
   several lines */

say "Hello" /* inline comment */ ", World!"

3. Case Insensitivity

REXX doesn’t care about case for keywords:

1
2
3
4
SAY "works"
Say "works"
say "works"
sAy "works"  /* Even this works! */

Convention typically uses lowercase in modern REXX code, though uppercase was common historically.

4. Strings

Strings can use single or double quotes:

1
2
3
4
say "Double quotes work"
say 'Single quotes work too'
say "Use 'single' inside double"
say 'Use "double" inside single'

The Minimal Program

Technically, the smallest valid REXX “Hello World” is:

1
say"Hello, World!"

No spaces required between the keyword and the string! However, for readability, always use spaces.

A Bit of History

When Mike Cowlishaw created REXX in 1979, he was frustrated with the complexity of existing scripting languages. He wanted something that:

  • A secretary could read and understand
  • A programmer could write quickly
  • A system administrator could maintain

The say instruction exemplifies this philosophy—it’s not print(), printf(), console.log(), or System.out.println(). It’s just say. The language says what it does.

This same program would have run on IBM mainframes in the 1980s, on Amiga computers in the late 1980s, on OS/2 desktops in the 1990s, and now in Docker containers in the 2020s. REXX’s simplicity has given it remarkable longevity.

Why Learn REXX Today?

While REXX isn’t the trendiest language, it offers:

  • Mainframe relevance - If you work with z/OS, MVS, or VM/CMS, you’ll encounter REXX
  • Excellent text processing - REXX’s string handling is elegant and powerful
  • Historical perspective - Understanding REXX illuminates the history of scripting languages
  • Easy learning curve - REXX can serve as a gentle introduction to programming concepts

Common Beginner Mistakes

Forgetting Quote Marks

1
2
say Hello, World!     /* Error! REXX thinks these are variables */
say "Hello, World!"   /* Correct - quoted string */

Using Wrong Comment Style

1
2
3
// This doesn't work    /* REXX doesn't support // comments */
# This doesn't work     /* No shell-style comments either */
/* This is correct */

Case Sensitivity Confusion

1
2
Name = "REXX"
say name     /* Outputs: REXX - same variable! */

Variable names are case-insensitive in REXX.

Next Steps

Continue to Variables and Data Types to learn about REXX’s unique approach to data handling, where everything is a string.

Running Today

All examples can be run using Docker:

docker pull rzuckerm/rexx:3.6-5.00-1
Last updated: