r/computerscience • • Nov 09 '19

Code is magic

I just had a wonderful realization and I thought I might share. To preface this, I always wanted to go to Hogwarts as a kid and learn magic. I became somewhat disenfranchised with the world as I grew older, but I have recently begun to rekindle a sense of wonder and excitement for the world.

A big part of that has been learning to code. I was thinking about this the other day, and I realized that I have essentially been learning magic by any standard throughout history, and for some reason I take that for granted!

Through a high-level language, we manipulate electrons in order to create symbolic information patterns that can accomplish real tasks - to anyone from any other time in history, if they could see us they would think we were literally witches and wizards.

At Hogwarts the students learn to predict the rough future through magic. I can do the same with data analysis, game theory, and machine learning networks. They can see things from the other side of the world - I just finished coding a security cam for my dorm. They can imbue non-living matter with sentience - robotics. They can manipulate life - bioinformatics - if I had access to the right tools I could literally breed glowing animals. Artificial intelligence adds an even cooler aspect to this given we might soon be able to create sentience from non-sentient matter! Even the bad powers, killing people, controlling people etc are real - consumer programming, psychometric targeting through the internet, drone strikes, malicious hacking, etc.

By extension, everything we are exploring in modern science is really magic. We don't really know how this stuff works or why it works - if you look at the physical constants of the universe they seem somewhat arbitrary. While we do have a good sense of the relational properties between things in reality, we don't know why they are what they are - like electrons! We know the rules that dictate their interaction with other things in reality, but we don't know why they exist the way they do, where they came from, or for that matter where any of this really came from! Somehow through all these layers of abstraction, from basic properties of atoms and forces, to high-level symbolic computation, we manage to actually do stuff, and that stuff is no less absolutely amazing! I don't think it's hyperbole to say that we're all doing real magic.

162 Upvotes

47 comments sorted by

View all comments

46

u/Lexilogical Nov 10 '19

I actually teach beginners this. When you start learning code, you're basically using magical incantations to make things work. You'll learn that "print("Hello World");" makes the words appear on the screen, but you don't know why. Why a semi colon? Why the quotes? Why brackets or print? You learn this later, and it just opens more questions.

But to start, it's magic. When they make a syntax error, I tell them it's the difference between "LeviOsa" and "LeviosA". Once you know what the rules are, you learn what you can change. But even without that knowledge, you can start with safe knowledge and basic spells.

1

u/tcpukl Nov 10 '19

Interesting. I don't think it helps personally. I don't see why it's magic just because you don't understand something. You describe it more like a black box but it's not because literally doing what it day on the tin. The computer is only following the instructions you give it.

1

u/Lexilogical Nov 10 '19

It follows the rule that any sufficiently advanced science is indistinguishable from magic.

So the fact that the computer is a black box that you don't understand the inner workings of is precisely why it's magic. Obviously, you can eventually dig into the science and it's not going to feel that advanced then, but for most people, it's beyond their understanding of how it works, hence magic.

1

u/tcpukl Nov 10 '19

Ok. You've just described the difference between religion and science now.

1

u/Lexilogical Nov 10 '19

Spirituality, not Religion. Religion has a couple more steps involved.

But you know, those who don't believe in magic will never find it.