Did racism as a concept evolve from tribalism?

This isn't racism exactly, but I think this is getting at the root of what you're asking about. George Washington University political scientist, Henry E Hale, wrote a book called "The Foundations of Ethnic Politics".

While the main international relations component of the book in the later chapters deals with modern Eurasia, in the early chapters while establishing the theory, he goes over the origins of humanity and the evolution of the social world. In brief, he argues that the social world is ultimately a complex monster, one that is difficult to easily understand and categorize in the more primitive brain of early humanity (heck, it can be difficult for us these days, still). As such, the brain creates mental shortcuts and tricks to navigate the complexities of that world. One of these is that those who are close to a person are safer, more reliable, less likely to beat their head in with a rock. So when confronted with people not familiar, either through different skin color or any other various factors that go into the appearance of a human, there is a sense of fear that goes with othering. As such, unity of political units took a long time, and even to this day is still an ongoing process, driven in large part by the legacy of these origins. Tribalism is what can be considered the earlier stages of the integration of political units, all the way up to the state and now multi-state political entities like the EU.

If we accept the argument that the division of early political units was by and large driven by fear of the other in a complex social world rife with danger, then it would follow that tribalism and the general idea of hating those who are different are intrinsically bound to one another. Racism is more specific than just hating those who are different, as it is specific to a race component, but given racism can be encapsulated in the same type of othering mentality, it is likely related.

/r/AskSocialScience Thread