Suppose your best friend is down on her luck. Magnanimously, you give her a spare room in your house, on a temporary basis, and when she starts earning some income, you let her pay rent—say, $100 a week.

You would think that just about everybody would applaud you. After all, your act of charity has prevented one more person from becoming homeless. But not everybody is happy with that result. The hotel industry doesn’t like it for selfish reasons. Progressive politicians don’t like it because .... well, it’s not always clear why progressives think the way they do.

All of this came to a head this week in a fight over a ballot proposition in San Francisco, a city with two interesting distinctions. With an average-priced home costing $1.1 million, it’s the most expensive place to live in America. And, it’s home to Airbnb, a company that came into existence to solve the housing shortage crisis by connecting homeowners who are willing to rent out a room with strangers who need a place to stay. In fact, Airbnb has been so successful in meeting previously unmet needs all over the world that its market value exceeds that of the hotel giant Marriott International.

Let’s pause for a sidebar on the economics behind all of this. At any one time, there are millions of opportunities for mutually beneficial exchanges that never get consummated. I have a room I would be willing to rent and someone else would be willing to rent it, but we don’t know of each other’s existence. When I am not driving my car, I would be willing to rent it to someone else and someone else would like to rent it. I would be willing to pay someone to bring me a takeout hamburger and there is someone who would be willing to do that. But, again, we don’t know each other. Modern technology is eliminating all those barriers to mutually profitable exchanges.

But standing between all those willing buyers and willing sellers are a raft of special interests who like things just as they are—or were. Just as Yellow Cab and their friends at City Hall have been trying to shut down Uber in every city in the country, in San Francisco the hotel industry, with local politicians in tow, has been trying to stop homeowners from renting out their rooms.

Proposition F, which was soundly defeated in last Tuesday’s election would have limited a homeowner’s ability to rent out a room to only 75 days. The proponents, including Sen. Dianne Feinstein (who along with her husband has $25 million stake in a San Francisco hotel) even had the audacity to claim that regulating homeowners would actually help solve the city’s housing shortage.

It’s worth noting that virtually all of California’s housing problems—especially those in San Francisco—are the result of unwise public policies. At e21, Jared Meyer and James Delmore explain:

San Francisco, where rents for a one bedroom apartment frequently exceed $4,000 per month, has the most serious housing shortage in America. Over the past 20 years, San Francisco only permitted the construction of an annual average of 1,500 housing units. Over that time, San Francisco’s population grew by 97,000. From 2010 to 2013 it grew by 32,000.

According to a Trulia study that examined housing production from 1990 to 2013, San Francisco had the highest median prices per square foot and the lowest rate of new construction permits among America’s ten largest tech hubs.

Nearly 80 percent of San Francisco’s housing is occupied by rent-controlled tenants or homeowners. This leaves only one in five housing units available for other renters, artificially driving up rents.

One thing the Proposition F proponents didn’t count on was that the companies who service the “gig economy” have the email addresses of lots of voters.

Leading up to the election, Airbnb was only too happy to remind the 138,000 San Franciscans who have used its app that the company was helping to solve the very problem that city government had created. It didn’t hurt that the number of app users was greater than the number who actually voted on Tuesday. In New York City, Uber contacted its 2 million app users to help defeat onerous restrictions backed by the taxi cab industry. That’s more than the number of people who voted for Mayor Bill de Blasio in the last election.

In both cases the app companies are making the pitch that they, not the politicians, are defending the middle class. Who could argue with that?