Intro to BASIC
Where personal computing began. Line numbers, GOTO, and the language that started it all.
Where personal computing began. Line numbers, GOTO, and the language that started it all.
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.
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.
Your first BASIC program is just two things: a line number and a command. Type it, type RUN, and the computer does the rest.
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.
The most important command. PRINT sends text to the screen. Put your message in quotes and BASIC displays it.
Type RUN and hit Enter. BASIC executes your program from the lowest line number to the highest. That is it.
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).
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.
BASIC keeps things simple. No type declarations, no setup. Just give a variable a name and a value.
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 10 + 3 = 13 |
| - | Subtraction | 10 - 3 = 7 |
| * | Multiplication | 10 * 3 = 30 |
| / | Division | 10 / 3 = 3.333... |
| ^ | Exponent (power) | 10 ^ 2 = 100 |
Most versions of BASIC let you skip the LET keyword. X = 10 works the same as LET X = 10.
Text variables end with a dollar sign: NAME$, CITY$. Number variables are plain: X, SCORE.
Use ; in PRINT to join values on the same line without a space between them.
This is where BASIC gets interesting. GOTO jumps to any line. IF/THEN makes decisions. FOR/NEXT repeats code. And GOSUB creates reusable subroutines.
Jumps execution to any line number. Simple, powerful, and the source of a famous debate in computer science.
Checks a condition. If true, runs the command after THEN. Some versions support IF/THEN/ELSE on one line.
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.
Like a function call. GOSUB 100 jumps to line 100, then RETURN jumps back to where you left off.
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.
Commands read like English: PRINT, INPUT, LET, IF, THEN, GOTO. No curly braces, no semicolons, no complex syntax. Just plain instructions.
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.
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.
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.
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.
The BASIC interpreter is available in our terminal. Install it, start it up, and write your own BASIC program.
Open the Terminal and follow these steps:
apt install basicbasicLIST to see your programRUN to execute itquit to exit BASICShows all the lines in your program, in order. Useful for checking what you have typed so far.
To change a line, just retype it with the same number. To delete a line, type just the number and press Enter.
Clears the current program so you can start fresh. Your old program is gone, so make sure you are ready.
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.
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.
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.
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).
BASIC used plain English commands like PRINT, INPUT, LET, and IF/THEN. No complicated syntax or declarations required.
Bill Gates and Paul Allen wrote Altair BASIC in 1975, launching Microsoft. An entire generation of programmers got their start in BASIC.
Put your new knowledge into practice!