'Magic as programming' is a relatively common trope - conceptually, the two have a lot in common, and it ties in nicely to old legends about true names etc.
Interestingly, the book jokingly uses sorcery as an ongoing analogy for computing. Programs and algorithms are "spells," computational processes are "spirits" which are conjured and controlled by spells, programming languages are the arcane symbols and runes wizards use to compose their spells, and software bugs are the flawed spells which novice sorcerers often cast (sometimes with disastrous consequences).
Slightly related, since this blog post has inspired me for a while. I would absolutely love to read a whole fantasy-themed "tome" that treats a programming topic as a school of magic. Maybe VR/AR is like illusion/alteration magic. Maybe robotics is the equivalent of summoning, or beast training, or something; maybe electrical engineering is like smithing or crafting. Computer history is lore. And so on...
I wonder if there's anything else out there like this idea? If not, I'll make it happen.
I think it's interesting that people associate programming with magic, but I don't think it's the most enlightening comparison. The actual magic, from my perspective, is social skills and the ability to organize/manipulate people.
People like magic narratives because magic acts as a force multiplier for a single person. The force multiplier in real life is the ability to organize a bunch of other people to do stuff for you. The real Merlin is Steve Jobs or Obama. Just like magic, the ability to do this is generally an inborn talent (theoretically it could be learned, but you can't do anything to change whether it's the kind of thing you like to do, just like you can't do anything to make yourself like golf enough to make yourself practice as much as Tiger Woods).
There are weaknesses to this comparison, of course. In real life when you are using social engineering to further your goals, you become beholden to the network of interests that support you (e.g. politicians, customers). Also, in real life the ability to gain positions of influence is not distributed in any egalitarian manner.
One of the reasons magic is appealing to programmer types, is because they tend to be weaker in these areas, and they wish that they could have access to the same sort of power, but based on the things they are good at (studying tomes, complex incantations) rather than the things they aren't good at (networking, salesmanship). If magic were real, I would definitely be dedicating a lot of time to mastering that, but even knowing the power of politics I am not particularly interested in becoming a politician.
I think you're wrong about that. There were some stories in the 70's about that theme, specifically the parallels between 'magic' in one branch of fiction and programming a computer by interacting with them in some arcane language casting spells in another.
The Well World series would probably qualify as an example of the latter.
I've always thought computer science was the closest thing the real world had to magic, because the essense of software is always automation - you write the spell, so later you just have to invoke it and magic happens.
Whether the actual spell is written in arcane runes or python or encoded as a language model doesn't matter, the essense is the same.
> magic powers have slowly morphed from Gandalf style vague mutterings and the occasional flashlight to basically being programs that a wizard can download, swap, upgrade, etc.
There's a (not particularly good) Russian fantasy book series where the premise is literally that - it's the usual "regular guy ends up in a magic world" kind of set-up, except that the guy is a software developer, and he discovers that magic is a great deal like OOP, and that his skills translate remarkably well. Of course, it's mostly just a Mary Sue story - the author being a Java developer, so far as I can tell - but it's interesting that someone else came up with this metaphor and developed it to that extent.
Reading this thread, it’s funny how universally identified with wizards software engineers are.
It’s not just the arcane knowledge and elaborate incantations. I actually think musicians and athletes possess more of this type of ability. Movie magic to me seems to involve timing and physicality.
I think the real connection is that programming truly is a generalizable tool. A wizard can apply magic to all kinds of general situations. Similarly, a programmer can apply computation generally. A musician can make magical, mind-blowing music but they can’t use music to make a dishwasher.
> I think the real connection is that programming truly is a generalizable tool. A wizard can apply magic to all kinds of general situations. Similarly, a programmer can apply computation generally. A musician can make magical, mind-blowing music but they can’t use music to make a dishwasher.
In Alan Dean Foster's Spellsinger series the protagonist is able to conjure up (on separate occasions) a Jeep and a boat using music magic. A dishwasher wouldn't have been much of a challenge (other than their usual difficulty in getting the result they were aiming for and the fact that there wouldn't be electricity or plumbing to hook it up to).
The article mentions SICP aka the wizard book. In it, there are a lot of metaphors pertaining to magic and spirits, which IMO makes the book much better than if they weren't there. One of the authors of the book, Hal Abelson, famously said:
> There's a good part of Computer Science that's like magic. Unfortunately there's a bad part of Computer Science that's like religion.
This points to perhaps a useful distinction that is to be made here between religion (as in tribalism which leads to holy wars) and mysticism/spirituality/magic (as in deep fascination in search of ultimate truth).
My favorite part of The Magicians series is how complex and real the magic system felt. It was a science just like physics or chemistry. You had to work to get spells right, and creating new spells must have taken many many years of building up abstraction layers and "architecture" so as to allow more complex mechanisms.
Another book that delved into this was "The Wiz Biz" by Rick Cook. Haven't read the second two books in the series yet, but the cool part was when he realized how by combining certain basic spells, he could create something that was essentially a programming language for magic.
Another one that I started getting into (although the writing style isn't my favorite) is Ra [1]. There magic is just like any other engineering discipline in college.
I'd love recommendations for other books where magic is treated like computer science if people have them.
Back to the topic though--where I work our engineers actually have the official title of "Sorcerers." While I'm not an engineer myself, I consider myself fairly tech savvy and have been teaching myself Ruby and RoR over the past couple years to augment my HTML/CSS/JS knowledge. I still have that sense of wonder when I realize realize all that time I saved by abstracting something away to a single function.
Another book that gave me a similar feeling of awe and humbleness was "Code." It starts with wires and relays and explains how computers work from the ground up. At first it was easy to follow, then I got lost on the combinatorics. Hoping to pick it up again, but it really goes to show how much truly arcane knowledge is required to get us to where we are today. I'd wager most developers out there probably could not assemble a full set of logic gates from a NAND gate if you asked them to. To them, hardware and perhaps even low level systems are, for all intents and purposes, magic.
Then you look at the general population of non-tech-savvy people and while they may take things for granted, devices like cell phones, iPads, etc. are truly magical devices. It's like living in a high-magic D&D campaign setting like Netheril where magic is plentiful and embedded into every aspect of life.
> ... I don’t know the “official” name for it, so I just stole the name from a recent reddit post (magical handler functions).
What's the difference between programming "magic" and "using the language to its fullest"?
Wikipedia has an article dedicated to the concept of magical programming. It starts with:
> In the context of computer programming, magic is an informal term for abstraction; it is used to describe code that handles complex tasks while hiding that complexity to present a simple interface. The term is somewhat tongue-in-cheek, and often carries bad connotations, implying that the true behavior of the code is not immediately apparent. For example, Perl's polymorphic typing and closure mechanisms are often called "magic". The term implies that the hidden complexity is at least in principle understandable, in contrast to black magic and deep magic (see Variants), which describe arcane techniques that are deliberately hidden or extremely difficult to understand. However, the term can also be applied endearingly, suggesting a "charm" about the code. The action of such abstractions is described as being done "automagically", a portmanteau of "automatically" and "magically".
I think that "true behavior of the code is not immediately apparent" is the key. The harder it is to figure out how something works, the more likely it is to be viewed as "magic."
Do the magical handlers in this article fit the bill? I'm not so sure. All that's going on is generics applied to functions. True, it's not as common as generics applied to other types. But it's also not fringe.
Maybe as a technique becomes more established, it starts to seem less magical. The author notes:
> Exploring this pattern was an interesting journey. I still can’t tell why it’s more popular than the alternative that contains less magic and gives more flexibility to developers. I can only assume that even Rust developers long for some magic and coolness in their tooling.
Maybe it's more popular because it's now widely used across Rust web frameworks and therefore expected as a convention?
How about Charlie Stross' "Laundry Files" novels, in which magic is mathematics and software is a way of executing your magic quickly (and automating it). You can also do it inside your own head, but since it attracts the attention of Cthuluesque beings, there's a risk attached.
reply