Book excerpt: “Source Code: My Beginnings” by Bill Gates
We may receive an affiliate commission from anything you buy from this article.
In Bill Gates’ new autobiography, “Source Code: My Beginnings” (published February 4 by Knopf), the computer pioneer and philanthropist writes of his formative years, and the experiences that led him to the then-burgeoning world of computers.
Read an excerpt below about how, in eighth grade, he discovered BASIC, which introduced him to the elegance and exacting demands of computer code; and don’t miss Lee Cowan’s interview with Bill Gates on “CBS Sunday Morning” February 2!
“Source Code: My Beginnings” by Bill Gates
Prefer to listen? Audible has a 30-day free trial available right now.
All these years later it still amazes me how so many disparate things had to come together for me to use a computer in 1968. Beyond the leap of faith made by those teachers and parents who got us the terminal, and beyond the stroke of luck that people were now sharing computers over phone lines, completing this miracle was the decision by two Dartmouth professors to create the BASIC programming language. Just four years old at the time, the “Beginners’ All-purpose Symbolic Instruction Code” was made to help students in nontechnical fields get started with computer programming. One of its attributes was that it used commands, such as GOTO, IF, THEN, and RUN, that made sense to humans. BASIC is what hooked me and made me want to come back.
On the wall next to the terminal, a teacher had tacked up a half sheet of paper with the most rudimentary directions to get started, including how to sign in and which keys to press when something went wrong. It also warned ominously that typing “‘PRINT’ WITHOUT A STATEMENT NUMBER MAY CAUSE LOSS OF CONTROL.”
The page included a sample program written in BASIC telling the computer how to add two numbers.
Ready . . .
10 INPUT X,Y
20 LET A=X+Y
30 PRINT A
40 END
That was probably the first computer program I ever typed in. The elegance of the four lines of code appealed to my sense of order. Its instantaneous answer was like a jolt of electricity. From there, I wrote the first computer program of my own—a game of tic-tac-toe. Getting it to work forced me to think through for the first time the most basic elements of the game’s rules. Immediately, I learned that the computer was a dumb machine that I had to tell every single step it should take, under every single circumstance that could occur. When I wrote imprecise code, the computer couldn’t infer or guess what I meant. I made a lot of errors trying to figure that out. When I finally got it right, the sense of accomplishment far outstripped the result. A game of tic-tac-toe is so simple, even kids learn it quickly. But it felt like a triumph to get a machine to do it.
I loved how the computer forced me to think. It was completely unforgiving in the face of mental sloppiness. It demanded that I be logically consistent and pay attention to details. One misplaced comma or semicolon and the thing wouldn’t work.
It reminded me of solving mathematical proofs. Programming doesn’t require math skills (beyond the basics), but it does demand the same kind of rigorous, logical approach to problem-solving, breaking problems down into smaller, more manageable parts. And like solving a problem in algebra, there are different ways to write programs that work—some more elegant and efficient than others—but infinite ways to make a program that fails. And mine failed all the time. Only after persevering, forcing myself to think smart, could I coax a program to run flawlessly.
Another early program I wrote was a lunar lander game. The problem: safely touch down a lunar lander on the moon without crashing and before you run out of fuel. From that I had to break the problem down into steps. I had to solve how the game player moved the lander left and right, up and down, how much fuel it had, how fast it burned. I also had to describe what it looked like and how to display the ship in dashes and asterisks on the screen.
Not long after Lakeside installed the terminal, Mr. Stocklin wrote a program that contained an infinite loop, meaning it ran continuously before someone eventually stopped it—but not before it burned through over a hundred dollars of our precious rummage-sale budget. I’m not sure he showed his face again in that room. It was a lesson to all of us.
To avoid racking up charges, I’d write out as much of my program as I could with pen and paper before elbowing into my place at the machine. With the machine offline to avoid time charges, I’d type it in and the program would print on a roll of inch-wide paper tape. That was step one. Then I’d dial the phone—the rotary dial on the side of the terminal—and wait for the buzz of the modem to confirm that I’d connected. I’d then feed my tape in, and chug-chug-chug, the program would input at a blistering ten characters per second. Finally, I’d type “RUN.” Typically there was a gaggle of other kids waiting for the computer, so if my program didn’t work, I’d have to log off and find a spot to sort through where I went wrong, then wait my turn to get back on the teletype.
This feedback loop was addictive. The feeling of getting better and better was a rush. Writing programs flowed from a combination of skills that came easy to me: logical thinking and an ability to focus intensely for long periods. Programming also stoked the persistent need I had to prove myself.
The atmosphere of that computer room was a (mostly) healthy mix of cooperation and competition. We were a mosh pit of teenage boys all trying to outdo one another. A gap of only two or three years isn’t much in the grand scheme of things but feels like a lot when you’re thirteen, small for your age, with some indeterminate time until your growth spurt. Kent and I were among the youngest kids in that group. The assumed superiority of some of the older kids bothered us.
I was an eighth-grader confident in my brain power and convinced that my intensity meant I could do anything the older guys could do—if not better, then at least faster. I was determined to not let anyone get anything on me. Kent also hated being put-upon by someone else. Maybe even more than me.
A sophomore named Paul Allen picked this up immediately, and he exploited it beautifully. “Bill, you think you’re so smart, you figure this thing out.” Those are some of the first words said to me by the person who I would go on to cofound Microsoft with years later.
Excerpted from “Source Code: My Beginnings” by Bill Gates. Copyright © 2025 by Bill Gates. Excerpted by permission of Alfred A. Knopf, a division of Penguin Random House LLC. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Get the book here:
“Source Code: My Beginnings” by Bill Gates
Buy locally from Bookshop.org
For more info: