IMAGINE it. An authoritarian president takes over the White House. He introduces a register of illegal aliens and starts to deport them. He begins a war of words with China which escalates into military skirmishes. He also declares that global warming is a hoax and scraps America’s efforts to tackle it. Climate catastrophe approaches. A third world war looms. And then, in a final twist, it is revealed that the new US president was a Russian agent all along.

It could be the outline of a dystopian science fiction film. But at least some of it is also true – or will be soon – which is how dystopias work. They take a problem of the present and map it onto a potential future. What would it be like if the White House was run by a megalomaniac? What would it be like to live through the third world war or a worldwide famine? What if the robots took over, or no-one ever died, or the authorities could read our minds or keep us placid and controlled through drugs? What if our hopes of progress were misplaced and the future was considerably, and shockingly, worse than the present?

One of the greatest examples of this approach – the future as a warning – is Metropolis, the influential German silent film which is celebrating its 90th anniversary. Directed by Fritz Lang and at the time the most expensive film ever made, its extraordinary images have never gone away: the towering buildings and flyovers in a city of the future; the huge, steaming underground machinery; and, most famously of all, the android woman with limbs of steel and eyes of light. That image of the robot, Maria, is probably one of the most influential ever in science fiction and popular culture. All robots have the same mother: Maria.

However, it is the dystopian vision of how cities, and different classes of human, might live and work in the future that is the most fascinating element of Metropolis. At the start of the movie, we see the two sides of the city: the beautiful, blonde super-race who live high up in the tall buildings and the grimy, oppressed underclass that work the machines that keep the city going. It was an idea of how the future might be, but, more importantly, it was a criticism of how the world was then – in the case of Metropolis: the 1920s, a time when Western Europe was still emerging from the First World War. While one section of society in the 1920s was having a great old time, another was struggling to eat. Metropolis wasn’t the future, it was the present.

And that is essentially why dystopian visions of the future have always been so popular with novelists and film-makers. There are utopian alternatives – Iain M Banks’s Culture novels for example, or Star Trek, which imagines a future where distinctions of race, sex or class are irrelevant – but they are hugely outnumbered by visions of a much darker, grimmer and nihilistic future because that way you can tackle the crises and challenges facing humans: ageing, obesity, fertility, gender and sex, food, war, plastic surgery and beauty, class and poverty. The great works of dystopia also tackle the potential political solutions and how they can go wrong – if there is one thing dystopian writers are obsessed with more than anything else it’s the dangers of fascism and socialism.

A history of dystopian novels and films proves the point and it is no coincidence that images of a fearful future began to proliferate at the end of the 19th century, when life was speeding up and many people were being left behind. Jules Verne proposed a future terrorised by weapons of mass destruction in The Begum’s Fortune, which was published in 1879, and while HG Wells was in many ways a utopian writer, The Time Machine tackles the issue of class division when the Time Traveller ends up in a future in which society is divided between the ineffectual Eloi and the brutal Morlocks.

Perhaps unsurprisingly, a few years later, the early part of the 20th century was filled with dystopian novels taking on capitalism and socialism, including the great but neglected 1935 novel Land Under England by Joseph O’Neill, in which an explorer discovers a underground society where all individuality is erased by an all-seeing state – whether it is a warning about socialism or fascism is up to you.

Later, in the age of film, dystopian visions of the future continued to be a rich source of inspiration. Metropolis was based on a screenplay by Fritz Lang’s wife Thea von Harbou, but many of the greatest dystopian films of the last 70 years have been based on novels. The 1966 film Fahrenheit 451 is based on the Ray Bradbury novel about a future in which reading is illegal and a fireman’s job isn’t to put out fires but to start them and throw books on the pyre.

Also based on a book by Harry Harrison, Soylent Green in 1973 tackled food shortages and over-population and suggested how one problem could solve the other – something which Jonathan Swift had tackled almost 250 years earlier in his 1729 satirical essay A Modest Proposal, which suggested that the Irish might ease their economic troubles by selling their children to rich people as food. Then there was Logan’s Run in 1976, in which over-population was solved by killing everyone as soon as they reached the age of 30. It was based on the novel by William F Nolan and George Clayton Johnson.

Demetrios Matheou, the Sunday Herald’s film critic, believes these dystopias work because of the combination of ideas and entertainment. “There is not much drama in a rosy future in which everything is perfect, we’ve solved the problems of illness and disease and have become decent people to boot,” he says. “It’s much more dynamic when things are terrible – as in 1984, Mad Max, or more recently The Hunger Games – or when they seem perfect on the surface, but “utopia” comes at a price or not everything is as it seems, as in Logan’s Run, Soylent Green.”

Matheou also cites Gattaca, the 1997 film set in a future in which parents can change the genetic make-up of their children before they are born and those who are unmodified are doomed to a menial and meaningless life.

Another of Demetrios Matheou’s favourites among the more recent dystopian films is Children Of Men in 2006. Based on a novel by PD James, it suggests a future in which the British Government has grown more oppressive and is rounding up illegal immigrants into prison camps. It hasn’t happened yet, but it is that kind of future-echo of what is happening in real life – in this case, the scapegoating of refugees and immigrants during the Brexit referendum – that makes a film like Children Of Men so fascinating, and a little frightening.

There are real-life echoes almost everywhere else you look. The Channel 4 series Humans, for example, is set in a time when robots develop consciousness and rebel against their human masters. Meanwhile, in real life, it was announced last week that MEPs are to vote on the first comprehensive set of rules for how humans will interact with artificial intelligence and robots, which in turn reflects dystopian fiction, in particular I, Robot, the novel by Isaac Asimov, which laid down the rules for robots including the first and most important: “A robot may never hurt a human.”

There are other dystopian visions which seem to have disturbing parallels in real life as it is or might be. The Hunger Games suggests a future in which young people are obsessed with gaming and reality TV shows. The Handmaid’s Tale, the 1985 novel by Margaret Atwood, a film in 1990 and a TV series next year, posits an America run by a totalitarian theocracy.

There are also other, more neglected novels, television series and films whose dystopian ideas deserve more recognition. Facial Justice by LP Hartley, the novelist more famous for The Go-Between, was written in 1960 but is set in a future in which people have their faces surgically altered to look the same. Did Hartley foresee the ubiquity of plastic surgery? And later this year, the pretty much forgotten BBC series 1990 will be released on DVD. Starring Edward Woodward, it is set in a Britain whose citizens have given up their rights in exchange for security. Did its writers predict the rise of security cameras and internet surveillance?

It is also interesting to speculate as to where dystopia will take us next, with Donald Trump and his government the most obvious inspiration. Indeed, Trump has already had that effect – The Arctic Lizard, a short story by the Israeli author Etgar Keret, is set during a war which President Trump has started with Mexico and features young soldiers playing a version of Pokemon Go on the battlefield.

It is entirely likely that Trump will continue to have such an effect – mainly because most of us fear what President Trump might do in office, and fear of the future is the main driver of dystopia. But there is another interesting question to ask about dystopias and it’s this: are we already living in one? Imagine someone from 100 years ago waking up in 2017. What would they see? People undergoing the most extreme kinds of surgery in pursuit of beauty or their true gender. Young people taking intimate pictures and sending them to strangers via a worldwide computer network. Parents so fearful that they won’t let their children out to play. It would sound like a dystopia to most people.

But would that traveller from 100 years ago focus on the positives instead? Would they see all the diseases that have been cured, or the fact that millions of ordinary people can travel in the air for next to nothing, or communicate face-to-face with their friends or family anywhere in the world? Would they look at the spread of democracy since the Second World War and think the world had become a better place?

The point is that we are living in both a dystopia and utopia at the same time. For every technological advance, for example, there is a down side: the low pay of the people who make the technology, the waste and pollution involved in its production and the social, cultural and sexual consequences of technology’s proliferation. Equally, one person’s dystopian vision of the future is another’s progress: many people are outraged at being watched on the street by security cameras and emails and internet activity being monitored; for others, these measures it offer solutions to the threat of terrorism.

But could there be yet another factor at play? John Wyndham wrote several novels set in a future-gone-wrong including Day Of The Triffids, in which the world is overrun by killer plants, and Trouble With Lichen, in which a scientist discovers a fungus that can slow down ageing, and fellow science-fiction writer Brian Aldiss described them rather dismissively as “cosy catastrophes”. What he meant was that the hero in Wyndham’s novels, usually British, male and middle-class, always survived the apocalypse, whatever it might be, and would usually have a role to play in rebuilding society.

And isn’t that one of the reasons we love dystopias – for the idea that, after all the chaos or brutality or totalitarianism, in the end something better might rise from it? Aren’t dystopias just another form of hope – the hope that we might have to go through something terrible to find something better?