Harry Potter will be eleven forever.

Despite the million or so words that follow the event of his eleventh birthday, in which he grows and masters spells and vanquishes his enemy, the real magic of JK Rowling’s Harry Potter series—the storybook magic, that is—is contained within the first two acts of the very first book.

In literary studies, the action in stories is discussed in the present tense: ‘Harry lives with his aunt and uncle, until he discovers that he is a wizard.’ This reflects the idea that texts are temporal experiences rather than physical objects; that they continue to exist in the present, coming into being each time they are read. As long as there is a reader to open a copy of Harry Potter and the Philosopher’s Stone, McGonagall will always be watching Privet Drive, still as a statue; Dumbledore will perpetually arrive to darken the street lamps; and the Dursleys will forever be the worst sort of muggles (thank you very much).

The start of a story is an inward breath; the beginning of the second act is an exhalation of wonder, a collective ‘ooohhh’. That is how conventionally-plotted novels work, and children—as what we might call, after critic Stanley Fish, an ‘interpretive community’—understand this convention better than anyone. It is a magic trick, performed by the writer via deployment of certain plot points and methods of characterisation. Any writer can learn to do it, although some pull it off better than others; and readers, for their part, learn it too, and become receptive to it as an affective strategy. The sensation created in this instance is one of anticipation fulfilled.

How does the trick work? In the beginning, the story sets up a situation in which change is required. Harry Potter is homeless in a sense, relegated to the cupboard under the stairs and denied a meaningful place in the Dursley family; he is neglected and abused, and like any child who is neglected and abused, deserves none of it. The second aim of the opening act is to create in the reader the hope for that change. Harry, with his odd powers, is not completely vulnerable. Those powers connect in an as-yet-unexplained way with the letter from Hogwarts, which appears like a chink of light to threaten the darkness of his entrapment.

Children know all about hope. They are experts in longing. Nothing has happened to them yet, or so it seems. Even if it has, it’s nowhere near as much as is going to happen, and so anticipation is more than familiar to them: it’s a state of being. Childhood, so they are told, is an opening act in itself, and their dreams for what follows are still wild.

In the meantime, they have a keen sense of injustice, which serves to make Harry’s plight all the more urgent. When you have little agency—when most of life’s decisions are visited upon you by other, bigger people—then you are very alive to what is fair. The cake must be sliced just so. Children read the fine print, hunting not always for loopholes—as it might appear to frustrated adults—but for the very letter of the law. They have a deep investment in understanding what governs them, in working out the exact location of the boundaries that contain them so that they can optimise their movement in that space, and yes, ultimately plan their escapes.

The 1971 film version of Roald Dahl’s Charlie and the Chocolate Factory explicitly acknowledges this fine print. When the five golden ticket winners enter the factory, they are required to sign a contract that is both impossible to read and designed to protect Willy Wonka’s interests, not their own. But the price for refusing to sign on the spot is refusal of entry to the factory, and the parents’ suspicion of it is swiftly trampled by Veruca Salt, whose disdain for restraint of any kind will soon lead to her demise. Charlie himself signs only after checking with Grandpa Joe, who gleefully declares that they have ‘nothing to lose’.

Contemporary readers might wince at the brutality of the judgement meted out in Charlie and the Chocolate Factory, but children are still warned severely against being greedy, spoilt and uncouth, and still recognise in these characters a grotesque exaggeration of what they are told is their own innate monstrosity. Charlie, who—the book tells us—gets one bar of chocolate a year and knows how to make it last for more than a month, is the only one well-versed in denial. This, in a way, is his own magical power, its potential yet to be fully realised.

Philosopher’s Stone is in the same tradition as Charlie and the Chocolate Factory, with its downtrodden, impoverished hero. The letter from Hogwarts is Harry’s golden ticket, frantically desired but always out of reach—until it isn’t. Each story creates a potent build-up of anticipation, prolonging arrival in the adventure world in such a way that the reader’s yearning for it ratchets up to a pitch equal to the protagonist’s. Dahl’s opening act imbues the chocolate factory, and Wonka himself, with a folkloric significance via tales of his brilliance and mysteriousness. These are interleaved with the ever-more-feverish hunt for the golden tickets and the pitiless fact of Charlie’s slow starvation, so that the reader longs to see inside the factory as much as the ticket-hunters do, as well as understanding that Charlie needs—indeed, deserves—a golden ticket more than anyone.

In Philosopher’s Stone, Harry’s first trip to Diagon Alley acts as a narrative bridge between the ordinary world and the wonder of Hogwarts. The reader is initially focused on Harry’s escape from the Dursleys; now the focus shifts to where he is going. As he collects each item on his list of school supplies he encounters a new, tantalising facet of the wizarding world, and the reader’s anticipation grows alongside his own—one cauldron, owl and wand at a time.

The children in both stories are entering territory more perilous—and therefore thrilling—than they first imagined. They are alerted to this in various ways, but still they race wide-eyed into their adventures—towards something marvellous but also away from something, the lives they had before—and they will find out what happens when you disregard the fine print: that you could be signing up for anything.

Because while Hogwarts and the chocolate factory are both as astonishing as the reader and the protagonists hope, neither place is safe. Spells and potions can be used to do harm; chewing gum and fizzy drinks have unwanted consequences. In both stories there are adults who have to be outwitted, villainous in varying degrees from cowardly or self-serving to violently malicious. Alongside Slugworth and Voldemort are galleries of misguided egos: the indulgent, know-it-all parents of the other golden ticket winners; teachers like vain Gilderoy Lockhart; or the blinkered Cornelius Fudge, the wizarding world’s very own version of an office-holding climate denier. At the centre of these stand the powerful and eccentric figures of Willy Wonka and Dumbledore, both benign and dangerous at the same time.

Children’s literature can in this way tread a fine line between the familiar and the radical. The form of the novel is established, but the adventures within it are not. Books, therefore, are a safe space in which to try out escape. This suits kids, who are simultaneously seeking two oppositional things: comfort and challenge.

A writer does ask: what can I get my reader to feel and how will I get them to do it? Commercially successful writers certainly ask this, for the feels created by stories are what sell in the marketplace for fiction. Conventional structure is a tried-and-tested way to generate them, but what takes place within that needs to be fresh enough to thrill. There exists a tension between the conventions of the form—itself a kind of contract with the reader, representing what is ‘known’—and the content. Form creates a boundary to contain what is ‘unknown’, those fantastical and precarious new realities.

In both its book and film iterations, Charlie and the Chocolate Factory presents a kind of dissertation not on rule-breaking, as it might first appear, but on self-mastery. You can, of course, follow a rule without carrying any moral investment in it or even appreciating why it’s a rule in the first place. But this is not a story about the advantages of blind obedience. In the book, Charlie wins by doing a Bradbury of sorts—by being the last child standing after the other four have fallen prey to their own short-sighted, childish urges, enabled by their parents’ deficiencies. The reader knows, however, that Charlie has outlasted them because he would never behave like that. The film introduces some nuance and tension by having Charlie break a rule too, then giving him the chance to redeem himself by returning the gobstopper—the ultimate act of self-denial. In this way, Charlie’s special power fulfils its potential at last.

It is a story about just desserts—about the long game, not short-term gratification. A story for strategists and escapologists. The glass elevator bursts through the ceiling; all Charlie’s problems are solved; his wildest dream comes true. But Charlie has earned his escape. First you master yourself; then you get to take charge. The journey is long and arduous, but the payoff is sweet.

Harry Potter does not break any serious rules of Hogwarts blindly, but only where he sees a dangerous adult deficiency, something he is far better versed in than Charlie, whose loving home mitigates against his other privations. Harry acts not in wisdom but out of curiosity, courage and instinct. The prize for those actions is wisdom, although he will take much longer to earn his than Charlie. The reader must first watch Harry grow up for real, in an approximation of real time, over the course of six more books. In contrast, an adventure like Charlie and the Chocolate Factory is a fantasy of early freedom.

And what will children do when they earn their freedom? Write their own rules, of course. ‘When I grow up/I will eat sweets every day on my way to work/and I will go to bed late every night’ daydream the characters in another Dahl-inspired work, Matilda the Musical.

The challenge is all contained in the early part of the story. This is where we might ask of a book: is it a worthy challenge? Not in the sense that it is weighed down by its own good intentions, but worthy of children.

A story worthy of children is not didactic, but a training ground for the mind. A tour of the fine print, in which the consequences of actions can be explored without really turning into a blueberry or having your soul sucked out by a Dementor. A place in which to escape, briefly, the boundaries of childhood and exercise all that wild longing.