DEV Community

Cover image for The difference between code and magic 🧙‍♀️🧙‍♂️

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

Ben Halpern on April 08, 2020

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 coun...
Collapse
 
robole profile image
Rob OLeary • Edited

"Any sufficiently advanced technology is indistinguishable from magic." by Arthur C Clarke. The addendum is "unless you are an engineer" 😉

Collapse
 
maxart2501 profile image
Massimo Artizzu

"Any sufficiently analyzed magic is indistinguishable from science!" - Girl Genius

Collapse
 
markoshiva profile image
Marko Shiva

Lets simplify there is no magic. If it appears as magic to you you just do not know the data and the process of how it works. :)

Collapse
 
dwd profile image
Dave Cridland

"When a spell doesn't work as intended, it's likely because the castor isn't capable of expressing their intentions effectively."

Yeah, like code.

Collapse
 
ben profile image
Ben Halpern

I think no matter how hard you intend, you're still fighting the nature of complexity.

Magic exists in a universe where complexity is kind of a solved problem.

It's a declarative universe we can only dream of.

Collapse
 
dmfay profile image
Dian Fay • Edited

Magic as conceived in a particular children's book exists in a universe where complexity is kind of a solved problem. Magic as conceived and practiced over the course of human history is itself an attempt to grapple with complexities beyond ordinary understanding and control: health, weather, politics, closeness with the divine.

Aleister Crowley defined magick-with-a-k as 'the Science and Art of causing Change to occur in conformity with Will', and explicitly included such arcane works as banking and potato-growing. Programming is not so different.

Collapse
 
dwd profile image
Dave Cridland

By mentioning complexity and programming in the same context, I'm now forced by ancient tradition to mention No Silver Bullet and ask if you've read it?

Collapse
 
chrisachard profile image
Chris Achard

I've thought a lot about code being magic while watching Harry Potter over the years

Both take intense study and learning to master.
Both require you to say just the right thing to get it to work
Both make the impossible become possible
Both have edge cases and unintended side effects

... I could go on and on 😆

It's definitely an interesting thought that magic works "as intended", and code works "as built"... but it's still the closest thing to magic we have!

Collapse
 
fkhan698 profile image
Faizan Khan

Computers and technology are like a wizarding world. Hackers are like Dark Wizards and learning cybersecurity is like Defense Against the Dark Arts

Collapse
 
integerman profile image
Matt Eland

This has been on my mind recently as I became a bootcamp instructor a month ago. Pretty sure I'm a Ravenclaw, but what does Vue, JavaScript, and REST translate to? Please don't be divination...

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

One of my perennial favorite cartoons is My Little Pony: Friendship is Magic, and I always find it humorous how much unicorn magic in that show does behave like computer code.

  • A spell must be written down in at least one place before it can be cast, although if this "source" exists, it can be cast from memory. (Episode 65, 116/117, 167)

  • Destroying the last copy of the "source" means the spell can no longer be cast. (Episode 116/117)

  • Running a spell without verifying what it will do can have unexpected results. (Episode 65)

  • Unicorn magic is exactly as literal as computer code, and can have unintended results; outcomes have nothing to do with the intentions, only with the technique. (Episode 29, 55, 138, 145)

  • An object (relic) can contain specific magical properties or spells, but those magical properties can only be used in specific ways. You can't make a relic do something it was never intended to do. This is not unlike "compiled code". (Episode 118/119, 194/195, 209)

  • Unicorn magic "just works", although it must be powered either individually by a unicorn, stored energy in a relic, or another energy source. It's not impossible for non-unicorns to use unicorn magic, but that magic will behave the same no matter who is using it.

Collapse
 
slashgear_ profile image
Antoine Caron • Edited


harry

Collapse
 
lbeul profile image
Louis • Edited

@ben little bit off-opic, but is it your first time listening to the story?
Read all of the HP books for the first time a couple of months ago. I'm 22 years old. How was I even able to live without them for so long?

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I thought this post was going a different direction. As in code that is "magic" versus code that is not. The difference being that the former is perhaps inscrutable to the user of it. They just pray that they invoked it correctly with the right incantations (configuration, parameters) and that it doesn't cause any unexpected casualties when run. Non-magic code is obvious what will happen and perhaps boring, even if intricate.

Collapse
 
bhavaniravi profile image
Bhavani Ravi

A production software running for more than 10 years without much of maintenance or bug fixes by the developer. That's magic. No it's not a dream. I know a person who wrote such a software

Collapse
 
highcenburg profile image
Vicente G. Reyes

I've never understood software development from magic. Thank you Ben.

Collapse
 
nickytonline profile image
Nick Taylor

When my code doesn't work, I just scream "Expecto patronum!" and that fixes all my bugs. 😆

Collapse
 
bugmagnet profile image
Bruce Axtens

We want DWIM (Do What I Mean.) We're stuck with DIY (Do It Yourself) and DWYS (Did Wut Yu Sed)

Collapse
 
wellicanjosh profile image
WellicanJosh

It is like doing Math vs English.

Collapse
 
itsjzt profile image
Saurabh Sharma

Magic works as intended. Technology works as built.

😻

Collapse
 
lukegarrigan profile image
Luke Garrigan

Haha loved this!

Collapse
 
lbonanomi profile image
lbonanomi • Edited

Charles Stross got some books out of this idea; I recommend them highly.

Collapse
 
makampos profile image
Matheus de Campos

Cara, faz total sentido!
cheers :D

Collapse
 
not_jffrydsr profile image
@nobody • Edited

None whatsoever. I'm glad these thoughts are reaching the surface of our consciousness' as things are halted temporarily.

Collapse
 
olivierjm profile image
Olivier JM Maniraho

Magic: Code written in meteorjs

Code: Expressjs

Collapse
 
deleteman123 profile image
Fernando Doglio

This is the tale of someone who's had to deal with timezones one too many times.. I feel you, you're not alone! ;)

Collapse
 
tracy_garner_e95d5600c5f3 profile image
Tracy Garner

Sounds like the bug just became a feature. I'll close the bug.