(Courtesy of Penguin/Random House)

Margaret O’Mara is a professor of history at the University of Washington. Her new book, “The Code: Silicon Valley and the Remaking of America,” was just published by Penguin Press. I interviewed her about it.

Ross Perot died recently. Few Americans realize he played a key role in the U.S. software industry. Why was he an important figure before he ventured into politics?

Perot embodies the tight interconnection between tech and politics that I trace in this book. He started two enormously successful software-and-services companies and remained a tech-industry player for decades, intersecting with the Silicon Valley story I tell in this book again and again.

In the early ’80s, he tried to buy Microsoft. (Bill Gates took the idea seriously enough that he got a haircut before his meeting with Perot, but he still said no.) In 1986, he bailed out Steve Jobs’s NeXT, which the Apple wunderkind had started with his own money after his notorious firing from the company he started. The partnership didn’t last, partly because Perot kept on pestering Jobs to take on defense contracts to build up NeXT’s book of business. He also successfully lobbied to make Texas the location of federally-subsidized microelectronics and semiconductor research centers.

That all points to an important connection between Perot’s tech and political life, understandably downplayed in his 90s-era campaign bio. Despite running for president as a folksy, self-made businessman, the thing that really made Perot’s fortune was the 1965 passage of Medicare and Medicaid. Perot’s EDS won some of the programs’ biggest data-processing contracts, making him a billionaire -- at a time that the U.S. had very few of them.

Another thing that most people don’t realize is how the federal government played a key role in building Silicon Valley. How has the relationship between Washington and Silicon Valley evolved over time?

The Silicon Valley mythos of freewheeling, entrepreneurial cowboys allows little room for big-government involvement, and antipathy toward bureaucracies and politics-as-usual has been a hallmark of tech culture for a while. But the hidden history I trace in this book shows that the U.S. government has been present all along. Silicon Valley’s entrepreneurial flywheel started spinning during the Cold War, during which the feds embarked on an unprecedented program of subsidy of scientific research and development. It wasn’t just a matter of government spending lots of money: It was how it spent it that mattered. Money was decentralized, competitive, flowing to private contractors and to universities — including Stanford, whose leaders upended its curriculum to build what they called “steeples of excellence” in specialized engineering programs that were exactly what the Cold War-era electronics industry wanted and needed.

Another shot in the arm was the space race. Silicon semiconductors and integrated circuits of the type invented and developed in the Valley were exactly what NASA needed — small, light, powerful. Placing big orders as the Apollo program ramped up, NASA became the most important early customer for Valley start-ups, and its high demand drove down prices to a point where these microchips could become commercially viable.

The government-tech relationship changed over the span of the Valley’s lifetime, but it never, ever disappeared. The Pentagon’s research arm, DARPA, not only sponsored creation of the Internet but also became, and remains, the major source of funding for top computer science programs like Stanford’s. There were tax breaks and research projects and regulatory fixes, fiercely lobbied for by tech entrepreneurs and investors from the 1970s forward, that accelerated the rate of investment and wealth creation in the Valley.

Today, government contracts — particularly for defense and national security — continue to be a major source of revenue for large technology companies. And government makes a difference not only when it governs tech behavior but when it consciously chooses not to: the lightly regulated Internet, itself the result of close political collaboration between lawmakers and tech titans during the 1990s, has been the enabler of social media companies’ growth and dominance, for good and for ill.

A lot of Silicon Valley’s success was down to technological brilliance. A lot was down to clever marketing. How did marketing shape the digital economy that Silicon Valley built?

Storytelling is central. The Valley companies that broke ahead of the pack had people with the ability to tell a good story about tech’s transformative power. There were many “microcomputing” start-ups in the Valley in the late 1970s, for example, but only Apple had technical wizard Steve Wozniak paired with techno-evangelist Steve Jobs, who could explain computing in a way few others could. A personal computer is like a bicycle for the mind, he would explain again and again. Buy an Apple, and you’d have a tool for creativity, for education, for personal liberation. The apogee of this countercultural pitch was of course the famous 1984 Super Bowl ad that introduced the Macintosh computer.

Entrepreneurs like Jobs (and later Bill Gates, Jeff Bezos and other boldfaced names) delivered the techno-philosophical sound bites that shaped the story, as well as boosting public fascination with the leaders themselves. Yet this process, like all aspects of the Valley’s tech success, also was the result of lesser-known thousands, men and women who worked in marketing and advertising, venture capital and more. Their story is Silicon Valley’s story — and its magic — too.

Your book states that a homogenous culture was “both Silicon Valley’s great advantage and its greatest weakness.” What do you mean by that?

The early Valley was something of an entrepreneurial Galapagos: evolving in physical isolation from the capitals of government and finance, developing distinctive species of business enterprise as a result. This wasn’t just the companies themselves; it was law, venture capital, investment banks, marketing firms, even real estate developers. All evolved as service industries focused on developing and supporting young, untested entrepreneurs with good technical skills and good ideas — but little sense of how to actually run a business.

From the 1950s well into the 1980s, this small and tightly networked place had few distractions or amusements. The restaurants all stopped serving by 8:30, there were only a couple of good bars, and a good deal of social life happened on the sidelines of Little League games. People knew one another, and these personal connections informed choices VCs made about investments — putting money in a “grade-A man,” as legendary investor Arthur Rock put it — as well as helping executives build out teams comprised of people they knew from other places, or who were referred by existing employees. This continues to this day: Employee referrals are an important source for hiring at places like Google and Salesforce.

This helps explain the Valley’s entrepreneurial resilience. It also helps explain its struggles with diversity. When you hire who you know — or people who have the same look and résumé as others who have previously succeeded — then it becomes more difficult to find and identify talent outside that charmed circle. Tech venture investment is by definition a risky business — for every investment that hits, another nine fail — and the ingrained habits of the Silicon Valley Galapagos have made its kingmakers reluctant to make bets on people who can’t as readily be identified as “grade-A men.”

What was life like in the Valley for those who didn’t fit readily into this culture (such as women and people of color)?

Life in many of the tech companies I profile often required a thick skin and a willingness to work extraordinarily hard, usually putting work before a healthy social or family life. The semiconductor industry that emerged in the Valley in the 1960s was notorious for its hard-charging atmosphere, a nearly entirely male environment that was a combination of Navy barracks and locker room. The 1970s superstar Atari was famous for its shambolic vibe, with plenty of pot-smoking and hot-tubbing.

The technical women and people of color who were part of the tech world — and they were there all along, albeit in much smaller numbers — had to find ways to fit into this culture, rather that it adjusting to fit them. I was struck by the toughness and pragmatism of so many of the women I interviewed for this book; they cared passionately about the technology, and they were willing to put up with a lot in order to build careers in the field.

It’s only in the last few years that Silicon Valley has had an open, extensive conversation about tech’s diversity problems. Perhaps not coincidentally, this also is the first moment that we are starting to reach critical mass of female investors and mentors. It makes me hopeful about what might come next.

Don’t miss anything! Sign up to get TMC’s smart analysis in your inbox, three days a week.