How Mark Zuckerberg Learned to Code

Mark Zuckerberg, Harvard 2005

Millions of people know the story of Facebook’s creation. The humble beginnings of the billion-dollar company even became a major motion picture in the 2010 Best Picture nominated film The Social Network. But few know how Mark Zuckerberg learned to code.

Facebook started in a Harvard dorm room back in 2004. Originally called, Zuckerberg bragged “I do stuff like this all the time,” to The Harvard Crimsonduring a June 2004 interview. “The facebook literally took me a week to make.”

During that week, in January 2004, Zuckerberg locked himself into his dorm room in Harvard’s Kirkland Hall. He ignored his friends and barely ate while he crafted code for his new social media site. And in one week, the self-taught programmer created a website that would eventually attract more than 2 billion users.

“I didn’t have to have a lot of money,” Zuckerberg told Charlie Rose in a 2011 interview. “I literally coded Facebook in my dorm room and launched it from my dorm room. I rented a server for $85 a month, and I funded it by putting an ad on the side.”

But Facebook wasn’t the future entrepreneur’s first attempt at programming—not by a long shot.

Mark Zuckerberg learned to code not long after he received his first computer as a sixth grader. Zuckerberg was instantly interested in coding, eventually turning to C++ for Dummies to teach himself programming.

In 2013, Zuckerberg explained his motivation. “Learning how to program didn’t start off with wanting to learn all of computer science or trying to master this discipline or anything like that,” Zuckerberg explained. “It started off because I wanted to do this one simple thing—I wanted to make something that was fun for myself and my sisters.”

His first program, Zuckerberg relates, was a modified version of the board game Risk. “It was centered around the ancient Roman Empire,” Zuckerberg said in a 2004 interview. “You played against Julius Caesar. He was good, and I was never able to win.” Designing a game that even its creator couldn’t beat was an exciting challenge for Zuckerberg.

From the start, Mark Zuckerberg learned to code to connect people. As his sister, Randi Zuckerberg, described in an interview with People Magazine, Mark created an intranet for the family home at only 11 years old. “Anyone could log into any computer around the house and send a message.”

Randi remembers realizing that her younger brother was thinking “10 levels ahead.” For Zuckerberg, programming was a powerful tool. “It was the first example of when he started building things—and he never stopped.”

By the time Zuckerberg attended Philips Exeter Academy, taking computer science classes, he already had several years of programming experience under his belt. And Facebook wasn’t even the first program Zuckerberg nearly sold for millions.

At Exeter, Zuckerberg tried his hand at designing a music program, which he called Synapse. “The playlist ran out on my computer, and I thought, ‘You know, there’s really no reason why my computer shouldn’t just know what I want to learn next,’” he related. “So that’s what we made.”

Zuckerberg designed Synapse with his Exeter classmate Adam D’Angelo, who would later become the chief technology officer at Facebook.

“It learned your listening patterns by figuring out how much you like each song at a given point and time, and which songs you tend to listen to around each other,” Zuckerberg explained.

Synapse instantly attracted attention from major corporations.

Microsoft, AOL, and WinAmp, a major MP3 player, all wanted to buy the program. In 2004, Zuckerberg recalled, “Some companies offered us right off the bat up to one million, and then we got another offer that was like two million.”

But Zuckerberg walked away from the offers. “I don’t really like putting a price-tag on the stuff I do. That’s just like not the point,” he said.

Once at Harvard, Zuckerberg graduated to more complicated programming challenges. He designed a program called CourseMatch. It let students see if their friends were enrolled in a class before they registered. In a smaller way, CourseMatch echoed the goal of Facebook: connecting people with their friends to strengthen their social network.

Zuckerberg’s next project landed him in trouble with Harvard. FaceMash paired up pictures of two Harvard students, letting users rate their looks. The program then ranked the best looking students at the school. When Zuckerberg launched the site, it quickly went viral. Harvard stepped in, cutting off Zuckerberg’s internet access and taking the site down after only four hours.

FaceMash flamed out, in part because of privacy concerns. As reported inThe Harvard Crimson, Zuckerberg hacked into Harvard sites to collect photos of students. Zuckerberg’s defense? His primary interest was the programming and algorithms. He publicly apologized to the Harvard community.

Just weeks later, Zuckerberg would launch Facebook.

In 2004, Zuckerberg described his philosophy. “I’m just like a little kid. I get bored easily and computers excite me. Those are the two driving factors here.”

What can we learn from Mark Zuckerberg?

1. It’s all about freedom. For Mark Zuckerberg, learning to code gave him the freedom to control his own life. As a 20-year-old Harvard student, just before dropping out, Zuckerberg explained what he wanted from life: “My goal is to not have a job. Making cool things is just something I love doing, and not having someone tell me what to do or a timeframe in which to do it is the luxury I am looking for in my life.”

2. Think small. Mark Zuckerberg didn’t set out to create Facebook. Mark Zuckerberg learned to code to because he loved to build cool things. “I don’t really know what the next big thing is because I don’t spend my time making big things,” Zuckerberg says. “I spend time making small things and then when the time comes I put them together.”

What’s a small step you’ve taken that lead to big results? Let us know in the comments below!

Want to learn to program? Register for my free Self-Taught Coder Masterclass where I cover how I went from a novice to a software engineer at eBay in less than one year.

Join the Conversation

  1. gravatar
  2. gravatar
  3. gravatar
  4. gravatar


  1. Never watched the movie but this is good info, thanks

    1. you should watch it. It’s very interesting how and what he did before and after he started Facebook.

  2. I wish I would’ve come across coding long before college. I don’t care what it takes, I’m going to get into the video game industry one way or another; even after everything I’ve learned in school, I am determined to improve my skills as much as I can every day. I’m definitely lucky to be alive, I want it to mean something, and I know all those years I spent gaming as a child weren’t a complete waste; they only fueled my interest to get into this industry more and more. Of course, I’d like to pursue other things as well since gaming too much isn’t good, but I know this industry is where I belong.

Leave a comment

Your email address will not be published. Required fields are marked *