When Bill Gates started Microsoft, he pulled all-nighters and thought sleeping was 'lazy'—this book changed his mind

Business magnate and Microsoft co-founder Bill Gates poses in November 1985 in Bellevue, Washington.
Deborah Feingold | Getty Images

Bill Gates got a lot done in his 20s: After taking a leave of absence from Harvard, he formed a computer software company with his high school friend Paul Allen. That company became Microsoft, one of the most valuable publicly traded companies in the world.

He also sacrificed a lot of sleep in those early Microsoft days. "I routinely pulled all-nighters when we had to deliver a piece of software," the self-made billionaire writes on his blog. "Once or twice, I stayed up two nights in a row."

Gates sensed that he wasn't as sharp when he operated on little to no sleep, "but I was obsessed with my work, and I felt that sleeping a lot was lazy," he says.

Today, at 64, the billionaire philanthropist has a different perspective, partly thanks to Matthew Walker's book, "Why We Sleep." Walker, the director of UC Berkeley's Center for Human Sleep Science, dives into the overwhelming benefits of sleep, from improving brain function to strengthening our immune systems, and the consequences of not getting enough of it. Lack of sleep, he explains, can impair things like creativity, memory, mental health and even your life span.

Walker also offers tips on how to get a better night's rest: don't use LED light bulbs, limit alcohol and, if possible, set your room temperature to 65 degrees Fahrenheit.

After reading "Why We Sleep," which Gates includes on his 2019 holiday book list, "I realize that my all-nighters, combined with almost never getting eight hours of sleep, took a big toll," he writes.

I realize that my all-nighters, combined with almost never getting eight hours of sleep, took a big toll.
Bill Gates
Microsoft co-founder

He's not the only billionaire who now prioritizes sleep: Amazon's Jeff Bezos makes a point of getting eight hours a night. It "makes a big difference for me, and I try hard to make that a priority," he told Thrive Global in 2016. "For me, that's the needed amount to feel energized and excited."

It also helps prevent decision fatigue, which describes the way choices become harder and harder as a day goes on and your finite store of energy gets depleted. "Making a small number of key decisions well is more important than making a large number of decisions," said Bezos. "If you shortchange your sleep, you might get a couple of extra 'productive' hours, but that productivity might be an illusion."

Bezos and Gates are in good company: Facebook COO Sheryl Sandberg and media mogul Ariana Huffington also tout the importance of making sleep a priority.

Don't miss: The 5 books Bill Gates recommends you read this holiday season

Like this story? Subscribe to CNBC Make It on YouTube!

How Bill and Melinda Gates negotiated school drop-offs
How Bill and Melinda Gates negotiated school drop-offs