As for slums and marginal areas -- yes, they exist, but even there the costs of living can be high, and in terms of livable low-cost areas, such as you might find in Chicago, or Detroit, or Berlin, not so much. Land-use planning, growth limitations (California is ultimately water-constrained), NIMBYISM, and real-estate inflation have and are taking their toll on the area.
Regarding affordable living, I think you'd be suprised what you can find. In just about every county there are affordable housing developments and less affluent areas. Those people taking your fast-food order for minimum wage and cleaning your house have to live somewhere.
Of course even entry level jobs in tech preclude you from the government assistance many poor people here rely on. But "I make too much money for affordable housing" is bit different thing to say than "SF has no place for you to fall ... There are no slums. There are no marginal areas."
The "valley" is Santa Clara Valley, which is a full 45 miles away and a very diverse set of neighborhoods.
"There are no slums. There are no marginal areas." <-- have you seen some parts of east San Jose, or east Palo Alto? Or since "the valley" apparantly includes more than the actual geographic valley, what about Richmond or Stockton near the docks? I wouldn't suggest stopping at red lights at night.
I've lived in "the valley" my whole damn life. My family has ties going back to the gold rush days. I have no idea where it is that you lived, as it sure as hell doesn't resemble anything I recognize.
I'm sorry you had such a shitty experience.