Take Airbnb, a San Francisco-based company now valued at close to $10 billion that enables users in 192 countries to turn their homes into hotel rooms. In 2010, the state of New York passed a law confirming that short-stay rentals were generally illegal in apartment buildings, and for good reason: The longstanding distinction between hotels and apartment buildings protects the rights of building residents who didn’t choose to live 10 feet away from a parade of strangers. The law also protects tourists — who are usually unfamiliar with the rooms and buildings where they are sleeping — by imposing stiffer fire safety and building codes on hotels.

Airbnb “hosts” rent out apartments every day in violation of this law. Some of these are large, commercial enterprises with dozens of apartments — truly illegal hotels.

The most straightforward solution would be for Airbnb to simply prevent illegal transactions. But when my office reached out to Airbnb, the company rejected the idea of self-policing out of hand and refused to provide data that would give us a handle on the scope of the problem. With my hope of working in partnership with Airbnb dashed, we were forced to subpoena the company for information, a step that Airbnb has attempted to quash in court.

On Monday, just 24 hours before a key court date, Airbnb announced it had removed some 2,000 New York-based listings from the site, suggesting that our concerns are not misplaced. But none of this promotes confidence in the site — by users, their neighbors or the regulators whose job it is to protect the public.

Another example is Uber, a company valued at more than $3 billion that has revolutionized the old-fashioned act of standing in the street to hail a cab. Uber has been an agent for change in an industry that has long been controlled by small groups of taxi owners. The regulations and bureaucracies that protect these entrenched incumbents do not, by and large, serve the public interest.