The second hint that things were going to be interesting was when the guy on the front desk told me how to get to Union Square - the hotel was on Geary St. and I thought I knew SF reasonably well. He proceeded to tell me not to walk directly along the street, but to walk up the hill a bit then walk across in the direction of Union Square.
It turned out that during the day this advice wasn't really required but at night it definitely was! I only walked back once and took taxis back after that.
This was about 10 years ago - don't know if the area is more civilised now but it was pretty scary then.
Two areas of SF are pretty bad: Hunter's Point / Bayview, and the Tenderloin. Personally I never really go there on foot, and I'm fine. If I must go there, I'll drive of catch a cab.
I've only moved to NYC few months ago and never felt remotely as threatened as some of my late night walks in SF. Still I keep hearing NYC has its own share of bad hoods but my guess is in proportion to its overall size, they comprise a significantly small % of area than sf.