Earlier quoted context omitted.
Yes, I do realize Switzerland doesn't actually use direct democracy for things that matter and when they do they often end up with xenophobic laws. I don't even want to talk about town assemblies voting on naturalisation decisions.
So if they want to be xenophobic, what's the problem? It's their country and they can do whatever they want with it.
Creating laws based on popularity makes populism rule. Hence why democracy usually has an explicit legislative branch abstracting over individual sentiments. That helps prevent policy from being devised through an overly greedy algorithm.
That is not to say it prevents all these problems. But it evidently helps.