Hello World in BASIC

docker pull codearchaeology/basic:latest

BASIC was designed to be beginner-friendly, and it shows. Let’s write Hello World.

The Code

Create a file named hello.bas:

1
PRINT "Hello, World!"

That’s it. One line.

Classic Numbered BASIC

In the original BASIC dialects, every line needed a line number:

1
2
10 PRINT "Hello, World!"
20 END

Understanding the Code

  • PRINT - Outputs text to the screen
  • "Hello, World!" - A string literal enclosed in quotes
  • Line numbers - Originally required for program flow and editing

Running with Docker

Using FreeBASIC in Docker:

1
2
3
4
5
6
# Pull the image
docker pull codearchaeology/basic:latest

# Run the program
docker run --rm -v $(pwd):/code -w /code codearchaeology/basic:latest \
    sh -c "fbc hello.bas && ./hello"

Running Locally

Install FreeBASIC and run:

1
2
3
4
5
# Compile
fbc hello.bas

# Run
./hello

Expected Output

Hello, World!

Key Concepts

  1. BASIC is simple - Designed for beginners, minimal syntax
  2. PRINT is fundamental - The primary output command
  3. Modern vs Classic - Modern BASIC doesn’t require line numbers
  4. Multiple dialects - Many versions exist (GW-BASIC, QBasic, FreeBASIC, etc.)

Historical Context

When BASIC was created in 1964, most programming required punch cards and specialized training. BASIC changed that, making programming accessible to students and hobbyists. This accessibility made it the first language for millions of programmers.

Next Steps

Continue to Variables and Data Types to learn about storing data in BASIC.