One of the many oddities of San Francisco is that the city is full of libertarians who love regulation. You can do your own thing, unless you’re a tech bro, a landlord or a big corporation, and then you must be legislated into submission. The city’s housing market is distorted by a series of regulations that seemed like good ideas at the time, such as rent control and tight zoning. Instead of making the city more charming and affordable, they drew tension between those who can afford housing (the very rich, the long-tenured tenant) and those who don’t. The result is a nasty edge to daily life in an otherwise gorgeous city.

The twin pressures of rent control and a booming economy have created occupations that can scarcely be imagined elsewhere, such as the master tenant: this is a person who has a large rent-controlled apartment and who makes a living by subletting rooms at market rate. Sure, the subtenants can complain, but they aren’t likely to in a city where the shortage of housing is a serious issue.

Then there’s Airbnb. The zoning and construction limits that affect the housing market also affect the hotel market. In 2007, Airbnb was formed in this world of semi-anarchy: a service that allowed people to rent out rooms to visitors. The host received more money per night than he or she would from taking on a roommate. The money offset the very high cost of living in SF, and the visitor saved money on hotel bills.

Win-win? Not quite. With no regulation, participating in Airbnb raised questions: could renters rent out space in their apartments without violating their leases? What if the renter moved in with her boyfriend but kept the rent-controlled lease to make a living as a full-time hotelier? Could landlords kick out tenants in order to rent out apartments to short-term guests? Would the hosts have recourse against crazy, violent or thieving guests – or squatters? Likewise, would the guests be protected against difficult hosts? And was the city due taxes for the lodging services? If so, should it go after the hosts, the guests or Airbnb itself to collect?

Excessive regulation led to the creation of Airbnb, and less-excessive regulation may just save it. On Oct. 7, the San Francisco Board of Supervisors passed legislation allowing residents to rent out rooms if they register with the city and hold $500,000 in liability insurance. Also, Airbnb must remit lodging taxes to the city. Airbnb is now legal, and guests and hosts alike, at the very least, know where they stood relative to the law.

Regulation is such a complicated beast. It would be nice to say that there should be no regulation whatsoever, but let’s face it: some people will behave badly unless they are given limits. On the other hand, too much regulation creates its own issues. Rent control is a bad idea; it is an economic transfer from the landlord to the long-term tenant with no social advantages, as the tenants receive the benefit without regard to need. As with any transfer payment, once it’s in place, the beneficiaries form a tight constituency to keep it. No politician has the will to take on an issue like rent control, and there’s no time machine to undo it.

On the other hand, there’s the very interesting phenomenon of creativity acting in response to constraints. Because regulation creates problems, it creates demand for work-arounds to solve them. Airbnb is one example. Another, also from SF, is Uber: restrictions on the number of taxis meant that people who lived in San Francisco’s neighborhoods could not get cabs. The taxi drivers would rather serve tourists than troll for passengers in the Fog Belt. The market for medallions may be limited, but other forms of on-demand transportation solved the problem.

Maybe that’s the secret to economic growth in Northern California. We like to think that a high-tax, high-regulation jurisdiction would be a terrible place to do business, but people are flocking to San Francisco and surrounding cities in the hope of hitting it big. The tight regulations force creative thinking to work around them – and maybe lead to their destruction.