Working as an EP and writer on cultural staples including SeinfeldCurb Your Enthusiasm—and now, Silicon ValleyAlec Berg is something of a comedy legend. On his latest HBO series, in line with a career evolution stemming from Curb, Berg has taken on even more hats, as the director of a great number of episodes.

This season, the TV veteran has earned his 13th Emmy nomination for his writing of the Season 4 opener, “Success Failure,” and the controversial, abrupt exit of T.J. Miller at season’s end may signal a whole new world for Season 5, in the absence of the Rabelasian rabble-rouser.

Miller had some unkind words for Berg in the press, on which the showrunner declined to comment, saying only that any comment on the matter in the public forum would do neither he nor Miller any good.

Speaking with Deadline, Berg explains that the basic mechanics of this serialized comedy are wildly different from those of Seinfeld and Curb, making it “by far the hardest thing I’ve ever had to write.”

How long have you known the general shape of Silicon Valley’s fourth season?

We’ve gotten in this habit of dealing ourselves a hand and having to figure out how to play it the next season. We had set up this idea that the company that Richard had thought he was founding had crashed, but there was this new video chat that was kind of taking off. We started from there, and as we were discussing it, the question we kept asking ourselves was, “Is this what Richard would really be excited about? Would he feel like this is the ideal use of his algorithm?”

We decided it wasn’t, which led to an interesting question of, “What would he do about it?” Would he try and pivot the company back to something he thought was more ideal, or would there end up being this fight where he would have to leave his own company because he didn’t believe in it? That’s where we landed—Richard was going off to do this other thing.

HBO

This series occupies a unique space as a sort of serialized comedy. How have you found the right balance between humor and drama?

That’s the exhausting work of doing this show. This is by far the hardest thing I’ve ever had to write, particularly because of that serialized nature. It’s got to keep moving forward, and you can’t reset at all, partially because of the decision we made, early on, to try and be as technically accurate as we could.

A lot of things that we come up with are just technically wrong, and we’ll plead with our technical consultants: “Please, can you find a way to justify this happening?” Sometimes they just go, “No, there’s no way that would ever happen,” and we have to throw good stories away because they’re not accurate.

It’s this serialized show, which implies a journey somewhere. These guys are on this journey to see if they can make this company successful, and ultimately, you have to let them succeed enough that it’s validating that they’re onto something, and they’re not idiots. It’s our feeling that if they ever become the success they want to become, the show’s over. So how much do you let them succeed, to give the audience that kind of voyeuristic, “Oh, we want them to succeed, and we want to be a part of it?”

Every time we find them succeeding, we keep having this idea of, “Oh, well maybe just for the first couple of episodes of the season they’ll be a wild success.” We try and write those shows, and there’s nothing happening. There’s no conflict, there’s no strife, there’s no comedy from people who are just successful. It’s more interesting to see them struggle.

HBO

This sounds similar to the struggle TV writers face with romantic relationships between characters—once the central relationship is fulfilled, the show is over.

Yeah. There are certain shows, like Cheers—I think they handled the whole Sam and Diane thing very well. I was a huge fan of Moonlighting. There was this “Will they, won’t they” thing, and at a certain point, when that tension kind of withered, I’m not sure they knew quite what to do with the show.

Having worked on series like Seinfeld and Curb Your Enthusiasm, how are the mechanics of this show different?

It’s the serialized nature of it. On Seinfeld and Curb, there were arcs, but we would do a ton of standalone episodes. In one of the Curb seasons we did, Larry was organizing this Seinfeld reunion. We did 10 episodes that season, and I think four or five of them were organized around the Seinfeld reunion, but five of them were pure standalones. There were times when we were like, “Oh, show one and show two have some things that are similar in them, so what if we flipped shows two and three, so we air one, then three, then two, so that those shows are a little further apart?”

If you flipped two episodes of Silicon Valley, it literally makes no sense. This is the first thing I’ve done where the whole premise of the show is, “These guys are trying to accomplish something, and will they get there or not? Seinfeld and Curb were “a day in the life” shows. This is a “Will they or won’t they get where they are trying to get?” The whole organizing principle of the storytelling is a little different.

HBO

This season, you submitted Episode 1—”Success Failure”—for Emmys, an easy choice because it was the only episode you wrote. What was exciting to you about that piece of work?

To me, the big thing about that episode is that we’ve gotten to this point in the show now where Richard’s business model started off as a music copyright app, then pivoted to this file sharing thing, and that crashed. Then, they pivoted to video chat, and that crashed. It sort of felt to us like as a show, we’re out of pivots. Whatever Richard seizes on as the Holy Grail of the usage of his algorithm, we have to ride that horse for the rest of the season—probably for the rest of the series.

It felt like whatever he decided would be an ideal use for this algorithm was really important. We kind of thought, Whatever we land on, that’s what we’re doing for the rest of the series. Richard having this idea of decentralizing the internet, and connecting all the world’s mobile devices using some wireless protocol, eliminating the need for centralized servers, that seemed like a cool idea.

It’s interesting: We do this research trip every year at the beginning of the season. We’ve gone up to the Valley in San Francisco the last few years, and this year we went to Seattle just to mix it up a little bit. You get the sense of the macro trends, and what’s the thing that everybody’s talking about. This year, it’s starting to feel like there is this looming sense of, How much do these companies know about me, and how much am I allowed to withhold from them?

HBO

There’s this phrase that we kept hearing over and over: “If you’re not paying for the product, then the product is you.” Facebook is free. Google searches are free. But are they free? The amount of information you’re giving them in exchange for this social network is kind of gobsmacking. so this decentralized internet with no centralized nodes and nobody controlling these stockpiles of information, suddenly it’s becoming kind of something that is in the zeitgeist. “Wait a second. What do you mean Facebook knows how much money I make, where I went to junior high school, and what I bought at the grocery store last Thursday?” That’s crazy.

This decentralized internet flies right in the face of that. We got lucky and kind of guessed that this was an interesting thing before I think we really understood how interesting it was.

You’ve taken all of your characters in radically new directions this season. What were your intentions as far as the evolution we now see?

Some of them are amalgamations of real-world people. A lot of them arise just out of story need. Russ Hanneman is a character that had sort of cornered the company; they were being sued by Gavin Belson in this onerous lawsuit, and they needed money. We were writing that character before we landed on exactly who he was— we just kept referring to him as “bad money.” The story dictated that they needed to go to somebody to get money, that somebody would end up being a nightmare, and they would be on the hook to somebody. They were basically trapped in a cage with a bear.

HBO

That was a character that just came out of the need for some dynamic like that. Then we were like, “Okay, well who would the worst person in the world to take money from be?” We played with the idea of a Russian oligarch, or a Chinese billionaire, and for whatever reason, we were just having more fun with a guy like Russ Hanneman.

A lot of the characters come out of the exact same thing. You create the story need for a certain character, and it’s really rare that we’ll go, “Oh, we should put a guy like this on the show,” and then figure out a way to use them. It almost always comes from story—we need some force that acts on the company in this way. Who would that be, how do you make them entertaining, and what specifics can you give that character that makes them fun to write?

You strike an interesting balance on Silicon Valley as a showrunner, writer and director. How did you arrive at the dynamic that works best for you?

I’ve got a writing staff of eight to 10 people so I like to spread the writing credits around. Generally, I try and get everybody who’s a staff writer at least one episode, so that dictates how many I write. It’s just how many slots are left, frankly.In terms of directing, that’s the part that I’m the least experienced at, so in a weird way, the learning curve is steepest there.

It’s the part I actually enjoy the most, but my value to the show is higher as a writer, making the trains run in the writing process. I’d love to direct more of them, it’s just I’m locked in the writers room, making sure that the other directors we hire have something to direct. Season 2, Mike Judge and I did all of them. That damn near killed me.

HBO

It just wasn’t practicable, so we started going to a few other people to direct episodes. You talk to any showrunner and their one bone to pick with this whole process is everybody wishes they could just do it at a slightly slower pace.

With T.J. Miller’s abrupt depature from the series, how will Erlich Bachman’s absence affect future seasons?

Story-wise, he wasn’t really a central part of the company, so that part is not a big challenge. To be honest, we were having to try and find ways to bring his character into the company’s business. Losing that energy is going to be really hard—Erlich was a great character, and very much a part of the DNA and ecosystem of the show.

We just started writing, so we’re trying to figure that out now.

He was probably my favorite character to write for, in some ways, just because he was so much fun. We will miss that character for sure. Narratively he wasn’t at the center of anything; it’s really just a question of that character’s energy and bluster, and contrarianism, and the fact that they live in his house.

Do you find that you’ve written toward your actors’ strengths with this series?

Oh yeah, that’s the joy of serialized television, that you learn more over time about your characters, where they’re funny and where they’re strong. You learn the same thing about the actors.

In Season 8 or 9 of Seinfeld, Jason Alexander said, “I’ve never done a scene with Wayne Knight, just the two of us, before,” and it was like, “Oh wow, we’ve gone this long without this permutation of characters happening.”