You might say that modern English fiction begins on a beach, and with a mystery – or a menace. In 1719, Daniel Defoe has his marooned Robinson Crusoe, who thought himself so alone on that archetypal desert island, one day find himself "exceedingly surprised by the print of a naked man's foot on the shore, which was very plain to be seen in the sand. I stood like one thunderstruck, or as if I had seen an apparition." At least Crusoe's future companion Friday (for the footprint is his) didn't nick the sun-lounger or swipe that silly cocktail with a paper parasol.

If beaches mean a quest for refuge or solitude – getting away from it all – then what happens when we encounter humanity, in the form of Friday, on the sand? Stroll along the literary beach over the centuries, and you discover a less than idyllic scene. For a start, until the very recent advent of the slow-roasting sun cult, they never appear as friendly or attractive spots. If you have a beach then, in a seafaring age, you don't have a welcoming port, a harbour, a sheltered anchorage – just dead, marginal space, sun-baked or wind-lashed, with no cover. Who knows what dangers might lurk inland or surge from the sea? In Racine's tragedy Phedre, the dreadful climax comes when a sea-monster roars on to the beach and frightens the horses of the fleeing prince Hippolytus, dashing his chariot – with fatal results – on to the rocks.

For the modern greats, beaches incubate alienation and loneliness. "On Margate Sands/ I can connect/ Nothing with nothing," mourns TS Eliot in The Waste Land. The Kentish resort has since had an image makeover – but, yes, we do know how he feels. Among the classics of 20th-century fiction, the most fêted beach of all is Sandymount Strand in Dublin. There (in the 'Nausicaa' episode of Ulysses), James Joyce's Leopold Bloom cultivates his fantasies about a girl named Gerty McDowell, her scanties spied in the distance.

Post-Second World War, a frankly dystopian fog descends on the fictional beach, prompted in part by nuclear anxieties (all those scary tests on tropical strands) but also by a growing distaste for the costs of mass tourism. Nevil Shute's 1957 nightmare of Australian survivors after a nuclear war is called (what else?) On the Beach.

JG Ballard's versions of strangeness on the shore encompassed both apocalyptic fears, as in the stories "Terminal Beach" and "Vermilion Sands", and a vision of pleasure-seeking vacancy on meaningless holidays that never end, in late novels such as Cocaine Nights and Super-Cannes. Very much in the Ballard vein, French enfant terrible Michel Houellebecq sees only selfish, exploitative squalor in the sands of his novels Platform and Lanzarote. In the shadow of William Golding's Lord of the Flies, Alex Garland updated the terror of blood on the sand for the backpacker generation with The Beach.

That unpleasantness happened in faraway Thailand. This year, you might prefer a safe, nearby beach – maybe at cosy Aldeburgh? If so, don't pack the ghost stories of MR James – and avoid in particular "Oh, whistle and I'll come to you. My lad" (1904), with its hideous glimpse of a pursuing figure in "pale, fluttering draperies" that would "bow itself toward the sand, then run stooping across the beach to the water-edge and back again; and then, rising upright, once more continue its course forward at a speed that was startling and terrifying". Happy holidays!