For the last couple of years, San Francisco has been erupting with periodic protests aimed, rather imprecisely, at a nexus of grievances related to gentrification, affordable housing, transportation, the tech industry, newcomers to the city, its changing skyline and Silicon Valley to the south. The city is screaming, although at what its protestors seem a little confused.

“In my view, the whole debate here misses the point,” says Enrico Moretti, an economist at the nearby University of California at Berkeley. “People are marching against Google buses when they should be marching for more housing permits.”

At the root of San Francisco’s tension is a mismatch of supply and demand: Affluent workers have been flocking to the area for its tech jobs, but as the number of jobs in the region has grown, the number of housing units to accommodate people taking them hasn’t remotely kept pace. As a result, rents are going up. Low-income residents are pushed out. Landlords who see more lucrative opportunity in condo conversions have ramped up evictions.

“Once I started seeing what was going on in the San Francisco public debate, I got appalled by the lack of understanding of basic economics among the general public, the protesters,” Moretti says. “And it’s even more problematic among policymakers.”

The culprit here isn’t really the tech industry. It’s much-harder-to-protest land-use policy. And from Moretti’s point of view, the rest of us should care about how San Francisco and big cities like it restrict new housing because the economic repercussions of such local decisions stretch nationwide.

Here’s the first point, for locals: New housing supply benefits the entire city, even if that new supply takes the form of luxury condos. Tenant activists have regularly objected to new luxury developments as just another sign of gentrification. But even if that housing is intended for high-income tech workers, it will take some pressure off the existing units that those tech workers have occupied at the expense of middle- and lower-income residents. In effect, this means that affordable housing advocates who want to block new high-end developments are simply making the city more expensive.

Here is Moretti’s broader point, from some research he has been conducting with Chang-Tai Hsieh at the University of Chicago (h/t Tim Lee): By preventing more workers who would like to live in the city from moving in, San Francisco — and this also goes for New York, San Jose, Boston, Seattle and Washington, D.C. — is holding the U.S. economy back from being as productive as it could be.

These six cities have two things in common. They’ve had tremendously strong productivity growth in their labor markets. At the same time, they’ve also been particularly stingy with their housing supply.

Moretti’s super-productive cities have been among the the least likely to add new housing since 1990. Decisions to build or restrict new housing are normally the realm of urban planners. But here’s what they look like to an economist: “It’s as if we have some of the most productive metropolitan areas in the world,” Moretti says, “but we don’t allow American workers to flow to these areas to take advantage of that high productivity.”

Put another way: People who already live in San Francisco or New York have a lot of reason to keep other people from moving in. Their own housing values rise when supply is restricted. They protect their own scenic views. But by doing so, they also foil the chances of workers in St. Louis or Buffalo from moving to the cities where they would be most productive. And from a larger perspective, that means that restrictive land use in a few cities prevents the economy in aggregate from allocating workers in the most productive places.

If workers could move where they wanted to, Moretti and Hsieh have modeled that the country would look very different: New York, San Francisco and Boston would be much larger (yes, that means St. Louis and Buffalo would be smaller). The U.S. economy would be bigger, too, on the order of a “very significant” impact, Moretti says (he and Hsieh are still refining the precise number). Your average worker would probably earn several thousand dollars more a year.

“We’re not talking about doubling the size of New York overnight,” Moretti says. “We’re talking about increasing the size of New York over time, and increasing public services proportionally to population, so you’d have the same New York as now, but larger. This is very, very feasible, certainly in the context of the Bay Area. We’re not talking about building skyscrapers in the hills, or on green space, we’re talking about using developable land that’s already there, building on empty parking lots.”

There may be other consequences to such a world meant to optimize economic productivity. This vision could further contribute to a trend I wrote about two weeks ago, where workers with college degrees are increasingly segregating into cities like San Francisco. But if housing in those cities was less expensive, the costs in pushing out the poor would be much lower.

Regardless of what this idea would look like taken to its logical extreme, the basic concept is an important one: Policies that strictly limit new housing in many cities aren’t just bad for the housing costs of the people who live there — they’re bad for everyone.

And yet, despite these negative national externalities, land-use policy has always been a local issue. Moretti and Hsieh toy with the idea of making it a federal one. That might be the most unrealistic idea they throw out. But they also suggest that we could work around the strict housing policies of places like San Francisco by building better transportation networks out of them.

“California high-speed rail has always been thought of as a fast way to move people from Los Angeles to San Francisco, as competing with the plane,” Moretti says. “But it might be that actually its most meaningful economic impact would be as a way to allow people in Central Valley low-wage cities to commute to the Bay Area.”

He’s talking about Sacramento, Merced and Modesto, places two hours from San Francisco by car that could be within realistic commuting distance by high-speed rail. In essenence, this is another way of thinking about expanding housing supply in metropolitan San Francisco. Rather than build new housing there, we could expand the boundaries of the region itself as an economic whole to encompass more of the housing that already exists.

The ramifications from strategies like this would be even broader. In a more productive country, people are earning more. They’re paying more taxes.

“We’re talking about a larger pie for the U.S.,” Moretti says. “Then how we divide it is up to us. It’s a great problem to have.”