Encouraging children to tinker with electronics and pay attention to their computers could help 'save the country', according to a former British spy chief who believes that the UK is now critically short of tech-savvy talent and needs to urgently address the issue.

"The assumption that time online or in front of a screen is life wasted needs challenging," Robert Hannigan, who led British intelligence agency GCHQ between 2014 and 2017, wrote in an article for The Telegraph, published Monday 7 August. "It is driven by fear," he claimed.

He said that the hours spent playing with computers can "open a child's mind for life" and noted that he does "not recognise the moral concern about how the internet generation is turning out".

Hannigan said parents should let children learn to code, even urging the purchase of a Raspberry Pi.

He wrote: "If you appear to be spending your holiday unsuccessfully attempting to separate your children from Wi-Fi or their digital devices, do not despair. Your poor parenting may be helping them and saving the country."

Of course, there was an underlying motivation for his concern – the security of the nation.

"This country is desperately short of engineers and computer scientists, and lacks the broad 'cyber skills' needed now, never mind in the next 20 years," said Hannigan, who resigned from GCHQ in January.

"The baseline of understanding is too low and often behind our competitors. If we are to capitalise on the explosion of data that will come through the internet of things, and the arrival of artificial intelligence and machine learning, we need young people who have been allowed to behave like engineers: to explore, break things and put them together."

His comments were at odds with recent statements made by the UK's children's commissioner, Anne Longfield, who previously launched a "Digital 5 A Day" scheme. Longfield believes that parents should stop children abusing time spent online and compared its use to junk food.

In an article on 6 August, she stated: "I don't think parents should be afraid of children's digital lives – but what they should avoid doing is allowing their children to use the internet and social media in the same way they would use sweets or junk food given half the chance."

But the former spymaster disputes this idea, saying digital freedom could help, not hinder. "We need young people to explore this digital world just as they explore the physical world," he wrote. "We need to have the same debate about the balance of risk in the world of the internet"

He concluded: "Leave aside your fears of being a nerd: that would be a problem to be proud of."