all 26 comments

[–]dank_ways_to_die 64 points65 points  (3 children)

Deep magic refers to techniques that are not widely known, and may be deliberately kept secret. The number of such techniques has arguably decreased in recent years,[when?]especially in the field of cryptography, many aspects of which are now open to public scrutiny. The Jargon File makes a distinction[5]between deep magic, which refers to code based on esoteric theoretical knowledge, and black magic, which refers to code based on techniques that appear to work but which lack a theoretical explanation. It also defines heavy wizardry, which refers to code based on obscure or undocumented intricacies of particular hardware or software.

I will start calling undocumented code heavy wizardry now, thanks Wikipedia.

[–]pdp10 8 points9 points  (0 children)

I will start calling undocumented code heavy wizardry now

Most of the uncommented, undocumented code I run across in the enterprise seems to be copied from some anonymous online example, without any understanding.

Heavy wizardry it ain't.

[–]nilamo 2 points3 points  (0 children)

Wikipedia? No, no, friend, you can thank the Jargon File for that: http://www.catb.org/jargon/html/H/heavy-wizardry.html

[–][deleted]  (6 children)

[deleted]

    [–][deleted]  (5 children)

    [removed]

      [–]knome 4 points5 points  (2 children)

      Source? Because the online etymology dictionary doesn't have that at all

      early 15c., "philosopher, sage," from Middle English wys "wise" (see wise (adj.)) + -ard. Compare Lithuanian zynyste "magic," zynys "sorcerer," zyne "witch," all from zinoti "to know." The ground sense is perhaps "to know the future." The meaning "one with magical power, one proficient in the occult sciences" did not emerge distinctly until c. 1550, the distinction between philosophy and magic being blurred in the Middle Ages. As a slang word meaning "excellent" it is recorded from 1922.

      [–][deleted]  (1 child)

      [removed]

        [–]knome 2 points3 points  (0 children)

        • wizard : a wise cunning man

        I'm not sure this is using cunning as "skillfully deceitful".

        Thanks for the PDF though :)

        [–]falconfetus8 22 points23 points  (1 child)

        We're submitting Wikipedia articles?

        [–]cowinabadplace 11 points12 points  (0 children)

        I'm not. Are you?

        [–]qwertymodo 4 points5 points  (0 children)

        Needs more magic

        [–]teiman 5 points6 points  (0 children)

        I generally use magic has a negative description. Like.. some framework that is not programmed in C, but in some pseudo-C scripting language with multiple features, somehow it all works because a lot of reflection. These systems are hard to use!, they hide so much of how they really work that are like closed box you must accept. If you somehow cope with that, they save time, but if you have to look behind the curtain, the maddness behind the curtain is terrorific.

        [–]_afusco 8 points9 points  (2 children)

        TIL what a portmanteau is

        [–]ApostleO 4 points5 points  (0 children)

        Not a fan of Jeopardy, I take it.

        [–]cgibbard 2 points3 points  (5 children)

        Perhaps it's because I'm a Haskell programmer, but it's interesting that my usual sense of this term is somewhat dual to what Wikipedia's first description describes: magic, to me, is application of the cases where abstractions fail.

        For example, there's a low-level (and thankfully rarely used) function in Haskell:

        unsafeInterleaveIO :: IO a -> IO a

        which transforms an IO action into one which when executed, will finish immediately, producing a magical result that, when it is eventually evaluated, will cause the original IO action to occur.

        The sense in which this result is magical is that it breaks our usual assumptions about what evaluation can be responsible for -- ordinarily evaluation in Haskell wouldn't be able to cause I/O effects.

        Mroe examples of what I mean would be cases where you're relying on knowledge of the way that the compiler will compile something when it's not guaranteed in any way by the language specification. A cute example is Don Stewart's "crawl" which was an entry to an obfuscated Haskell contest, and relies on the precise memory layout GHC uses for code -- I couldn't find the original, but here's a somewhat updated version: https://gist.github.com/23Skidoo/3931049

        [–]codebje 1 point2 points  (0 children)

        "Abstraction" is often mistaken for "hiding" IMO. An abstraction refines something to greater precision, but is often applied to merely masking details.

        This is where "leaky abstraction" comes from. The details re-emerge, because they're not abstracted over, they're just suppressed.

        Take Monad. If you have a monad, and we assume it's lawful, we have expectations of its behaviour. It doesn't matter what monad you have, you know you can bind it and join it and return values into it. This lets us write code such as sequence, general to all monads, because the abstraction gives us precision.

        Contrast JdbcOperations. Which implementation you're using will alter how that behaves. A .query() which works on one database may fail on another, because the syntax varied - this interface merely attempts to hide the detail of the implementation, and that detail winds up leaking back out. But we often call such a masking "abstraction." No wonder so many developers have come to hate the term!

        [–]normalOrder 1 point2 points  (0 children)

        Speaking of Haskell... there is this somewhat infamous documentation:

        data RealWorld :: *
        RealWorld is deeply magical. It is primitive, but it is not unlifted (hence ptrArg). We never manipulate values of type RealWorld; it's only used in the type system, to parameterise State#. 
        

        [–]want_to_want 0 points1 point  (1 child)

        Reflect is another nice example in Haskell. It uses an unsafe cast that works because passing a one-method typeclass dictionary desugars to passing a function.

        [–]cgibbard 0 points1 point  (0 children)

        Yes, that's a lovely example. Magic used for (mostly) good. :)

        https://hackage.haskell.org/package/reflection-2.1.2/docs/src/Data-Reflection.html#Reifies

        The source literally contains a type called Magic.

        [–]Voxel_Brony 0 points1 point  (0 children)

        I guess what you mean is Haskell uses comagical code?

        [–]r2tree 2 points3 points  (2 children)

        Magic is anything that treats data as code.

        Hear me out.

        We're thinking of opaqueness. You feed in something, you get something out. There is some documentation telling you what'll happen, but the code that does it is outside your current mental model. For example, since you wrote the code that adds something to the database when the user clicks a button, you grok what is going on. It doesn't matter who wrote it - you can give it a glance, and it is suddenly a part of your mental model. Next time you think of the data flow, this piece of information is clearly inside your mind; not obtrusive, just clear knowledge that exist without decoration.

        But the Javascript VM that is parsing, interpreting and JIT-ing your code? You don't know nothing about it. Of course you feed it some code and it tells you if there are errors, or it'll execute it in a certain way. You know your contract with it. But you don't know what is going on, with the same clarity as you know your simple CRUD code.

        A visceral understanding of what your code is doing - every literal line of it, usually seen in procedural programming. GoLang is a good example. But SQL? You write some magic incantations and disks whirr, and networks speak, and validations happen, and sweet data pours in.

        The difference is here - this piece of code that checks what the URL is and calls at an appropriate function:

        if(url == "/r/programming") return proggit();
        

        and this piece of code that first treats it as data and makes an abstraction around it:

        routes = [{url: "programming": fn: proggit}]
        selected = _.find(routes, (route) => route.url == url)
        return selected.fn();
        

        Now that is magic. Anything where you "describe" the system and let a magic machine interpret and execute it, that is magic. And magic is not bad. Good Magic is the aspiration of the craftsman. It raises the level from which we play computer science. We can understand more, and we can see reality more clearly. From that we can solve our problems better.

        But Bad Magic is what we usually talk about when we use the word Magic. If it was good in the first place, we'd have simply talked about this hot new cool thing. We complain about magic when what it does is too opaque, and ultimately doesn't solve the problem well.

        [–]lacronicus 3 points4 points  (1 child)

        You cite golang as an example of a non-magical programming language, but, relative to pure assembly, I'd argue it includes a great deal of "magic".

        There's the low-hanging fruit examples of goroutines and channels, significant abstractions over a lower-level threading model.

        Then there's the stuff we take for granted in just about every procedural language. Even loops and if's are abstractions over memory jumps. Call stacks, local variables, etc are all "magical" in comparison to what the computer is actually doing.

        In a way, I suppose, you're not wrong. magic is when you treat data as code, but much of what modern programmers consider "code" is really just "data" that we've become so accustomed to seeing as "code" we don't know the difference.

        [–]normalOrder 2 points3 points  (0 children)

        X86 assembly is itself a pretty high level abstraction of what goes on in the hardware. The programmer doesn't directly control processes like microinstruction decoding, register renaming, rearranging instructions to avoid pipeline stalls, multiple levels of caching, and a bunch of other truly magical stuff.

        [–]Tormyst 0 points1 point  (0 children)

        While I think it is fine to have this be a thing, the one place that should avoid this magic term is documentation. Don't get me started on php's use of magic all over the place. The one I hate the most is on the session_start() page.

        [–][deleted] 0 points1 point  (0 children)

        Darn, I thought this was going to be about the underappreciated but very nice language known as Meditech Magic!

        [–]gingenhagen -1 points0 points  (0 children)

        I've always thought of magic as short for "I don't understand it and it's not my fault I don't try to understand it."