The truth is tech ruined the city. SF used to be a city of misfits, who don't usually have high income. Tech workers started flooding the city, drove up rents, and these misfits ended up homeless. Once you're homeless it's a struggle, some get back on their feet but some start abusing drugs. Government support programs are terribly run, so nobody uses them. Let the situation go on for a few years and you get SF.
It's not just SF though, it's any city in North America that has had booming rents the past couple decades. Vancouver, Seattle, Portland, SF.
If you look at Tokyo, rents are low and jobs are plentiful. The biggest city in the world has less than 4000 homeless people living in it.