Image copyright Rex Features

James and the Giant Peach is 50 years old. In the story his parents die a violent death and James escapes abusive relatives. Why was Roald Dahl so dark?

There's a perception that children's literature involves endless picnics where the strawberry jam and lashings of ginger beer never run out. But Roald Dahl pursued a different path, satisfying children's appetite for the violent, greedy and disgusting.

Today, 50 years after the publication of James and the Giant Peach, Dahl is a towering figure. It was his first children's book and has now sold 5.1 million copies in the UK as well as being translated into 34 languages. But for years it struggled to find a British publisher.

The surreal plot emerged from bedtime stories Dahl told to daughters Tessa and Olivia. The hero, four-year-old James, is orphaned after his parents are killed by a rhinoceros. James is sent to live with his wicked aunts, the start of a traditional Dahl theme - the solitary child at the mercy of cruel adults.

Dahl facts Image copyright Getty Images Roald Dahl (1916-1990) was born in Llandaff, south Wales, to Norwegian parents

His stories are published in 49 languages

More than 100 million copies of his books have been sold globally

In 2010, Puffin Books sold a Roald Dahl book every five seconds

10% of author royalties from books, films, plays and merchandise are donated to two charities

He is bullied and beaten until one day an old man gives him a bag of crocodile tongues. James drops them by mistake on the peach tree, causing a giant peach to sprout, which James ends up living inside with various friendly insects.

"There's the isolated central child who is then propelled into a fantastical landscape inside the peach," says Donald Sturrock, whose authorised biography of Dahl - Storyteller - has just been published in paperback. What follows is a child taking revenge against adults. Backed up by some unlikely friends - in this case a centipede, earthworm and grasshopper - James squashes the aunts with the peach and floats away.

Dahl's books are full of the grotesque, from Mrs Twit substituting worms for her husband's spaghetti, to child-eating giants in the BFG, and the hero of Danny the Champion of the World drugging pheasants so that they're easier to poach.

Greed and its punishment is everywhere, whether it's Violet Beauregarde swelling up into a blueberry in Charlie and The Chocolate Factory or the child in Matilda who is forced to eat a whole chocolate cake.

For the Times newspaper's children's book critic Amanda Craig, there's also a "streak of rather unpleasant misogyny". In a Freudian sense, female characters are either warm and loving like the "supportive, luscious peach" or evil like the wicked aunts. It's a simple duality that children are used to, she argues.

Five dark storylines Image copyright Getty Images Charlie and the Chocolate Factory: One of Dahl's best-loved stories. It is a black comedy with the naughty children receiving diabolical revenges

Danny the Champion of the World: Danny, whose mother died when he was still a baby, discovers his father's deepest, darkest secret - a love of poaching

George's Marvellous Medicine: George concocts a hideous cure for his grandma's selfishness, grumpiness and general nastiness

Matilda: The leading lady (pictured above in the 1996 film version) is an exceptionally bright young girl who is horribly mistreated by her parents

The Witches: A young boy, whose parents have been killed in a car accident, has to battle against the Grand High Witch who wants to kill all the children in England

"Dahl is picking up the baton of the evil stepmother and the fairy godmother."

James and the Giant Peach was published in the US in 1961. But it was considered too "dark, brutal and vulgar" for the British publishing establishment, says Sturrock.

At the time, Dahl was seen as a writer of macabre short stories for adults. The book was eventually published in the UK in 1967 after Dahl agreed to pay half of the publishing costs in return for the same proportion of sales income. As it went on to sell millions it turned out to be spectacularly good business, his first of many best-sellers as a children's author.

There's always been darkness in fairy tales. In the 19th Century Hansel and Gretel involved a witch wanting to cook children in her oven, while Charles Dickens's Oliver Twist featured an orphan living out a miserable childhood.

But Dahl took things beyond masochism to sadism, says former children's laureate Michael Rosen. "In Hansel and Gretel the father is poor and only gets rid of the children against his better wishes. But in Dahl the parents are often sadists like in Matilda. There's a persistent nastiness and brutality in Dahl and he lingers over their horrible appearances and habits."

The darkness came from his own life. His father and sister died when he was three years old and a few years later he was sent to boarding school, a period he wrote about later in his book Boy.

Image copyright Rex Features Image caption George Clooney was the voice of Mr Fox in the 2009 Hollywood film

"He lost his father young. Then his mother sent him away to boarding school where he was viciously beaten. Those sadistic parents in his fiction are a reframing of his own experience," says Rosen.

Then there was his wartime experience. "Very few people have quite that fierceness," says Craig. "He's one of the few children's authors who's actually killed people. That is going to have an effect on how you see people and the world."

But others argue the darkness came from within his character. The book reviewer Kathryn Hughes recently wrote of him in the Guardian: "No matter how you spin it…Roald Dahl was an absolute sod. Crashing through life like a big, bad child he managed to alienate pretty much everyone he ever met."

Like many other children's writers such as Beatrix Potter, C S Lewis and Lewis Carroll, he had an ambiguous relationship with children. Sturrock argues he loved them but accepts he lost interest when they grew up.

"Once his own kids turned adolescent he switched off and packed them off to boarding school," he says.

Whatever his failings, Dahl succeeded because he understood a child's dark side, says Rosen.

Find out more BBC Radio 4 Extra is running a month-long series of programmes about Roald Dahl and his work, weekdays on The 4 O'Clock Show. Or listen again on the iPlayer

"Dahl knew that what children want in literature is the opposite of what they want in life. He believed that children love and hate their parents in equal measure. He lifts the lid and allows a child to have that hate feeling to adult carers."

Comedian Tim Minchin says Dahl's plots sound "terrifying". And while it's true they "scared him witless" as a child, it is an abstract fear free of the gruesome "baggage" that adults bring to the stories.

"When adults see child abuse in Matilda they think of Baby P. But kids don't see it that way," says Minchin, whose Matilda the Musical opens in London next month. "For children it looks dirty and fun."

And the books always end happily, says Craig. It's not so much a righting of the moral universe as the triumph of the child, she argues.

"He was unequivocal that it is the good, young and kind who triumph over the old, greedy and the wicked."

And the old shouldn't object, she says. For when we read Dahl we all become children again.