The difference between code and magic 🧙‍♀️🧙‍♂️

Ben Halpern - Apr 8 '20 - - Dev Community

I've been listening to the Harry Potter audiobooks, as one does.

There is a plot point in Harry Potter and the Deathly Hallows where Harry is counting down the days until he turns 17 when he is no longer under surveillance for use of under-age magic. It's a spell the magical community places on young magicians to maintain law and order, and perhaps a bit of Orwellian control.

There is a moment where Ron wishes Harry "happy birthday" early in the morning, and it immediately clicks to Harry that he can now use magic without detection! (They are currently on the run from Death Eaters so this is important).

Harry immediately casts a spell in celebration.

Me, the software developer, not being able to help myself, gets nervous. I literally think to myself "What if the curse is time zone sensitive, what if it's based on UTC, what if Harry was born later in the day and he hasn't actually hit 17 yet? What about leap years? Why doesn't Harry leave himself a buffer of certainty before casting a needless spell!"

And then I think to myself "that's not how magic works at all, that's how computers work." Technology and magic are not too different a lot of the time, but this is a significant distinction: Magic works as intended. Technology works as built.

In general, if Harry is 17, for all intents and purposes, the spell will be lifted. That's just how the universe works. When a spell doesn't work as intended, it's likely because the castor isn't capable of expressing their intentions effectively. This is why focus and nuance are such an important thing when casting. But when a wise witch or wizard casts a spell, it's going to work to their intentions.

Code just works how it works, we have off-by-one errors, we have time zones, we have string interpolation, we race conditions. Code does what it was built to do, but it's not magic, it doesn't just work as intended. No amount of wisdom makes code work as intended unless it is meticulously crafted to work this way. The closer it is to work as intended without the burden of edge cases, the closer it is to magic, but our code will never have the kind of guarantees of effectiveness that magic does. That's the deal.

Happy coding 🧙‍♀️🧙‍♂️

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player