Magic in software development
skilldrick.co.uk
skilldrick.co.uk
class A:
thing1 = 0
thing2 = 0
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.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.
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: http://perl-tricks.blogspot.com/2007/01/flip-flop-operator.h... If you encounter that for the first time you can be really lost trying to figure out how the list construction is occurring and it's not at all obvious what to search for.
I don't care how my car works, just that it gets me to work every day. If it breaks day, I have the choice of learning another craft (car repair) or paying someone that already knows it.
Likewise, if I find a bug in Ruby's base code, I can choose to learn enough about Ruby's code to fix it, or write a bug report and let someone else.
I'm not advocating ignorance, I'm saying it's a perfectly valid option given that we aren't immortal.
I feel a bit uncomfortable leaving it at that though, I always want to know how things are working. But it's not essential.
They just do, and that's good enough.
(I'm not actually ignorant of these things, but it certainly wasn't necessary to learn them. I chose to. It hasn't really helped me much, except to satisfy my curiosity.)
[0] http://www1.idc.ac.il/tecs/ [1] http://csapp.cs.cmu.edu/
CSAPP is unfortunately a hulking $100 hardback, but the authors have put close to 200 sample pages online. Despite looking a bit fearsome, it's extremely clear. And TECS is just awesome--they take you all the way through building (in a hardware simulator) a simple 16bit computer!
I've been toying with the idea of a series of blog posts (or possibly even a separate site) that give a bottom-up explanation of all the stacks we work with - starting with electronics => circuits => computers => programming languages. It would be a way of teaching myself the material and provide a useful resource to others.
Feels like a lot of work though :P
I know that for me personally, having gotten into programming via Ruby rather than an academic CS background, practically everything having to do with Unix felt like magic. What's a process again? How do pipes work? Wtf is TCP? Everything is a file?
I think I'm going to have to get this TECS book (no pun intended) - it sounds just what I'm after. Need to finish SICP first though :P Not enough hours in the day.
> anything below your current level of abstraction that you don’t understand
The function fib is abstracting away all the details of calculating the nth member of the Fibonnaci Numbers. Sadly we are working with machines, not pure mathematical concepts - so when poor Bob will try to do something like [fib x| x <- [1..9999]] with the first implementation and will see his computer grinding to a halt he will have a leaky abstraction.
Basically the law of leaky abstractions just says that if you don't know everything about the abstractions you use you will eventually get hit in the head by one of them.
The proof is so obvious that it borders on a "by definition"... an abstraction is something that has had details removed from it. When those details are still important for some purpose, as they almost always are, your abstraction is leaky. When you suddenly have those purposes, you suffer.
The idea of a non-leaky abstraction is almost nonsensical; if it doesn't leak at all it pretty much isn't an abstraction, it's an isomorphism.
The point here is we're talking about a "principle" of un-intended abstraction leaks, not a "law of leaky abstractions", which sounds more authoritative than it should be and leads to shoddy thinking on the part of people who cite it as some immovable law.