Utopia and dystopia are genres of speculative fiction that explore social and political structures. Utopian fiction portrays the setting that agrees with the author's ethos, having various attributes of another reality intended to appeal to readers. Dystopian fiction (sometimes combined with, but distinct from apocalyptic literature) is the opposite: the portrayal of a setting that completely disagrees with the author's ethos. Many novels combine both, often as a metaphor for the different directions humanity can take, depending on its choices, ending up with one of two possible futures. Both utopias and dystopias are commonly found in science fiction and other speculative fiction genres, and arguably are by definition a type of speculative fiction.
The word utopia was first used in direct context by Sir Thomas More in his 1516 work Utopia. The word utopia resembles both the Greek words "no place", "outopos", and "good place", "eutopos". In his book, which was written in Latin, More sets out a vision of an ideal society. As the title suggests, the work presents an ambiguous and ironic projection of the ideal state. The whimsical nature of the text can be confirmed by the narrator of Utopia's second book, Raphael Hythloday. The Greek root of Hythloday suggests an 'expert in nonsense'. An earlier example of a Utopian work from classical antiquity is Plato's The Republic, in which he outlines what he sees as the ideal society and its political system. Later examples can be seen in Samuel Johnson's The History of Rasselas, Prince of Abissinia and Samuel Butler's Erewhon, which uses an anagram of "nowhere" as its title. This, like much of the utopian literature, can be seen as satire; Butler inverts illness and crime, with punishment for the former and treatment for the latter.
A dystopia is a society characterized by a focus on that which is contrary to the author's ethos, such as mass poverty, public mistrust and suspicion, a police state or oppression. Most authors of dystopian fiction explore at least one reason why things are that way, often as an analogy for similar issues in the real world. Dystopian literature is used to "provide fresh perspectives on problematic social and political practices that might otherwise be taken for granted or considered natural and inevitable". Some dystopias claim to be utopias. Samuel Butler's Erewhon can be seen as a dystopia because of the way sick people are punished as criminals while thieves are "cured" in hospitals, which the inhabitants of Erewhon see as natural and right, i.e. utopian (as mocked in Voltaire's Candide).
Dystopias usually extrapolate elements of contemporary society and this can be read as political warnings. The 1921 novel We by Yevgeny Zamyatin predicts a post-apocalyptic future in which society is entirely based on logic and modeled after mechanical systems. George Orwell cited We as an influence on his Nineteen Eighty-Four, a novel about Oceania, a state at perpetual war, its population controlled through propaganda. Big Brother and the daily Two Minutes Hate set the tone for an all-pervasive self-censorship. Aldous Huxley's novel Brave New World started as a parody of utopian fiction, and projected into the year 2540 industrial and social changes he perceived in 1931, leading to industrial success by a coercively persuaded population divided into five castes; the World State kills everyone 60 years old or older.
Anthony Burgess's 1962 novel A Clockwork Orange is set in a future England that has a subculture of extreme youth violence, and details the protagonist's experiences with the state intent on changing his character at their whim. Margaret Atwood's The Handmaid's Tale describes a future United States governed by a totalitarian theocracy, where women have no rights. Examples of young adult dystopian fiction include The Hunger Games by Suzanne Collins, The House of the Scorpion by Nancy Farmer, Divergent, Insurgent by Veronica Roth, The Maze Runner by James Dashner, Legend by Marie Lu, and Delirium by Lauren Oliver. Video games often include dystopias as well; notable examples include the Fallout series, BioShock, and the later games of the Half-Life series.
History of dystopian fiction
The history of dystopian literature can be traced back to reaction to the French Revolution of 1789, and the prospect that mob rule would produce dictatorship. Until the late 20th century it was usually anti-collectivist. Most experts in literature agree that the origins of dystopian fiction are rooted strongly in utopian fiction. Dystopian fiction emerged as a response to utopian fiction, a good example is Edward Bellamy’s 1888 best-selling novel Looking Backward, about a socialist utopia set in 2000. Dystopian fiction usually has satirical elements interwoven in it. It is based on imagined scenarios rather than real ones, but they are incorporated into storylines that readers can relate to the present.
Coming to the historical background of dystopian fiction, it is almost impossible to talk about it without referring to the historical background of utopian fiction. Utopian texts often ‘made promises’, while dystopian texts ‘issued warnings'  Utopian writers based their writing on perfect patterns and organized societies; however, at the outset of the 19th century, writers began to recognise the impossibility of such utopic scenarios and an anti-utopic wave gripped literature. The beginning of technological dystopian fiction can be traced back to E.M. Forster’s (1879-1970) "The Machine Stops". Forster is widely accepted as the 'pioneer of dystopian literature.'
After Forster's "The Machine Stops", more dystopian literature emerged, such as We and Brave New World. M Keith Booker states that these fictions are "the great defining texts of the genre of dystopian fiction, both in [the] vividness of their engagement with real-world social and political issues, and in the scope of their critique of the societies on which they focus."
Another very important figure in Dystopian Literature is H.G. Wells, whose work The Time Machine (1895) is also widely accepted as one of the best prototypes for dystopian literature. Post World War II, even more dystopian fiction was produced. These works of fiction were interwoven with political commentary: the end of World War II brought about fears of an impending Third World War and a consequent apocalypse, which began to be reflected in these works. There is a fine line between apocalyptic literature and dystopian literature, however the difference is mostly negligible. The most striking feature of Dystopian fiction is its dynamic and ever-changing character. This is primarily because different social and political situations around the world influenced different dystopic writers. This is why the entire body of dystopian fiction is incredibly diverse and heterogenous. Works of this genre spanning different times and different years are different as authors carefully observed what was going on around them and then wrote on the issues that concerned them deeply, often putting a different spin on things.
Today, Dystopian fiction draws not only on several topics that older dystopic works talked about such as totalitarian governments and anarchism, but also on topics that are widely talked about in today's society such as pollution, global warming, climate change, health, the economy and technology. Dystopian fiction has also found its way to the young adult (YA) genre of literature, as opposed to the more adult audience that it was originally meant for.
Jonathan Swift's Gulliver's Travels is sometimes linked with utopian (and dystopian) literature, because it shares the general preoccupation with ideas of the good (and bad) society. Of the countries Lemuel Gulliver visits, Brobdingnag and Country of the Houyhnhnms approach a utopia; the others have significant dystopian aspects.
Many works combine elements of both utopias and dystopias. Typically, an observer from our world will journey to another place or time and see one society the author considers ideal, and another representing the worst possible outcome. The point is usually that the choices we make now may lead to a better or worse potential future world. Ursula K. Le Guin's Always Coming Home fulfils this model, as does Marge Piercy's Woman on the Edge of Time. In Starhawk's The Fifth Sacred Thing there is no time-travelling observer, but her ideal society is invaded by a neighbouring power embodying evil repression. In Aldous Huxley's Island, in many ways a counterpoint to his better-known Brave New World, the fusion of the best parts of Buddhist philosophy and Western technology is threatened by the "invasion" of oil companies. As another example, in the "Unwanteds" series by Lisa McMann, a paradox occurs where the outcasts from a complete dystopia are treated to absolute utopia, and therefore believe that those who were privileged in said dystopia were actually the unlucky ones.
In another literary model, the imagined society journeys between elements of utopia and dystopia over the course of the novel or film. At the beginning of The Giver by Lois Lowry, the world is described as a utopia, but as the book progresses, the world's dystopian aspects are revealed.
In ecotopian fiction, the author posits either a utopian or dystopian world revolving around environmental conservation or destruction. Danny Bloom coined the term "cli fi" in 2006, with a Twitter boost from Margaret Atwood in 2011, to cover climate change-related fiction, but the theme has existed for decades. Novels dealing with overpopulation, such as Harry Harrison's Make Room! Make Room! (made into movie Soylent Green), were popular in the 1970s, reflecting the popular concern with the effects of overpopulation on the environment. The novel Nature's End by Whitley Strieber and James Kunetka (1986) posits a future in which overpopulation, pollution, climate change, and resulting superstorms, have led to a popular mass-suicide political movement. Some other examples of ecological dystopias are depictions of Earth in the films Wall-E and Avatar.
While eco-dystopias are more common, a small number of works depicting what might be called eco-utopia, or eco-utopian trends, have also been influential. These include Ernest Callenbach's Ecotopia, an important 20th century example of this genre. Kim Stanley Robinson has written a number of books dealing with environmental themes, including the Mars trilogy. Most notably, however, his Three Californias Trilogy contrasted an eco-dystopia with an eco-utopia, and a sort of middling-future. Robinson has also edited an anthology of short ecotopian fiction, called Future Primitive: The New Ecotopias.
There are a few dystopias that have an "anti-ecological" theme. These are often characterized by a government that is overprotective of nature or a society that has lost most modern technology and struggles for survival. A good example of this is the novel Riddley Walker.
Another subgenre is feminist utopias and the overlapping category of feminist science fiction. Writer Sally Miller Gearhart calls this sort of fiction political: it contrasts the present world with an idealized society, criticizes contemporary values and conditions, sees men or masculine systems as the major cause of social and political problems (e.g. war), and presents women as equal to men, having ownership over their reproductive functions. 
Utopias have explored the ramification of gender being either a societal construct or a hard-wired imperative. In Mary Gentle's Golden Witchbreed, gender is not chosen until maturity, and gender has no bearing on social roles. In contrast, Doris Lessing's The Marriages Between Zones Three, Four and Five (1980) suggests that men's and women's values are inherent to the sexes and cannot be changed, making a compromise between them essential. In My Own Utopia (1961) by Elisabeth Mann Borgese, gender exists but is dependent upon age rather than sex — genderless children mature into women, some of whom eventually become men. Marge Piercy's novel Woman on the Edge of Time keeps human biology, but removes pregnancy and childbirth from the gender equation by resorting to assisted reproductive technology while allowing both women and men the nurturing experience of breastfeeding.
Utopic single-gender worlds or single-sex societies have long been one of the primary ways to explore implications of gender and gender-differences. One solution to gender oppression or social issues in feminist utopian fiction is to remove men, either showing isolated all-female societies as in Charlotte Perkins Gilman's Herland, or societies where men have died out or been replaced, as in Joanna Russ's A Few Things I Know About Whileaway, where "the poisonous binary gender" has died off. In speculative fiction, female-only worlds have been imagined to come about by the action of disease that wipes out men, along with the development of technological or mystical method that allow female parthenogenetic reproduction. The resulting society is often shown to be utopian by feminist writers. Many influential feminist utopias of this sort were written in the 1970s; the most often studied examples include Joanna Russ's The Female Man, Suzy McKee Charnas's The Holdfast Chronicles. Such worlds have been portrayed most often by lesbian or feminist authors; their use of female-only worlds allows the exploration of female independence and freedom from patriarchy. The societies may not necessarily be lesbian, or sexual at all — Herland (1915) by Charlotte Perkins Gilman is a famous early example of a sexless society. Charlene Ball writes in Women's Studies Encyclopedia that use of speculative fiction to explore gender roles has been more common in the United States than in Europe and elsewhere.
Utopias imagined by male authors have generally included equality between sexes, rather than separation.
Feminist dystopias have become prevalent in young adult fiction, or YA, in recent years, focusing on the relationship between gender identity and the teenager. For instance, the Birthmarked trilogy by Caragh M. O'Brien focuses on a teenage midwife in a future post-apocalyptic world while the second novel in the series places the teenage heroine Gaia in a matriarchy.
Étienne Cabet's work Travels in Icaria caused a group of followers to leave France in 1848 and travel to the United States to start a series of utopian settlements in Texas, Illinois, Iowa, California, and elsewhere. These groups lived in communal settings and lasted until 1898.