And that’s not just some long-haired hippie’s opinion. Wednesday night we had a mini-geek night at work and we got onto the topic of whether or not (code) magic was good or bad. It was a great conversation and because Ade doesn’t have a blog (when are you going to get one?), I thought I’d write about it.
I struggled at first to work out what we meant by ‘magic’ and we somehow concluded at some point, for it to be ‘the unknown’. For instance, when you plug stuff into the Rails framework, there’s some sort of ‘magic’ going on to hook it all up. The focus of the discussion was really about whether or not we thought magic was good or not.
To actually substitute our other meaning, ‘the unknown’ for magic makes the question a very strange one – ‘Is the unknown good or bad?’
My attempt at answering this question was that the concept of magic is not good or bad, but whether or not the attempt at magic is good or bad. In general, I personally like magic because it makes my life easier. I shouldn’t have to understand how the compiler, for instance, turns code I write into bytecode every time I want to do something. I like the fact that it just works and that’s how it is. The abstraction or illusion holds true every time I run it and I can depend on it to work day in and out.
I consider magic good if it doesn’t require you to understand it. Bad magic on the other hand is bad because it forces you to work out how it works, and that need, let alone the experience, is generally traumatising. It’s like a magician’s illusion failing us because you have to go behind the scenes to understand all the little tricks that made it work. What can make it worse is if it is difficult to investigate how it works such as the source code not being available, or horrible code that’s hard to read, or an abstraction that just doesn’t work.
All of this is circumstantial and really depends on how well the magic was built. If the magic works all the time (and generally that’s because the abstraction is sound) and it does all the things that you need, then I think it’s a good thing.