7 ms·
Please stop calling it “magic” (2017)
- unkulunkulu 5y agoI always thought that “magic” in software and documentation is like “the” article. Magic == “the feature” in question. The thing “behind” the behavior in question. If you sample articles on metaprogramming, you will see magic being used in relation to it.
- nh23423fefe 5y agoI think this definition in the middle is quite intuitive. > That’s an example of “supernatural” behavior: e.g. when something happens not being obviously related to natural forces of the language. …And is bad exactly because of this fact: your natural tools and intuitions stop working, you need just to remember entire spellbook to deal with magical code. The words natural and spellbook could probably map onto idiomatic and confluence. lol I like it because magic code isn't bad, or slow, or unclever, it is often magic to achieve the opposite. But it does lack something like "being plain spoken"
- slingnow 5y agoThis is one of the most unreadable websites I've seen in a long time. Right off the bat you're assaulted with multiple levels of unreadable thin grey fonts, and it doesn't get any better from there. It almost seems like this was intentionally created to ruin eyesight.
- frankzander 5y agocontrast ratio is cruel
- boffinism 5y agoI wasn't aware that different bits of text in different shades of grey would 'ruin eyesight'. Can you provide a citation, or are you simply expressing "I don't like how this website looks" using hyperbole? Or are you using a hyperbolic way of expressing "I find it difficult to read this website"?
- rectang 5y agoI have vision problems which are not correctable with glasses or contacts, like many people. (Fortunately, my issues are relatively mild.) For people like me, sites with poor contrast are fatiguing to read in a way that sites with good contrast are not. For people with more severe impairments, low-contrast may push past a threshold where a site becomes unreadable in practice. This is not exactly news, there are whole guidelines on contrast published and backed by copious research. https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable/Color_contrast https://developer.mozilla.org/en-US/docs/Web/Accessibility/U... I understand that some people are unaware of this issue. For those that are open to becoming part of the solution when it is brought to their attention, I hold no resentment. But for those that belligerently minimize the problem, for example characterizing the challenge as "I don't like how this website looks"... not so much. Same with organizations that surely know better but continue to present problematic low-contrast interfaces. (Discord, I'm looking at you.)
- boffinism 5y agoDo you believe that things that you find fatiguing to read are also going to 'ruin' your eyesight if you try? Is there any evidence for this?
- rectang 5y agoNo, I don't believe that would affect my particular impairment. Do you believe that the only valid metric for accessibility is whether a site is actively damaging eyesight?
- boffinism 5y agoNo, but my original comment wasn't about accessibility (of which I'm a proponent, by the way), it was about whether the specific sentence "It almost seems like this was intentionally created to ruin eyesight" was unhelpful hyperbole.
- 5y ago
- nemacol 5y agoI also dislike light grey on a white background. Let alone how often the color and size change throughout. It is hard to see and feels noisy - maybe my eyes are already ruined, though I doubt it was from websites that are not to my taste. If I really want to read something like this I usually copy it into a text editor (usually Sublime).
- sebastianconcpt 5y agoYou're discussing pure form and no adding any value on discussing content.
- prawspeed 5y agoRemove the .light class from the <body> and apply these userstyles for this domain .post { font-family: unset; } .wrapper > center, .site-description, .site-navigation, #disqus_thread, .postNavigation, .site-footer { display: none !important; }
- boffinism 5y agoTo save you a click, the 'it' in the title is 'metaprogramming'. The thesis of the article is that, especially in Ruby world, we use the term 'magic' too much, when it's really a derogatory term that applies to cases where it's particularly hard to intuit _how_ a particular piece of code works.
- AndrewOMartin 5y agoFor me "magic" is something that's initially impressive but is actually just the result of a very specific setup or slight-of-hand, which actually has little to no practical usage. To me this is an adequate description of most of the software 'tricks' presented to me as magic.
- commandlinefan 5y ago> a very specific setup or slight-of-hand Wait wait wait... are you telling me that David Copperfield didn't use "rituals, symbols, actions, gestures, and language with the aim of utilizing supernatural forces" when he made the statue of liberty disappear?
- jimmygrapes 5y agoWait how did he do that
- a4isms 5y agoEvery industry has jargon, words which have one meaning in everyday use, but a different meaning within the industry that can be confusing or even hostile to outsiders. "Magic" is an example of jargon when used within the programming community, and especially within the sub-community devoted to Ruby on Rails. As an example of jargon, the dictionary definition is irrelevant other than to emphasize that it is jargon. There are applicable broad arguments against jargon in general, of course, but as an example of jargon, it's not any worse than any other jargon term or phrase, such as "It's ____ all the way down." If we want a definition that we can understand, the correct source is not the dictionary, but this quote from OG sci-fi author Arthur C. Clarke: “Any sufficiently advanced technology is indistinguishable from magic.” With respect to programming, meta-programming is not indistinguishable from a spell cast by a mage in D&D. A better comparison is to prestidigitation, the entertainment art of doing a thing that appears to be impossible, even though everyone in the audience knows that there is a trick to it that can be explained and understood. It's really that simple. "Magic" as a term of jargon means "A sufficiently advanced use of Ruby's meta-programming that is indistinguishable from a conjurer's trick to those who don't know the trick."
- triffee 5y agoThe jargon file defines this succinctly, and is a generally fun read for those who haven't seen it. http://www.catb.org/jargon/html/M/magic.html http://www.catb.org/jargon/html/M/magic.html
- klabb3 5y agoMetaphors have value. Is magic a good metaphor? It doesn't imply metaprogramming specifically to me, but it implies that the computer figures something out without seemingly being told how, which gives me quite a bit of information. Otoh, one man's boring code is another man's magic, so it's relative. But so is "performant", "simple" etc. Those are certainly useful terms, but they rely on context. There are worse sins in programming jargon; like when you overuse technical terms so much that you lose the "point" of what it's supposed to do. Another one is using heavily overloaded abstract terms without explaining which variant you're thinking of. If you say "service" without context, I will come after you :)
- r3trohack3r 5y agoBut it is magic. Personally, I wish we called more of our day to day lives magic. The fact that any of this works is absolutely magic. The whole point of science is separating the magic that works from the hocus pocus that doesn’t. Just because you understand it, just because we have equations, algorithms, and stories that explain the relationships between things, that doesn’t mean it’s not magic. It just means the magic is REAL. It’s impossible for me to look at a computer, a server rack, a car, or a roomba and not see the magic. Just because I understand the principles behind them doesn’t rob me of the wonder of the universe. The analogy I like to use is Hogwarts. Just because they study spells in that fictional world, just because they have schools and universities doesn’t mean the spells aren’t magic. They’re studying the magic available to them in that universe.
- imiric 5y agoI understand the sentiment that technology _feels_ magical. It certainly does so for someone unfamiliar with the field. But for us working in it, who can see the layers upon layers of abstractions, it feels less magical and more like a miracle that any of this works at all. Many of the devices you mention are programmed at such high levels that the programmers themselves rarely understand exactly what's going on beneath the surface. The hardest part of getting the thing to work at all is managing the complex web of dependencies underneath, not programming the actual functionality. Systems that appear magical are mostly running on a house of cards and person-years worth of frustration.
- a4isms 5y agoI own a slab of glass I can talk to, it talks to me, and it can recognize my face. This is absolutely magic in a figurative sense. And never mind that, I'm typing this message on a device that is thinner, lighter, and does so much more than the typewriter I wrote my high school essays upon... And I use it to exchange messages in real time with people around the world! Thank you for reminding us of the everyday magic surrounding us.
- giraffe_lady 5y agoI can't remember where I heard this anymore but "a computer is a rock we tricked into thinking"
- micahdeath 5y ago"magic" is a fun word. Just be sure you can explain what it really does when needed and your fine. I've been using it for years... Mostly as "auto-magic," meaning no user input is needed to make the function work. I also agree that the site is hard to read w/ grey text on a white background. Dictionary.com definition Magic: NOUN the power of apparently influencing the course of events by using mysterious or supernatural forces: example: "suddenly, as if by magic, the doors start to open"
- sebastianconcpt 5y agoSome segments adore to express themselves in language figures instead of concepts to market the hype up to the orbit without realizing that their exaggerations alienate intelligent people.
- mmartinson 5y agoNothing makes me long for boilerplate as much as seeing Ruby code with heavy use of metaprogramming.
- AtlasBarfed 5y agoMagic is of course a very arbitrary word: I'll define it more specifically as: It represents things that happen that you don't understand how they happen. Not just you don't understand how they work when presented with the effect, but is resistant to being reverse-engineered. In your typical programming environment there are ways to backtrack through code searches, type hierarchy management/overloads, interface implementations, type definitions, recasts, scope resolution, etc that you can deconstruct some "magic incantation" to figure out where it is calling and then what it is doing. In dynamic languages (the article is about Ruby) this gets a lot more dicey, with duck typing, lack of strong typing or optional typing to enforce / document what types are being used where, sometimes dynamic scoping, macro expansions. In those cases, IDEs are you friend in a BIG BIG way. They enable targetting searches, parsed/contextual navigations, type guessing even for some dynamic languages. IDE+static-ish typed languages is even better: back navigation to the type, navigate up the type hierarchies or compositions.
- shadowgovt 5y agoI prefer to call it "spooky action at a distance." Because what I observe is that's what gets under software engineers' skin... They think the abstraction is too vague or causes things to happen that are hard to predict, but also hard to trace because the control code is separated from the consuming code, or it has modified the syntax tree or the data at runtime in a place the developer can't directly observe. This differs from abstraction, which is fine. Abstractions are the bread and butter of programming. But if an abstraction is too leaky, or it interoperates badly with other abstractions applying to the same code... It ceases to be abstraction and becomes spooky action at a distance. You could implement subclassing in a language via an inheritance chain or you could implement it via taking objects and replacing their various methods and fields with other methods and fields after they've been constructed. One is the object inheritance abstraction. The other is spooky action at a distance.
- jonahx 5y agoWrong. Keep using the word, and keep piling on the hate. "What junior does not understand, is not magic." To that, I say the difference between a mid-level and senior is that the senior knows "magic" actually is bad.
- coldtea 5y agoThe author seems oblivious to the fact that we use the word magic metaphorically, in all kinds of contexts ouside programming (and the original occult). E.g. a "magical vacation" doesn't involve casting spells... Likewise "magic" in a program doesn't mean we can't ever trace where the effects we see are coming from. Just that they were put in with metaprogramming, and not more conventional methods.
- lloeki 5y ago> "magic" in a program doesn't mean we can't ever trace where the effects we see are coming from This is my definition of magic: when it _does_ so That's my pet peeve with Rails and Rails-minded gems, which do such magic as a core tenet. Someone ends up being too smart for their own (and others) good, it looks lovely and clever from the outside, methods are added to core objects, often dynamically so, global-like state is rampant, lazy behaviour is pervasive. Then something breaks, and you're left with behaviours that make no sense. Of course with enough time and energy one can see through the veil by diving deep in the bowels of the framework, but I don't quite like the thinly veiled judgemental statement of TFA that magic is just metaprogramming and that as a dev you should get your shit together, which does not help in the real world when all hell breaks lose in nonsensical ways because a prime directive has been violated†. Tricks and prestidigitation have no business being used in systems that aim to be reliable. † Blindly copying references to thread locals into another thread[0], assuming every possible one ever used in all apps and dependencies is either scalar (which they're usually not), deep-frozen (which they're usually not), or thread-safe (which they don't need to be, because they're, you know, thread local), can only be delicately described as "a bold move". [0]: https://github.com/rails/rails/blob/6ec669b65d5cd47c984661920d670faccbf0920a/actionpack/lib/action_controller/metal/live.rb#L254-L263 https://github.com/rails/rails/blob/6ec669b65d5cd47c98466192...
- commandlinefan 5y agoMaybe it's not literally magic when you use it, but you do definitely need a literal magician to make any changes to it two years from now.
- dr_dshiv 5y agoMagic is not supernatural in so far as supernatural means “doesn’t exist”. Otherwise referring to anything as magic simply means “it doesn’t exist” or “it doesn’t work.” If you want to use the term magic in a useful way, use it to refer to the use of processes or rituals that have effects through mechanisms we don’t understand. That fits better the history of the term. Like, when a design is magical, that means it has effects that aren’t fully understood. Like architectural decorations on buildings have real effects on the vibe of a neighborhood but we really don’t understand the specifics of how or why they affect us psychologically.
- simonbarker87 5y agoMeh, I think the author is overthinking the use of the word. Personally I tend to use “plumbing”. It’s important, has a tangible result but it’s working are totally hidden unless you go looking for it. I like to say to people that a good framework has a lot of plumbing, where others might call it magic.
- deleted 5y ago[deleted]
- thunderbong 5y agoFrom the article (and I totally agree) - > What's not magic > What junior does not understand, is not magic > Monkey-patching is not magic > Metaprogramming is not magic I've noticed this especially in the Rails community to talk about functionality they find fascinating and which either they don't understand or don't want to explain.
- burnished 5y ago"It doesn't stop being magic just because you know how it works" - Terry Pratchett The FA does seem to specify a particular frustration that my pithy quote doesn't address >>"It is common to see nowadays statements like “this is too magical for less experienced developers to understand”. As Matz says (reciting from memory), “Ruby is complex language to make developer’s life simple”, not the other way round. >>Your car’s engine and your computer’s processor are pretty complicated, too, but that doesn’t mean that they are “magical”. Neither that you shouldn’t use them and stick to “less magical” solutions." I think this is a separate point but it is one I agree with. Probably some nuance here, but I think the problem is less that something is seen as magic and more that something might be prematurely hobbled.
- terrib1e 5y agoStop NOT calling it magic...
- msie 5y agoI'm surprised he used inheritance to demonstrate magic. method_missing is a better example.
- 6gvONxR4sf7o 5y agoI take issue with the 'monkeypatching core classes isn't magic' conclusion. I'd define "magic" in this sense as something that looks like it does one thing, but actually does another. In python, if I see `print(5)`, I should know what that will do. Now, it's possible to do all sorts of magic and make it do something different (like print "five"). The reason that hijacking `print(5)` is magic is because when I look at it, I have reasonable expectations that are subverted. The reason that magic is often considered bad is that if my code is supposed to subvert my expertise, then my expertise suddenly isn't useful to getting my job done. If I want to make it do something else, or debug it, I won't know where to go, because I should know how to debug `print(5)` or change it to `print(6)`, but now I don't know my way around my tools. Maybe it's a connection to black boxes. If a reasonable user can't see how or why your magic works, and can't debug or direct your magic, it's too magical. Yes, that's subjective, but too bad. Maybe "opaque" is a better word.
- mro_name 5y agomagic was, what came prior enlightenment. Then came technology. 'Magic' is, when things – after proper enchantment and ritual – sometimes happen as expected. But you cannot explain why (other than 'because of proper enchantment'). I guess we got, what we called for.
- chameco 5y ago"We are about to study the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by a pattern of rules called a program. People create programs to direct processes. In effect, we conjure the spirits of the computer with our spells."
- karaterobot 5y agoDoes anyone here think that metaprogramming is actually magic, as in something which defies the laws of nature? If there is no confusion, there is no problem.
- ledauphin 5y agoI'm pretty surprised at the dismissive tone of so many of the comments here, most of which seem to focus on orthogonal and uninteresting quibbles like "you say magic means X, not Y, but I say it means Z". The author's point seems fairly clear to me: there are some types of metaprogramming where the "why" is reasonably discoverable, and other types where it is not. "Magic" is often used as a derogatory umbrella term for any kind of metaprogramming, but in fact we all use metaprogramming on a regular basis, and generally the umbrella term is used to disparage metaprogramming that I, the center of the universe, am not familiar with. I think the point is well-taken. Much of programming is metaprogramming; it's a matter of which parts you've familiarized yourself with and which you haven't, and it dumbs down the discourse when people misuse the word magic to describe discoverable forms of metaprogramming. It would be better to specifically critique individual forms of metaprogramming so that we can have productive discussions about those forms.
- deleted 5y ago[deleted]
- musingsole 5y agoIn most fables, it's possible to track down arcane rituals in full detail if you have the patience of a lifetime. From this perspective, discoverability isn't sufficient to claim that something isn't magical. What's magical is that it's sufficiently complicated and reliant on other sufficiently complicated things that -- in practice -- no one utilizing it will bother digging that deep. These things are only knowable in the hypothetical. In practice, they're arcane incantations with rigid, arbitrary constraints that must be respected for the system to function as you'd like.
- djur 5y agoPretty much all of computing is based on multiple layers of complicated things that the end users (including programmers) don't understand. How do we distinguish "magic" from "a successful abstraction" or "an effective and powerful tool"?
- 5y ago
- trey-jones 5y agoThis article correctly asserts that advanced programming techniques aren't invalid because less experienced developers don't immediately comprehend how they work. But from a business standpoint, it is still important. If you are the senior developer and all of your team are fresh out of college, it might be counterproductive for you to go crazy with programming "magic". The examples given of what isn't magic (inheritance, extensions, monkey patches) are completely arbitrary. The truth is that it isn't magic to some developers and it is to others, and you need to know who's reading your code. In the same vein, there are plenty of operations that can be done with arithmetic only (obviously not magic, right?) whose purpose is completely incomprehensible to anybody who didn't write it. Most of these will also be incomprehensible to the author after a period of weeks or months. The same goes for complex sed or regex expressions or a million other one-liner tricks that we nerds love so much. Even if I don't expect anyone other than myself to ever read the code (no, make that especially if it's just for me) I write a brief comment with some explanation of what it does. Or maybe wrap it in a semantically accurate function. I did a little bit of Ruby/Rails about 10 years ago, and this article also reminds me why I have avoided Ruby since, coming to down to this (non)quote: > As Matz says (reciting from memory), “Ruby is complex language to make developer’s life simple”, not the other way round. Ruby claims to make the developer's life simple by being complex, which in my opinion is just backwards reasoning. You lost as me at "parentheses are optional". I'm not even a Python guy at all but I'll go back to my favorite truism from the Zen of Python: explicit is better than implicit. Give a team of nerdy programmers too many routes to the same goal and you're guaranteed to end up with a bunch of code that nobody understands.
- imiric 5y ago> I'm not even a Python guy at all but I'll go back to my favorite truism from the Zen of Python: explicit is better than implicit. The Zen of Python is more of a meme than a list of guiding design principles of the language. This explicit over implicit one in particular. Python does things very implicitly. It encourages operator overloading, so you're never really sure what `a + b` does without seeing the `__add__` implementation. Same for `len()`, `str()` and a few others. Metaprogramming is also considered an advanced topic and used extensively in the wild. Python programmers love implicit behavior and building abstractions that hide the complexity away. It's kind of what the language is about, so being explicit over implicit is rarely followed. Similarly for the other points in the Zen. "There should be one obvious way to do it" is an internal joke; the Dutch line following it is the punchline. While it doesn't follow Perl's extreme TMTOWTDI mantra, there are often many non-obvious ways of doing the same thing in Python. See `str.format()`/`%`/f-strings, for loop/comprehensions, enum implementations, the packaging mess, etc. A language that follows explicit over implicit and one way of doing things is Go, where you're actually forced to do things a certain way because of the design simplicity. Granted, not everything, as generics are now a thing, and modules were a mess for a long time, but it mostly follows Python's Zen more than Python.
- silicon2401 5y agoHaving worked with rails professionally, I agree magic is a stupid term to use. It needlessly suggests some kind of unexplainable or opaque mechanism. As much as I wish ruby were more popular than python, python does it better by simply calling conventions "Pythonic" rather than a loaded word like magic
- stevebmark 5y agoRuby’s metaprogramming is magic, it’s harmful, not powerful, and shouldn’t be compared with actually powerful statically analyzable codegen metaprogramming in other languages. Everything happens at runtime in Ruby, so the fundamental structure of your program can change unexpectedly simply by the order you load files, or the order your code executes in. If you’re building a server, this means your backend code can fundamentally change based on the order you load pages. This is magic. Avoid it.
- josephcsible 5y agoIMO, "magic" is for when things are special-cased somewhere nonlocal. For example, the $ function in Haskell is magic because it always supports impredicative types, but if you define the exact same thing yourself, it won't. (Test case: "runST $ pure ()".)
- hyperdimension 5y agoExcept for the magic switch, of course: https://www.cs.utah.edu/~elb/folklore/magic.html https://www.cs.utah.edu/~elb/folklore/magic.html Edit: it is in the jargon file, just like I remembered it: http://www.catb.org/jargon/html/magic-story.html http://www.catb.org/jargon/html/magic-story.html
- MichaelMoser123 5y agoI hope he is save, he didn't write anything for a while now, last post is from Kharkiv, which is under constant bombardment by Russian forces. https://zverok.space/blog/2022-03-15-STILL-WAR.html https://zverok.space/blog/2022-03-15-STILL-WAR.html
- pjz 5y agoHis twitter was active less than an hour ago: https://nitter.net/zverok https://nitter.net/zverok
- CodeIsTheEnd 5y agoTIL: #method(:method_name) in Ruby I'm a big fan of Ruby, and feel like I know the language pretty well, but, my goodness, I don't know how I've never come across this one before. THIS is something that feels like magic!! [1]> 3.method(:days).source_location => [".../lib/active_support/core_ext/numeric/time.rb", 37] [2]> puts 3.method(:days).comment # Returns a Duration instance matching the number of days provided. # # 2.days # => 2 days => nil [3]> puts 3.method(:days).source def days ActiveSupport::Duration.days(self) end => nil https://ruby-doc.org/core-3.1.1/Method.html https://ruby-doc.org/core-3.1.1/Method.html
- jspash 5y agoFor me, Rails' magic is the (now somewhat outdated) method names that were overusing `method_missing`. Stuff like `Foo.find_by_bar` When all you did was define a db table "foo" with a column "bar". In the early days of Rails, that WAS magical! PHP certainly couldn't do that. I'm not sure how advanced Java's retrospection was in those days. But it seemed as though Ruby/Rails was the only (popular) language around at the time with that sort of trick up its sleeve.