Mr. Ollivander, wand maker
and Java programmer
The wand is a very important tool in the lives of witches and wizards of the Harry Potter universe. This is a look at those wands, from the perspective a muggle computer programmer, using actual examples from the Harry Potter books.
I believe the magical wands of Harry Potter’s world could actually be tiny hand-held computers. The processors in these computers are magical-creature-based, as opposed to muggle computers, which are silicon-based. From the way they are used, we can reasonably infer that the operating systems of these computers are written in the object-oriented programming language Java.
The wand’s command interface is voice activated, and commands are comprised of objects and methods. Many objects and methods have been preprogrammed into the wand. These built-in objects and methods are named mostly in Latin.
For example, in The Sorcerer’s Stone, on the Hogwarts Express, Hermione fixes Harry’s glasses with the charm “oculus reparo”. Internally in the wand, that charm is represented this way in Wand Java:
In this case, the message reparo() (to repair) is sent to the object oculus (eye-glasses), causing the glasses to be repaired. Since most of the internal objects are dervied from the same base class, most of these pre-programmed objects could be sent this reparo() message.
There is also the possibility of an unvoiced object that is derived by pointing the wand at something physically. In The Goblet of Fire, Hermione simply points her wand at a broken window and says “reparo”. Internally, the wand is sending the reparo() message to the derived target of the wand pointer:
Also in The Sorcerer’s Stone, in Professor Flitwick’s Charms class, Hermione demonstrates the proper way to do the levitation charm, “wingardium leviosa”:
“Wingardium” is the feather object, and sending the leviosa() message to it causes the object to be levitated.
Under certain conditions, the pointer object and the voiced object can be evaluated together. For example, later in The Sorcerer’s Stone, Ron points his wand at the troll’s club and yells “Wingardium Leviosa!” In this case, the voiced object, “wingardium”, is up-casted to the derived pointer object, the troll’s club, which is lifted up above the troll’s head:
Pointer club = new Pointer.getTarget();
Two methods, sonorus(), which causes your voice to become greatly amplified, and quietus(), which turns it off, are used with the internally derived pointer object, but are only valid when the derived pointer object of the wand is your own throat:
These functions throw an exception if you try something like pointing your wand at a Slytherin and commanding “Quietus!” Exceptions in Wand Java are nasty, and cause the wand to make a big “Bang!” and singe anything that happens to be too close to the pointer.
There are also some built-in methods which do not work on external objects like all the other methods do, they work on your own wand instead:
The lumos() function causes your wand to act as a flashlight, and the nox() function turns lumos() off. “Nox” in Latin means “night”. But, in technical jargon it could also mean “negate operation”, and presumably nox() could be used to negate any other currently operating feature of the wand, although we only have documented use of it in conjunction with lumos().
Some methods require attributes. For example, in The Prisoner of Azkaban, Professor Lupin teaches Harry and the students how to deal with a Boggart, by pointing your wand at it, thinking of something funny, and yelling “Riddikulus!”. Internally, the command is represented like this:
User image = new User.getTarget(MEMORY);
Here, the internally derived target of the pointer object is sent the riddikulus() message, with the image the user is concentrating on as an attribute, which results in the Boggart being turned into the ridiculous thing. The global constant MEMORY causes the getTarget() method of the User object to retrieve what the user is remembering. Other global constants which can be applied in this manner are SEE (retrieve what the user is looking at) and IMAGINE (retrieve something the user is imagining).
Some methods are so handy that they are also provided as static, so that even if you don’t know or can’t remember a built-in object’s latin name, or you can’t directly point your wand at it, you can apply the method to any object using its name in English as an attribute. For example, in The Goblet of Fire, to fly around the dragon in the first task of the Tri-Wizard Tournament, Harry summons his racing broomstick by using the charm “accio firebolt!”. “Accio” is the summoning method, and internally in Wand Java, that command looks like this:
Some of the other built-in methods in the wand that are used similarly to the methods described above are:
aparecium() – appear
confundo() – confuse
crucio() – torment (one of the unforgiveable curses)
deletrius() – eradicate
engorgio() – enlarge
ennervate() – revive from stun
incendio() – create fire at target
obliviate() – erase memory of target
reducio() – reverses engorgio
Finally, there is one special built-in method which only affects another wand or other wands in the derived pointer target:
Professor Snape uses the Finite Incantatum spell in The Chamber of Secrets to put an end to a duel betwen Harry and Malfoy that gets out of hand. The finiteIncantatum() method causes the operating system of the wand or wands in the target of the pointing object of your wand to reboot.
Hilarious and very informative article. It actually serves as a nice primer for people unfamiliar with basic programming of standard Muggle computers as well as wands. Good job!
Very funny. I wish J.K. could see that. Suddenly understood a great deal more. And was entertained at the same time. Keep up the good work!
This is a work of hilarious genius! Just a couple of points, though: 1) I think in your club example you should have some more brackets: ((club)wingardium).leviosa(); That is, if you mean to call the leviosa() method on the Club object that you have cast from wingardium. Oh, and since Club is a class, it should be capitalised. As written you would be casting whatever wingardium.leviosa() returns, to a Club. 2) I think you’ll find that the finiteIncantatum() method can also be called on a running instance of a Spell object. Thus we would have: Pointer.getSpell().finiteIncantatum(); I refer you to the battle in the Ministry from Order of the Phoenix, when Neville is dancing the Tarantella. I’d check the JavaDoc for this, but java.hogwarts.ac.uk appears to be offline at the moment.
That was great! I can’t really add to the praise already given, but I do have one question: How do nonverbal spells work? Would it sense when you’re casting a spell, then do this: User.getTarget(MEMORY); and pass the result of that into another function that runs the right spell?
Yes, this article was written before non-verbal spells were documented in Half-Blood Prince. The syntax would be: User spell = new User.getTarget(SPELL); spell.castNonVerbal();
Oh nice, that does make sense too. Great article, I shared it with my few friends who would understand it.:D
Well, I do think that wands might be minute computers. And I really like the syntaxes you’ve given.
Well, the wands could act like miniature computers but could not be miniature computers. Remember, no electronic things work inside Hogwarts.
Well… not miniature muggle computers, anyway. We know muggle electronics don’t work at Hogwarts. We don’t know it’s not possible a Wizard could get around that…
Unlikely. By this article, only wandmakers could create new spells. The Half Blood Prince, Snape, was not a wandmaker, but he made lots of new spells.
Nowhere in the article did it say that the programming of a wand was in something like ROM (read-only-memory). A wand wouldn’t be very useful at all if it couldn’t learn new spells (recieve new programming). It’s most likely voice-based commands that allow you to add new spell syntax…
The question needs to be asked.. How would one go about “upgrading” a wand? What if you found yourself in a job that required a lot of charms work but your wand was “hardwired” for transfiguration? Could there be a market for aftermarket add-ons?