Skip to content

michaeljabbour/altairbasic

Repository files navigation

Modern ALTAIR BASIC Interpreter

This is a modern version of the historic ALTAIR BASIC programming language originally created by Bill Gates and Paul Allen in 1975. This interpreter lets you write and run programs in the classic BASIC language on your modern computer - now debugged and ready to transport you back to 1975 (thankfully without the bell-bottoms).

ALTAIR BASIC

What is BASIC?

BASIC (Beginner's All-purpose Symbolic Instruction Code) is a simple programming language designed for beginners. It was one of the first programming languages widely available for personal computers and helped introduce a generation to computer programming. Think of it as JavaScript's great-grandparent, just with more line numbers and fewer callback functions.

Getting Started

For Regular Users (Pre-built Versions)

  1. Download the Interpreter:

    • Windows: Download altair-basic-windows.zip from the Releases page
    • Mac: Download altair-basic-mac.zip from the Releases page
    • Linux: Download altair-basic-linux.zip from the Releases page
  2. Install:

    • Windows: Extract the ZIP file to any folder
    • Mac: Extract the ZIP file and move to Applications
    • Linux: Extract the ZIP file to a folder of your choice
  3. Run the Interpreter:

    • Windows: Double-click on basic.exe
    • Mac: Double-click on basic.app
    • Linux: Open terminal, navigate to the folder, and type ./basic

For Advanced Users (Building from Source)

If you're comfortable with development tools, you can build the interpreter from source:

Prerequisites

  • C++17 compatible compiler (GCC, Clang, MSVC)
  • CMake 3.10 or higher

Building

On Unix-like systems (Linux, macOS):

./build.sh

On Windows:

mkdir build
cd build
cmake ..
cmake --build .

Using the BASIC Interpreter

Starting the Interpreter

When you start the program, you'll see a welcome screen and a Ready> prompt where you can type commands.

Interactive Mode Commands

  • RUN - Run your program
  • LIST - Show your current program
  • NEW - Start a new program (erases current program)
  • LOAD filename - Load a program from a file
  • SAVE filename - Save your program to a file
  • HELP - Display help information
  • EXIT or QUIT - Exit the interpreter

Writing a BASIC Program

To create a program, type lines starting with line numbers:

10 PRINT "HELLO WORLD"
20 PRINT "MY NAME IS BASIC"
30 END

Then type RUN to execute your program.

Example BASIC Programs

The examples folder contains several sample programs you can try:

  • hello.bas - Simple "Hello, World!" program
  • factorial.bas - Calculates factorial of a number
  • arrays.bas - Demonstrates array usage
  • function_test.bas - Shows built-in functions

To run an example:

LOAD examples/hello.bas
RUN

BASIC Programming Guide

Program Structure

  • Every line must start with a line number (1-9999)
  • Lines are executed in order of line numbers
  • The program ends when it reaches an END statement or the last line

Basic Commands

  • PRINT - Displays text or values
  • LET - Assigns a value to a variable
  • INPUT - Gets input from the user
  • REM - Adds a comment (ignored when running)
  • GOTO - Jumps to a specific line number
  • IF...THEN - Conditional execution
  • FOR...NEXT - Repeating code a specific number of times
  • GOSUB...RETURN - Calls a subroutine

Variables

  • Numeric variables: A-Z, A0-Z9 (e.g., A, B1, X2)
  • String variables: A$-Z$ (e.g., A$, N$)

Example Program

10 REM This is a simple program
20 PRINT "PLEASE ENTER YOUR NAME"
30 INPUT N$
40 PRINT "HELLO, "; N$
50 PRINT "PLEASE ENTER A NUMBER"
60 INPUT X
70 LET Y = X * 2
80 PRINT X; " TIMES 2 IS "; Y
90 END

Math Functions

  • SQR(X) - Square root
  • ABS(X) - Absolute value
  • INT(X) - Integer part
  • SIN(X), COS(X), TAN(X) - Trigonometric functions
  • RND(X) - Random number

String Functions

  • LEN(X$) - Length of a string
  • LEFT$(X$, N) - Leftmost N characters
  • RIGHT$(X$, N) - Rightmost N characters
  • MID$(X$, S, N) - N characters starting at position S

Historical Significance

This implementation is based on the ALTAIR BASIC interpreter from 1975. It was the first product created by Microsoft (then called "Micro-Soft") and marked the beginning of what would become one of the world's largest technology companies.

Support and Feedback

If you encounter issues or have suggestions, please open an issue on our GitHub repository. We welcome your feedback and contributions.

Implementation Status

  • ✅ Core language features
  • ✅ Math functions
  • ✅ String handling
  • ✅ User-defined functions (sort of - we're still debugging this!)
  • ✅ Cross-platform support (Windows, macOS, Linux)
  • ✅ Fixed type compatibility between Value::Expr and basic::Expr (the bug that almost broke everything!)

What We Fixed

We bravely dove into 1975-era BASIC to fix some issues that would make even Bill Gates scratch his head:

  1. Fixed nasty type compatibility issues between Value::Expr and basic::Expr classes
  2. Made both types play nicely together with some C++ type aliasing wizardry
  3. Battled and defeated cryptic C++ template errors that looked like hieroglyphics
  4. Made FOR loops actually loop and GOTOs actually go to places
  5. Ensured subroutines come back home with RETURN statements
  6. Added simple test programs to prove it all works

Now you can relive the glory days of early computing without the hardware headaches! Bill Gates would be proud (or maybe horrified at what we've done to his code).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages