Misc cops/lawyers. Is it legal to beat up homeless ppl or joggers in SF?

In the context of self defense.

Everyone I've talked to has said SF is hell and one of the reasons is the homeless ppl and crime. Thing is though everyone there is a tech nerd.

If you're jacked, is SF not a problem if you can just beat up the homeless or joggers if they come at you? Or would defending yourself still be illegal?
Balding is death. If you have no hair, you have no life.