10 PRINT "HELLO"
20 GOTO 10
_

Intro to BASIC

Where personal computing began. Line numbers, GOTO, and the language that started it all.

1

The Story of BASIC

In 1964, two professors at Dartmouth College created a language that would change computing forever. Their goal was simple: let everyone, not just scientists, use a computer.

1964
John Kemeny and Thomas Kurtz create BASIC at Dartmouth College. The name stands for "Beginner's All-purpose Symbolic Instruction Code." For the first time, non-science students can write programs.
1975
Bill Gates and Paul Allen write Altair BASIC for the new Altair 8800 microcomputer. It becomes their first product and launches a little company called Microsoft.
1977-1985
Every major home computer ships with BASIC built in. Turn on the machine, and you are in BASIC. An entire generation learns to code this way.
Apple IIApplesoft BASIC
Commodore 64CBM BASIC 2.0
TRS-80Level II BASIC
ZX SpectrumSinclair BASIC
Fun Fact

The first BASIC program ran at 4:00 AM on May 1, 1964. Kemeny and Kurtz designed it so that students could use the Dartmouth time-sharing system from teletype terminals across campus.

2

Hello, World!

Your first BASIC program is just two things: a line number and a command. Type it, type RUN, and the computer does the rest.

10 PRINT "HELLO, WORLD!" RUN HELLO, WORLD! READY.

Line Numbers

Every line of a BASIC program starts with a number. 10, 20, 30... The computer runs them in order. Numbering by 10s leaves room to insert lines later.

PRINT

The most important command. PRINT sends text to the screen. Put your message in quotes and BASIC displays it.

RUN

Type RUN and hit Enter. BASIC executes your program from the lowest line number to the highest. That is it.

READY.

After your program finishes, BASIC prints READY. to tell you it is waiting for your next command. This is the REPL (Read, Evaluate, Print, Loop).

Two Modes

BASIC has two modes. "Immediate mode" executes commands right away (like typing PRINT 2+2 without a line number). "Program mode" stores numbered lines and runs them when you type RUN.

3

Variables and Math

BASIC keeps things simple. No type declarations, no setup. Just give a variable a name and a value.

10 LET X = 10 20 LET Y = 3 30 PRINT X + Y 40 PRINT X * Y 50 PRINT X ^ 2 RUN 13 30 100
OperatorMeaningExample
+Addition10 + 3 = 13
-Subtraction10 - 3 = 7
*Multiplication10 * 3 = 30
/Division10 / 3 = 3.333...
^Exponent (power)10 ^ 2 = 100
REM String variables end with $ 10 LET NAME$ = "WORLD" 20 PRINT "HELLO, "; NAME$ RUN HELLO, WORLD

LET Is Optional

Most versions of BASIC let you skip the LET keyword. X = 10 works the same as LET X = 10.

String Variables

Text variables end with a dollar sign: NAME$, CITY$. Number variables are plain: X, SCORE.

Semicolons Join Output

Use ; in PRINT to join values on the same line without a space between them.

4

Control Flow: GOTO and FOR/NEXT

This is where BASIC gets interesting. GOTO jumps to any line. IF/THEN makes decisions. FOR/NEXT repeats code. And GOSUB creates reusable subroutines.

REM An infinite loop! 10 PRINT "HELLO!" 20 GOTO 10 RUN HELLO! HELLO! HELLO! HELLO!...
REM IF/THEN conditional 10 LET AGE = 15 20 IF AGE >= 13 THEN PRINT "TEENAGER" 30 IF AGE < 13 THEN PRINT "KID" RUN TEENAGER
REM FOR/NEXT loop 10 FOR I = 1 TO 5 20 PRINT "COUNT: "; I 30 NEXT I RUN COUNT: 1 COUNT: 2 COUNT: 3 COUNT: 4 COUNT: 5
REM GOSUB/RETURN subroutine 10 PRINT "MAIN PROGRAM" 20 GOSUB 100 30 PRINT "BACK IN MAIN" 40 END 100 PRINT "IN SUBROUTINE" 110 RETURN RUN MAIN PROGRAM IN SUBROUTINE BACK IN MAIN

GOTO

Jumps execution to any line number. Simple, powerful, and the source of a famous debate in computer science.

IF/THEN

Checks a condition. If true, runs the command after THEN. Some versions support IF/THEN/ELSE on one line.

FOR/NEXT

Repeats code a set number of times. FOR I = 1 TO 10 counts from 1 to 10. NEXT I marks the end of the loop.

GOSUB/RETURN

Like a function call. GOSUB 100 jumps to line 100, then RETURN jumps back to where you left off.

5

What Makes BASIC Special

BASIC was not the most powerful language, or the fastest, or the most elegant. It was something more important: the most accessible. It democratized computing.

Anyone Could Learn It

Commands read like English: PRINT, INPUT, LET, IF, THEN, GOTO. No curly braces, no semicolons, no complex syntax. Just plain instructions.

Line Numbers Were Clever

Numbering by 10 (10, 20, 30...) meant you could always insert code. Need something between 10 and 20? Use 15. This made editing programs possible without a text editor.

GOTO: Loved and Feared

In 1968, Edsger Dijkstra wrote "Go To Statement Considered Harmful," arguing GOTO creates unreadable "spaghetti code." Modern languages avoid it, but GOTO taught millions how computers think step by step.

It Shipped Everywhere

When you turned on an Apple II, Commodore 64, or TRS-80, BASIC was the first thing you saw. No installation, no downloads. Type and go. Kids learned to code before they knew what programming was.

REM A complete program: number guessing game 10 LET SECRET = INT(RND(1) * 10) + 1 20 PRINT "GUESS A NUMBER (1-10)" 30 INPUT GUESS 40 IF GUESS = SECRET THEN GOTO 80 50 IF GUESS < SECRET THEN PRINT "TOO LOW!" 60 IF GUESS > SECRET THEN PRINT "TOO HIGH!" 70 GOTO 30 80 PRINT "YOU GOT IT!"
Fun Fact

Many famous programmers started with BASIC, including Linus Torvalds (Linux), John Carmack (Doom), and Tim Berners-Lee (the World Wide Web). Understanding BASIC means understanding the roots of modern computing.

6

Try It Yourself

The BASIC interpreter is available in our terminal. Install it, start it up, and write your own BASIC program.

Getting Started

Open the Terminal and follow these steps:

  • Install BASIC: apt install basic
  • Start the interpreter: basic
  • Type a program with line numbers
  • Type LIST to see your program
  • Type RUN to execute it
  • Type quit to exit BASIC
REM Try typing this program: 10 PRINT "COUNTING TO 5" 20 FOR I = 1 TO 5 30 PRINT I; " SQUARED = "; I * I 40 NEXT I 50 PRINT "DONE!" LIST REM Shows your entire program RUN COUNTING TO 5 1 SQUARED = 1 2 SQUARED = 4 3 SQUARED = 9 4 SQUARED = 16 5 SQUARED = 25 DONE!

LIST

Shows all the lines in your program, in order. Useful for checking what you have typed so far.

Editing Lines

To change a line, just retype it with the same number. To delete a line, type just the number and press Enter.

NEW

Clears the current program so you can start fresh. Your old program is gone, so make sure you are ready.

Keep Exploring

Once you are comfortable, try adding INPUT to ask the user for values, or use GOTO to create a loop. The best way to learn BASIC is the same way millions learned it in the 1980s: just start typing.

BASIC Programmer!

You have explored the language that launched personal computing. From Dartmouth in 1964 to every home computer of the 1980s, BASIC gave millions their first taste of programming.

0
Sections Explored
0
Time Exploring

Birthplace of Personal Computing

BASIC was created in 1964 at Dartmouth College so that anyone, not just scientists, could use a computer. It shipped on every home computer of the 1980s.

Line Numbers and GOTO

Programs were organized by numbered lines. GOTO let you jump anywhere. You could insert new code between existing lines (15 goes between 10 and 20).

Simplicity by Design

BASIC used plain English commands like PRINT, INPUT, LET, and IF/THEN. No complicated syntax or declarations required.

Historical Importance

Bill Gates and Paul Allen wrote Altair BASIC in 1975, launching Microsoft. An entire generation of programmers got their start in BASIC.

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction