I think a lot of it comes down to social norms. From what I remember, 4chan was almost boringly pleasant outside /b/. Because the norm and moderation were towards thoughtful posting.
On the other hand pseudonymous reddits with the norm of knee jerk responses and political twitter are awful. Because that’s the encouraged norm.
Personally, I think the important factors for maintaining a civil community is a focus on civility, some overt selection of topics (vs. having a group that's about everything), and a lot of moderation work in the background that prevents the decay of standards. Social norms, unfortunately, don't maintain themselves.
HN also has great moderation (thanks DanG) and a strict set of rules which helps.
If HN was truly anonymous (everyone posted under anon accounts) I think it would decay and I’m not sure DanG would be able to save it.
I do think Urbit’s approach to this (low cost to creating an ID) is a really good one for handling this problem and the general problem of spam decentralized, and at scale.
Pseudonyms that are not trivially created and discarded can build reputation and will generally behave themselves (see Urbit’s approach to this problem).
Anonymous accounts incentivize awful behavior (see 4chan).
Real life is different because you’re not truly anonymous in person - you’re recognizable most of the time and identifiable. There are also more in person norms and social constraints.
The exception to this in real life might be mobs, where the chaos and confusion can provide some anonymity and well - people in mobs don’t behave that well either.