It has become a brutal and tragic motif of the times in which we live. In the heart of our busiest cities, irrespective of nationality, age or gender, innocent civilians find themselves mown down in Islamist-inspired terrorist attacks. The killing has sometimes involved bombs and guns but increasingly has been carried out with so-called low tech weapons such as knives or vehicles.

Following horrific events like those in Barcelona, it’s only right and natural that we should seek to learn what lessons we can on how best to prevent or diminish the chance of such atrocities.

Frustratingly, in the wake of such attacks, it often feels as if we simply go over the same ground, gleaning little that helps implement improved security.

Understandably, it will be of little or no consolation to the relatives of terror attack victims to know that for every outrage that takes lives, others are thwarted by the diligence and persistence of the security services.

Unpalatable as it is, there are also harsh realities that as citizens we must all now face up to. The first is that the West is embroiled in a long war against Islamist-inspired terrorism. That war and the violence that comes with it will not ease any time soon.

Given the nature of open societies and the civil liberties underpinning them, the extremist threat can never be fully eliminated. As terror groups like Islamic State (IS) increasingly find themselves under pressure in former strongholds like Mosul in Iraq or Raqqa in Syria, the shockwaves from their defeats will continue reverberating here in Europe and beyond.

With reports of a CIA warning two months ago about a threat to Las Ramblas in Barcelona, almost inevitably questions will be asked as to whether more could have been done to foil the attacks.

The answer, of course, is that more can always be done when it comes to improving security, be it in Barcelona, Paris, London or anywhere else. The fact remains that few street-level measures, be they cordons, barriers, electronic or ID checks are ultimately foolproof. The first and best line of defence against terrorism remains intelligence gathering.

As many experts point out, even the term “lone wolf” is often misleading in that individuals almost invariably have some connection to terrorist propaganda or core groups.

Where terrorist cells appear to have been operational, as suspected recently in Spain, intelligence gathering and the ability to penetrate and neutralise such groups early is obvious.

The fact hundreds of terror suspects have been detained and dozens convicted in Spain over the past five years with the help of informers and spies is why the country has been spared other attacks. This, along with a very effective policy of integration of Muslim immigrants, has thwarted a string of plots.

Difficult as it is to contemplate, there will be more terrorist attacks like that in Barcelona. Just as this is a given, so too is our best means of diminishing such a threat: intelligence sharing and security co-operation across Europe.