Hello World in MUMPS
Your first MUMPS program - the classic Hello World example with Docker setup
Every programming journey starts with Hello World. Let’s write our first MUMPS program using YottaDB, an open-source MUMPS implementation.
The Code
Create a file named hello.m:
hello ; Hello World in MUMPS
write "Hello, World!",!
quit
Understanding the Code
hello- A label starting in column 1. This is the routine name and must match the filename (without the.mextension).; Hello World in MUMPS- A comment. Everything after;on a line is a comment.write "Hello, World!",!- Note the leading space! Executable code must be indented. Thewritecommand outputs text. The,!after the string outputs a newline.quit- Ends execution of the routine. Also indented with a leading space.
Why the Leading Space Matters
In MUMPS, the first character of each line has special meaning:
- Column 1 starts with a letter = This is a label (routine name, subroutine name)
- Column 1 starts with a space or tab = This is executable code
- Column 1 starts with
;= This is a comment line
Forgetting the leading space on executable lines is the most common beginner mistake.
Running with Docker
The easiest way to run MUMPS without installing YottaDB locally:
| |
How the Docker Command Works
-v $(pwd):/app- Mounts your current directory into the container at/app-e ydb_routines=/app- Tells YottaDB where to find your.mroutine filesyottadb -run hello- Runs the routine namedhello(fromhello.m)
Running Locally
If you have YottaDB installed on Linux:
| |
Installing YottaDB
YottaDB runs natively on Linux. For macOS and Windows, use Docker or WSL.
Ubuntu/Debian:
| |
Expected Output
Hello, World!
MUMPS Interactive Mode
YottaDB also provides an interactive prompt (called “Direct Mode”) where you can type MUMPS commands directly:
| |
At the YDB> prompt, you can type:
YDB>write "Hello, World!",!
Hello, World!
YDB>halt
Command Abbreviations
One of MUMPS’s distinctive features is that every command can be abbreviated to its first letter. Our Hello World could also be written as:
hello ; Hello World abbreviated
w "Hello, World!",!
q
Here w is short for write and q is short for quit. In production MUMPS code, abbreviations are extremely common.
Key Concepts
- MUMPS has an integrated database - The language includes a built-in hierarchical database, making it unique among programming languages
- Indentation is significant - Code lines must start with a space; labels start in column 1
- Routines = files - A routine named
hellomust be in a file namedhello.m - Commands are abbreviated -
writecan bew,setcan bes,quitcan beq - Typeless - Variables have no declared type; values are coerced as needed between strings and numbers
- Case insensitive -
WRITE,Write, andwriteare all the same command
A Bit of History
When MUMPS was created in 1967 at Massachusetts General Hospital, it ran on a DEC PDP-7 with limited memory. The language’s terse syntax and command abbreviations were not just stylistic choices - they were practical necessities to fit programs into the small memory available. Today, those same abbreviations remain a hallmark of the language, and MUMPS continues to power healthcare information systems that serve millions of patients.
Running Today
All examples can be run using Docker:
docker pull yottadb/yottadb-base:latest-master