OPINION: What the West should've learned from its long 'war on terror'
Behind President Barack Obama's Sunday night speech lies an awkward reality.
Ever since 9/11, the West has been fighting two in some ways separate, but deeply intertwined battles against Islamist militancy.
One, to protect the West from attack, has actually gone remarkably well.
The other, however, to shape events in the Middle East and surrounding regions and push back radical militant groups, has been something of a disaster. Somehow, those two campaigns must be reconciled if groups like Islamic State and its ideology are to be defeated.
Last week's shooting at a San Bernardino, California, special needs centre was the deadliest jihadist attack on US soil since 9/11.
In all, such post-9/11 attacks have killed 45 people: a series of senseless deaths, yet a relatively small number considering the level of concern and attention paid to the topic.
The vast majority of those attacks appear to have been homegrown plots, albeit in many cases inspired and sometimes carried out by those in direct contact with militant groups elsewhere in the world.
Why have there been so few attacks?
There are several reasons, including sheer distance and air travel controls that make it hard for any foreign assailants to get themselves into position. Additionally, the US Muslim population remains well-integrated, particularly compared to Europe; law enforcement efforts have been massive and relatively effective; and strikes overseas have disrupted plots, as has the incompetence of the militants themselves.
And much of it, current and former security officials concede, comes down to luck.
What the Paris attacks showed, though, was the last decade of war in the Middle East coming home to roost. Those attacks may have been largely carried out by European-born or resident attackers, but the planning had clear links to Syria, and with the continent awash with refugees from Middle East war zones, stopping a handful of militants from slipping through the net is all but impossible. That's much less true in the United States and Britain, both of which can control borders much more easily.
Simply protecting the West and letting the Middle East burn is not really an option. Many of the West's actions over the last decade and a half, however, have made matters worse.
In Iraq and Libya in particular, we used military force to dismantle dictators, with no good alternative to fill the gap. In Syria, the West did even worse by encouraging the opposition to rise up against President Bashar al-Assad without backing them sufficiently to finish the job. The resulting instability provided the perfect environment for Islamic State to thrive.
The result has been devastating, a nine-fold increase in deaths worldwide from militant attacks, almost all of them concentrated in a relatively small number of countries across the Middle East and Africa.
Yet the situation isn't necessarily as bad as many think it is. Yes, Islamic State still controls a disconcerting amount of Iraq and Syria. Its expansion, however, has largely been halted as a result of airstrikes and efforts by local forces. As a result, it has become much harder for the group to maintain its narrative of invincibility, particularly as it begins to be pushed back in Iraq, in particular.
With the exception of Islamic State and its urban strongholds around Raqqa and Mosul, Islamist groups have had remarkably little success making serious territorial inroads around major cities. In Afghanistan, the Taliban has never managed to hold serious urban ground for more than a handful of hours. Nor has Boko Haram in Nigeria or the various groups in Pakistan, who so brutally terrorised Mumbai in 2008 and who hit targets in their own country even more often.
Those states might have their weaknesses, but today they are more urbanised than at any point in history. For now at least, their governments have the ability to hold the cities, and their populations seem to have little appetite for Islamist militant rule. The endless attacks have a high human cost, and it's almost impossible to stop militants infiltrating the target-rich cities, but total takeover seems unlikely.
For the United States and its allies, simply degrading Islamic State to the extent that it could no longer hold major towns would be a success. That, though, will take time, not least because the ethnic Sunni populations of places like Mosul and Raqqa would rather take their chances with Islamic State than live under, and risk recriminations by, the Shiite-dominated governments in Baghdad and Damascus. Persuading them otherwise will not be easy.
There is one country in which outside intervention has achieved such results, however, Somalia, where local African forces, backed by US strikes and intelligence, have pushed Al Shabaab militants first from Mogadishu and now from wider swathes of territory.
The strategy Obama outlined on Sunday is very much in that model. Yes, there will now be small numbers of US special operations forces on the ground in Syria as well as Iraq. In both cases, however, the plan is to build local capacity.
If the last 15 years have shown anything, it is that larger Western interventions can be less effective. Everyone knows they will one day leave, so it's hard to achieve lasting effects.
On that front, targeted air strikes should help. The West may be lousy at long-term strategy, but their militaries are really good at destroying structures and systems. In Iraq and Libya, that's probably done more harm than good, but it augers badly for Islamic State's hope of becoming an actual functioning state.
To build on that strategy, though, you need a functioning state in areas that Islamic State would otherwise control. That's still a long way away, particularly in Syria, where regional and global powers have long been fueling the conflict by picking sides based on wider geopolitical and ideological disagreements.
What binds the two interlocking battles against militancy, to stop attacks in the West and stabilise the current conflict areas, comes down to the same thing: integration.
By that, I do not necessarily mean cultural integration, although that is unquestionably important. I mean that the populations from which potential militants are drawn, be they disenfranchised groups in Iraq and Syria, Muslims in America and Europe, feel that they get something back from the nation-state they reside in.
In the United States and Europe, that is still not that difficult. Even relatively ill-integrated new migrant populations get plenty back in terms of benefits, opportunities and the rule of law. After all, that's why many came in the first place.
In countries like Iraq, Nigeria and most particularly Syria, rebuilding that social contract is going to be much, much harder. It will require unpleasant compromises and dealing with people the United States really, really doesn't like. But it is not impossible. Building those structures needs to be at the heart any truly effective strategy.
There will still, of course, be fanatics who will need to be robustly tracked down and neutralised. But that is a much more manageable problem.
It will not be easy, not least because the West and its allies are themselves often ineffective, transparently hypocritical and capable of huge mistakes. In general, though, both it and the globalised world it has created remain much more appealing places to live than anything Islamic State or its allies have to offer.
Peter Apps is Reuters global defence correspondent, currently on sabbatical as executive director of the Project for Study of the 21st Century (PS21).