How do you distinguish a foreign-policy "idealist" from a "realist," an optimist from a pessimist? Ask one question: Do you believe in the arrow of history? Or to put it another way, do you think history is cyclical or directional? Are we condemned to do the same damn thing over and over, generation after generation — or is there hope for some enduring progress in the world order?

For realists, generally conservative, history is an endless cycle of clashing power politics. The same patterns repeat. Only the names and places change. The best we can do in our own time is to defend ourselves, managing instability and avoiding catastrophe. But expect nothing permanent, no essential alteration in the course of human affairs.

The idealists believe otherwise. They believe that the international system can eventually evolve out of its Hobbesian state of nature into something more humane and hopeful. What is usually overlooked is that this hopefulness for achieving a higher plane of global comity comes in two flavors — one liberal, one conservative.

The liberal variety (as practiced, for example, by the Bill Clinton administration) believes that the creation of a dense web of treaties, agreements, transnational institutions, and international organizations (such as the U.N., NGOs, and the World Trade Organization) can give substance to a cohesive community of nations that would, in time, ensure order and stability.

The conservative view (often called neoconservative and dominant in the George W. Bush years) is that the better way to ensure order and stability is not through international institutions, which are flimsy and generally powerless, but through the spread of democracy. Because, in the end, democracies are inherently more inclined to live in peace.

Liberal internationalists count on globalization, neoconservatives on democratization to get us to the sunny uplands of international harmony. But what unites them is the belief that such uplands exist and are achievable. Both believe in the perfectibility, if not of man, then of the international system. Both believe in the arrow of history.

For realists, this is a comforting delusion that gives high purpose to international exertions where none exists. Sovereign nations incessantly pursue power and self-interest. The pursuit can be carried out more or less wisely. But nothing fundamentally changes.

Unfortunately, with "justice" did not come peace. The policies that followed — appeasing Vladimir Putin, the Iranian mullahs, the butchers of Tiananmen Square, and lately the Castros — have advanced neither justice nor peace. On the contrary. The consequent withdrawal of American power, that agent of injustice or at least arrogant overreach, has yielded nothing but geopolitical chaos and immense human suffering. (See Syria.) Barack Obama is a classic case study in foreign-policy idealism. Indeed, one of his favorite quotations is about the arrow of history: "The arc of the moral universe is long, but it bends toward justice." He has spent nearly eight years trying to advance that arc of justice. Hence his initial "apology tour," that burst of confessional soul-searching abroad about America and its sins, from slavery to the loss of our moral compass after 9/11. Friday's trip to Hiroshima completes the arc.

But now an interesting twist. Two terms as president may not have disabused Obama of his arc-of-justice idealism (see above: Hiroshima visit), but they have forced upon him at least one policy of hardheaded, indeed hardhearted, realism. On his Vietnam trip this week, Obama accepted the reality of an abusive dictatorship while announcing a warming of relations and the lifting of the U.S. arms embargo, thereby enlisting Vietnam as a full partner in the containment of China.

This follows the partial return of the U.S. military to the Philippines, another element of the containment strategy. Indeed, the Trans-Pacific Partnership itself is less about economics than geopolitics, creating a Pacific Rim cordon around China.

There's no idealism in containment. It is raw, soulless realpolitik. No moral arc. No uplifting historical arrow. In fact, it is the same damn thing all over again, a recapitulation of Truman's containment of Russia in the late 1940s. Obama is doing the same, now with China.

He thus leaves a double legacy. His arc-of-justice aspirations, whatever their intention, leave behind tragic geopolitical and human wreckage. Yet this belated acquiescence to realpolitik, laying the foundations for a new containment, will be an essential asset in addressing this century's coming central challenge, the rise of China.

I don't know — no one knows — if history has an arrow. Which is why a dose of coldhearted realism is always welcome. Especially from Obama.