STEM

The “coolest code” Bill Gates ever wrote

As part of celebration of Microsoft’s 50th anniversary on April 4th, 2025, Bill Gates has shared the original source code for Altair BASIC. He described Altair BASIC as “the coolest code I’ve ever written”. Altair BASIC was developed in 1975 by Bill Gates and Paul Allen for the Altair 8800 microcomputer. This was Microsoft’s first-ever software product, and it marked the beginning of the company.

Altair 8800 computer

This code was written for the Altair 8800, one of the earliest personal computers, and served as an interpreter allowing users to write and execute BASIC programs on the Altair. Altair BASIC made it possible for people to interact with the computer using a simple programming language, rather than dealing directly with machine code. It’s an early version of the BASIC programming language, designed to run only on the Altair 8800 computer. It translated BASIC commands into machine code that the Altair can understand and execute.

Bill Gates’ code was in assembly language, it’s very low-level compared to modern programming languages. The code manages memory, optimizes execution speed, and handles arithmetic and logical operations efficiently which was critical considering early computers had very limited resources. In the code, we the following comments are noted:
BILL GATES WROTE THE RUNTIME STUFF.
PAUL ALLEN WROTE THE NON-RUNTIME STUFF.
MONTE DAVIDOFF WROTE THE MATH PACKAGE.

Bill Gates and Paul Allen – 1975

The code performed these key functions:

Process the user’s input, identifying keywords, variables, and syntax.
Organize the instructions in a way the system can understand.
Translate commands into the Altair 8800’s machine language and runs them.

This was a giant step toward making computers more accessible to a wider audience and played a key role in launching Microsoft as a software company.

The software ran on an Intel 8080 processor. Since personal computers weren’t common at the time, many users actually had to build their own Altair 8800 from a kit. Users needed the Altair 8800 computer to run Altair BASIC. They had to load Altair BASIC onto the computer using paper tape or cassette storage (there were no hard drives or USB back then). Then users would type BASIC commands into a teletype or terminal, and this interpreter would process and execute them. It gave everyday people a way to write programs without needing to code in machine language. It helped spark the early personal computing revolution — eventually leading to modern programming tools.

Some examples of code that users could write Altair BASIC are shown below

Hello World program:
To print "HELLO, WORLD!" to the screen:
10 PRINT "HELLO, WORLD!"
20 END

Number comparison (to determine which is greater):
10 INPUT "ENTER FIRST NUMBER: "; A
20 INPUT "ENTER SECOND NUMBER: "; B
30 IF A > B THEN PRINT "FIRST NUMBER IS GREATER"
40 IF A < B THEN PRINT "SECOND NUMBER IS GREATER"
50 IF A = B THEN PRINT "NUMBERS ARE EQUAL"
60 END

To do looping: print numbers from 1 to 10:
10 FOR I = 1 TO 10
20 PRINT "COUNT: "; I
30 NEXT I
40 END

Here’s how an Altair BASIC program could take a user’s birthday, calculate their age, and determine their zodiac sign:

10 PRINT "ENTER YOUR BIRTH YEAR (YYYY): "
20 INPUT Y
30 PRINT "ENTER YOUR BIRTH MONTH (MM): "
40 INPUT M
50 PRINT "ENTER YOUR BIRTH DAY (DD): "
60 INPUT D
70 LET CURRENT_YEAR = 2025
80 LET AGE = CURRENT_YEAR - Y
90 PRINT "YOU ARE "; AGE; " YEARS OLD."

100 REM DETERMINE ZODIAC SIGN
110 IF (M=3 AND D>=21) OR (M=4 AND D<=19) THEN PRINT "YOUR ZODIAC SIGN IS ARIES"

120 IF (M=4 AND D>=20) OR (M=5 AND D<=20) THEN PRINT "YOUR ZODIAC SIGN IS TAURUS"
130 IF (M=5 AND D>=21) OR (M=6 AND D<=20) THEN PRINT "YOUR ZODIAC SIGN IS GEMINI"
140 IF (M=6 AND D>=21) OR (M=7 AND D<=22) THEN PRINT "YOUR ZODIAC SIGN IS CANCER"
150 IF (M=7 AND D>=23) OR (M=8 AND D<=22) THEN PRINT "YOUR ZODIAC SIGN IS LEO"
160 IF (M=8 AND D>=23) OR (M=9 AND D<=22) THEN PRINT "YOUR ZODIAC SIGN IS VIRGO"
170 IF (M=9 AND D>=23) OR (M=10 AND D<=22) THEN PRINT "YOUR ZODIAC SIGN IS LIBRA"
180 IF (M=10 AND D>=23) OR (M=11 AND D<=21) THEN PRINT "YOUR ZODIAC SIGN IS SCORPIO"
190 IF (M=11 AND D>=22) OR (M=12 AND D<=21) THEN PRINT "YOUR ZODIAC SIGN IS SAGITTARIUS"
200 IF (M=12 AND D>=22) OR (M=1 AND D<=19) THEN PRINT "YOUR ZODIAC SIGN IS CAPRICORN"
210 IF (M=1 AND D>=20) OR (M=2 AND D<=18) THEN PRINT "YOUR ZODIAC SIGN IS AQUARIUS"
220 IF (M=2 AND D>=19) OR (M=3 AND D<=20) THEN PRINT "YOUR ZODIAC SIGN IS PISCES"
230 END

These are obviously very simple examples of what people could do with Altair BASIC; in reality BASIC was used for much more complex programs, including games, calculations, and even early business applications. So, you may be wondering: Can we run this code as-is on our Windows PC?

Since Altair BASIC was designed for the Altair 8800, we can’t run it directly on a modern PC. However, we can use an Altair Emulator that simulate the Altair 8800 on modern systems. For example, Altair32 Emulator lets you experience Altair BASIC as if you were in 1975. Or, we can rewrite code in QBASIC, FreeBASIC, or Microsoft Small Basic, which work on modern computers. Some websites host interactive BASIC interpreters where we can input and run vintage BASIC code — here’s one: MITS Altair web-based emulator

To see the source code for Altair BASIC interpreter, click here (PDF format).

Back To Top