HipaticTechnology and more

2026-12-01

Who Wrote the Magic? Programming in Harry Potter

When Harry asks how Lupin knows how to use the Marauder’s Map, Lupin replies, “I helped write it.” Then he identifies himself as Moony. The verb is apt. Four students made a device that could respond to commands, follow people around Hogwarts and insult a particular teacher years after its creators had left school. Tom Riddle used another piece of stationery to achieve something more disturbing. His diary could hold a conversation, choose a memory to show its reader and use a reader to act in the world. [1–3, 6, 7]

Writing a device

A conventional plan records the castle’s layout. The Marauders also gave their parchment a way to respond to events that had yet to happen. They could specify the kind of information it would display, such as a name and a location. The particulars arrived while the Map was in use. When Lupin saw Peter Pettigrew on the grounds, he initially suspected a malfunction. The Map had reported a fact even one of its creators had good reason to doubt. [1, 2]

Lupin’s wording establishes co-authorship. Canon credits Remus Lupin, Peter Pettigrew, Sirius Black and James Potter, but gives no division of labour or account of how they expressed the rules behind the Map. Calling them programmers describes their work at the level we can observe. They designed behaviour that a device could carry out independently of them. [1, 2]

Casting, inventing and building

Harry opens the Map by supplying a wand gesture and a phrase. That resembles invoking an operation through an existing interface. Snape’s invention of Sectumsempra is a different kind of work. He devises a spell that someone else can later cast. Harry’s experience shows how a user can know how to invoke an operation while remaining ignorant of its consequences. [2, 4]

Hermione’s Dumbledore’s Army coins are a clearer example of designing a system with an existing charm. She applies the Protean Charm so that updates to the meeting details on Harry’s coin appear on the others. The coins grow hot when the details change, so recipients can notice without looking. The design combines one authoritative copy, multiple displays and a notification. The books explain which changes propagate while leaving the means of communication unspecified. [5]

What the Map does when Snape intervenes

The ordinary opening and closing commands change what the parchment displays. When Snape tries to reveal what it conceals, the surface instead produces four insults attributed to the Marauders. In software, an event handler can select a prepared response for a particular situation. Four authored replies can explain what happens in this scene. Recognising a caster, recognising the attempted spell and requiring both are three possible selection rules. The encounter alone cannot distinguish them. [2, 3]

The unknown location protocol

The official encyclopedia attributes tracking to the Homonculous Charm. To show a moving name, the Map must somehow detect an occupant, determine a location, resolve an identity and place the result on the plan. Pettigrew is its clearest test case. His appearance changes completely while the Map continues to identify him by name. A visual tracker would need some additional evidence to link a man and a rat to the same identity. [1, 2]

If Hogwarts supplies location observations, the parchment resembles a dashboard that receives updates or requests a fresh view. If the parchment senses the castle directly, it is both instrument and display. A third reading is that the enchantment ties the parchment to the space it depicts so that movement changes the marks without any exchange of messages. Hermione’s coins make remote coordination plausible in this world, but the Map’s moving dots cannot tell us which design it uses. [2, 5]

Riddle’s diary and agency

The diary accepts ordinary writing and replies in context. It can also show Harry a memory. A chat interface is a useful comparison for the written exchange, and an interactive archive captures part of the experience of entering a memory. Riddle chooses what Harry sees, however. A first-hand view of a selected scene can still give the viewer a misleading account of what happened. [6, 7]

The diary’s dealings with Ginny go further. The entity within gains her confidence, possesses her and uses her to reopen the Chamber of Secrets. A persistent software agent is a closer comparison for the way successive conversations serve an objective. The canonical mechanism is a Horcrux containing a fragment of Voldemort’s soul. The diary is the interface through which a version of Riddle can decide what to say and act through another person. [6, 7]

Three kinds of enchanted behaviour

Hermione’s coins propagate a change that someone initiates. The Map responds to commands and changing conditions in the castle. The diary can choose a response in pursuit of a purpose that extends beyond the current exchange. These objects make three ideas visible in the Wizarding World: synchronisation, rules driven by live data, and agency. [2, 5–7]

Lupin helped write a device capable of answering questions its creators could never have answered in advance. Where is Pettigrew tonight? Who is coming down the passage now? Its answers depend on what is happening in the castle. The diary reverses the relationship. Harry writes to learn what happened in the past, while the entity answering him is trying to change what happens next. [1, 6, 7]

References

← Home