Graeme Archer is a statistician and a former winner of the Orwell Prize for Political Blogging.

In Dan Mangan’s song “Robots”, the singer attempts to make plain the crisis facing every Robot Boy. That no matter how cold and clinical an approach you take to life, no matter how much you pride yourself on emotional detachment, no matter how safe this makes you feel: it doesn’t work. There’s “a flaw in the design.” Because “robots need love too.” It took me a long time to understand this.

Although I doubt very much whether PD James was a fan of Mangan’s song (though how could I know?), I expect she would have approved of the theme. Her novels deal often with men and women who seek order, detachment, calm. They want to be “robotic” – that is, rule-driven – and live in lay religious retreats, in private hospitals, in the pre-war social order (and in the case of her main protagonist, in the police force.)

Most of them are brought face to face with the flaw in such a design, a few by the obscenity of murder, but more often through having to declare their need for love, as part of death’s inevitable aftermath. Few Tory writers bother to write about love. For James, I think (I’m no academic) it was the central driving force of her books.

Why did she sublimate her ideas into detective novels? Here is my opinion. We are each a vortex of the unknowable, a mixture of “devices and desires” (her most frightening story, I think – there are theses to be written about brothers and sisters in her work): it is this central human fact that lies at the heart of the murder story, because if we could know people, we would certainly know if they were a murderer; we, the reader/suspects/victims do not know, however, which is why we need He/God/the detective to “solve” the mystery of the other for us.

James’s approach to the genre used its classical characteristics – closed settings, like monasteries, nursing homes, publishing houses – but played with them. Often there is an omen in the environment – the landscape is crumbling into the sea, or is dominated by a looming tower, or a lighthouse, or a stone circle – to remind the characters and the reader that order is no guarantor of comfort. That there are forces beyond the human capacity to understand. The murder merely makes this point clear.

(That she did not require the “closed form setting” was made plain by The Children of Men. Read the scene with the kittens in the pram. Tell me you do not shudder with horror, though there is no act of violence committed. Only a mother could have created such an image, I think.)

It is impossible not to read the life of James into the progress of Dalgleish through the canon. In the early books, women are not permitted to be close to him. He is a robot. James’s married life ended in tragedy. Her husband was damaged by the war, became mentally ill. I have a memory of a radio interview in which James spoke of her husband’s suicide, two years after she began writing. How do you measure pain such as that? What might it do to your humanity?

It’s all there, right from the start, in Cover Her Face, her first Dalgleish novel, published in 1962. Deborah, who is to become enamoured with Dalgleish, is damaged. Her father, a strange, animal presence/not-presence, is damaged by a vaguely-defined disease, his corpse/not-corpse hovering above all the actors in James’s dark play below. Deborah’s lover/not-lover is damaged by the war, she by the death of her husband. Her brother, a physician, threatens to bring down the social order by marrying Sally Jupp, an unmarried mother from the home for distressed women, who is a maid in the household. Clearly Sally must die; this is almost the least interesting fact of the novel.

Yet even here, right at Dalgeish’s start, the hint of “the answer” is given. There’s a stronger hint later on in her work (I’m writing from memory in a train station, so apologies, I can’t remember in which novel) where an old woman and her husband are waking, early in the morning. The husband is becoming senile. The passage talks of the “animal warmth” of their shared bed: marriage is shelter. We are animals and we need one another, even in our pain, because outside there’s only darkness.

In the later books, those hints are turned into clear direction. Dalgleish thaws, and loves the academic Emma (who must have been named in honour of Austen, as, too, must Dalgleish’s bird-obsessed, solitary aunt.) Though I once preferred cold, dark, negative Dalgleish to the later Dalgleish in love (forty years a robot), this progress was necessary, because James’s answer to the question (what do we do about pain?) is: love.

Devices, in other words – back to the unknowable vortex – have desires, and you ignore them at your peril. At the end of The Private Patient comes this:

‘The world is a beautiful and a terrible place. Deeds of horror are committed every minute and in the end those we love die. If the screams of all earth’s living creatures were one scream of pain, surely it would shake the stars. But we have love. It may seem a frail defence against the horrors of the world but we must hold fast and believe in it, for it is all that we have.’

The miracle is that the sun can rise, that it dares shine light on the unhappiness below. But there the sun is: so miracles exist, and that miracle is love. This was the lesson that P.D. James taught me: she wrote fiction about death, and showed me how to live. No more robots. That’s not a flaw in your design, man. Seek out the animal warmth, because in the end it is all that we have. But it’s enough.