REDWOOD CITY, Calif. — Silicon Valley, with its influence and economic clout soaring to all-time highs, is having its pop culture moment.

But the stream of movies, books, even a reality TV show spotlighting nerdy start-up culture have all been widely panned locally as cheap caricatures.

With Sunday's kickoff of Mike Judge's "Silicon Valley" comedy series on HBO, the geeks here say Hollywood finally gets them — even as it mocks them.

"It was like watching a bizarro version of your own reality," said Tesla Motors Chief Executive Elon Musk, after the Silicon Valley premiere Wednesday night at this city's historic Fox Theatre, where stars of the show walked the red carpet and the tech glitterati came out in force.

The show's producers say they went to great lengths to get the details big and small just right — even to the point of drafting a Stanford professor and his graduate student to brainstorm credible technology for fictional products on the show.

Thomas Middleditch, who plays Richard, the show's socially awkward programmer savant, was asked what he did to prepare to play a Silicon Valley geek. "All I did was just suffer about 15 years of relentless bullying," he said. "Pretty standard."

After the premiere, the bubbly crowd adjourned to an after party at a local watering hole, where people lined up at the "selfie" station. A photographer snapped a series of pictures in front of a green screen to create an animated GIF in front of a poster of the show.

"Nobody would tell me to my face if they didn't like it. This is a pretty passive-aggressive place," executive producer Alec Berg said. "But I don't think they were lying when they were laughing."

The current wave of Silicon Valley cinema began with the controversial take on the origins of Facebook in "The Social Network." Google got its turn in the klieg lights last year with "The

Internship." Ashton Kutcher tried his hand at playing Steve Jobs, and now Aaron Sorkin is crafting his own version of the Silicon Valley icon. Bravo's sensational portrayal of nerd culture in the 2012 reality series "Start-Ups: Silicon Valley" was laughed off the air.

"Until now, no one adequately embarrassed Silicon Valley on TV. All prior attempts either embarrassed themselves, or fell just short," Sam Biddle wrote on tech gossip blog Valleywag. "Silicon Valley" is the "graceful slap across the face" the industry deserves, he said.

With its veiled skewering of Silicon Valley power players, inside jokes and surprise cameos by colorful industry figures, "Silicon Valley" is basically "Entourage" for geeks.

And the two episodes shown Wednesday had the tech crowd laughing — sometimes very uncomfortably — at themselves.

In a quintessential Silicon Valley coming-of-age story, the main character Richard has created a search engine that lets musicians find out if their songs sound a bit too much like someone else's.

That idea is a dud, but the algorithm that powers the search engine sparks a bidding war between two

Along the way to building their own start-up, the guys — yes, they are all guys — debate which Steve (Jobs or Wozniak) was the genius behind Apple, take a page from Facebook and hire a graffiti artist to spray paint their corporate logo with obscene results, brainstorm boneheaded names for their company, rant about the Java programming language and name drop Grindr, Github and other tech companies.

Eventually Richard's start-up Pied Piper competes in TechCrunch Disrupt, an industry conference that pits start-ups against one another "American Idol" style.

Many of the real start-up CEOs who competed at Disrupt appear as themselves, steeling themselves to be grilled by real-life tech journalist Kara Swisher, who ad-libbed her lines.

The show so faithfully re-created Disrupt that in December, when TechCrunch founder Michael Arrington visited the set on a Culver City soundstage for his cameo, he said he felt like he was walking into the conference that he helped create.

The show was "dead on," he said.

Longtime Silicon Valley observer and Stanford consulting professor Paul Saffo said previous attempts to bottle the essence of Silicon Valley on the big screen "were cardboard cutouts of what a clueless outsider would think about this place.

"It's a great improvement that we're getting some smart people doing these shows. Everyone is carrying a piece of Silicon Valley in their pocket now. It's only a little bit natural that they'd be curious about how this place works."

If anyone in Hollywood knows how Silicon Valley works, it's Judge.

After graduating from UC San Diego as a physics major, he programmed electronic test systems for the F-18 fighter jet for a military subcontractor before moving with his girlfriend to Sunnyvale, Calif., in 1987. He eventually made his dystopian workplace experiences as a test engineer for a Silicon Valley start-up into the 1999 cult hit "Office Space."

To get up to speed on current-day Silicon Valley, Judge got a tour of Google's Mountain View, Calif., campus from a Google programmer, visited a start-up in the hipster, tech-heavy South of Market neighborhood of San Francisco and toured two start-up incubators in Los Angeles.

Judge relied heavily on Jonathan Dotan, a Web entrepreneur and investor who is an associate producer on the show, to give "Silicon Valley" geek cred.

Dotan put together a team of six programmers, a designer, a start-up lawyer and a chief technology officer to help Judge capture — and skewer — the tech industry he once toiled in.

Dotan went so far as to pitch the fictional company's technology and business plan to venture capitalists in Silicon Valley and Los Angeles.

"We definitely wanted to get it right for Silicon Valley," Judge said.

Stanford professor and compression expert Tsachy Weissman, with his 27-year-old graduate student Vinith Misra, consulted on the data compression algorithm that shrinks computer files of any kind — video, audio, images — to half their size, making them easier and faster to download and upload.

Judge even had Misra create mathematical formulas to set up what Judge says is the most complicated and sophisticated joke about the male anatomy ever told.

Only compression experts will notice that on Richard's bedroom wall, he has a signed photograph of the late computer scientist and data compression expert David Huffman and a pinup of Swedish model Lena Soderberg, whose 1972 Playboy centerfold picture became the standard test image for compression algorithms.

"The kind of detail they were looking for was a little shocking," Misra said.

Alec Berg, left, and Mike Judge introduce HBO's new "Silicon Valley" series at a screening at the historic Fox Theatre in Redwood City, Calif. The producers say they went to great lengths to get the details just right.