I got into an argument about black magic in a library with someone and have been thinking about this since.
I think "magic" is fundamentally "hidden dependencies" that prevent full reasoning about a piece of code. Like functions that use globals/thread locals to avoid passing in context, or a smart algorithm that makes a decision based on two supposedly independent arguments, or whatever. Authors recognized these dependencies, but think it makes using the library overly burdensome, or think it somehow reflects badly on them, and then go out of their way to obscure them.
It's similar to TFA's definition, but I feel like TFA's definition could just as easily describe spaghetti code which I don't think anyone would consider magic.
Spaghetti code isn't magic by my definition because there's a perfectly sensible methodology you can use to understand what it is doing based on the source code, which is the same as whatever else you do to follow any other bit of code.
The problem with spaghetti code is that the result that you obtain by following that methodology is incomprehensibly large. This is a different problem than not being able to come up with the result at all, or requiring more effort rather than less to come up with the incomprehensible mess.
The result in both cases is incomprehensible code, and that can have similar downstream effects. But how you get there is different.
And, of course, nothing stops a code base from being both highly magical and spaghetti code. There is no lower bound on code quality....
I think "magic" is fundamentally "hidden dependencies" that prevent full reasoning about a piece of code. Like functions that use globals/thread locals to avoid passing in context, or a smart algorithm that makes a decision based on two supposedly independent arguments, or whatever. Authors recognized these dependencies, but think it makes using the library overly burdensome, or think it somehow reflects badly on them, and then go out of their way to obscure them.
It's similar to TFA's definition, but I feel like TFA's definition could just as easily describe spaghetti code which I don't think anyone would consider magic.