I'm going to mention what I think the other big definition of magic is, because I haven't seen it spelled out yet. It's when there is something that is occurring in code but you have no handle on how to follow it back to where the magic occurred. For instance, you write a class that looks something like<p><pre><code> class A:
thing1 = 0
thing2 = 0
</code></pre>
but somewhere in between your definition and your usage, the class is suddenly an ORM mapping onto a database. As cool as that may be, just looking at class A, you have no idea where to look for that behavior. If you had to subclass something to get that behavior, you could have looked there; if you had to call a function on the class to get this behavior, you could follow it back from there, but when you have this sort of magic you can't. The forensic trail has gone cold.<p>If you think about it, you can see how the two definitions are related; this sort of magic tends to stay something you don't understand because you don't just naturally pick it up over time, you must make great effort to figure out what the problem is. But it's a different problem with a different solution, certainly.<p>Generally the two places this magic lives is in some all-encompassing framework, and in the language itself. Perl has numerous magical constructs, some of which turn out to be very difficult to even search for in the docs because it isn't even obvious what the operator is. The flip-flop operator comes to mind: <a href="http://perl-tricks.blogspot.com/2007/01/flip-flop-operator.html" rel="nofollow">http://perl-tricks.blogspot.com/2007/01/flip-flop-operator.h...</a> If you encounter that for the first time you can be <i>really lost</i> trying to figure out how the list construction is occurring and it's not at all obvious what to search for.