The Unreasonable Effectiveness Of Declarative Programming
May 19, 2020 9:19 AM   Subscribe

The blue circle's animation is quite complex. It consists of multiple stages. (1) The circle grows in size. (2) It continues to grow in size at a faster rate, as it shoots off to the right. (3) It pauses. (4) It moves to the middle. (5) It pauses again. (6) It shrinks to nothing.
posted by cgc373 (17 comments total) 17 users marked this as a favorite
 
An ORDER: Click on this link, paste what has been copied to your clipboard into the browser's console, and hit enter.
lol never do this blindly
posted by OverlappingElvis at 10:16 AM on May 19, 2020 [11 favorites]


No kidding, that's how you get chlamydia.
posted by Horkus at 10:35 AM on May 19, 2020 [5 favorites]


Are there important differences between "paste what has been copied to your clipboard into the browser's console, and hit enter" and "visit a site that has the same JS in its source"?

Is the console unsandboxed in a way that JS on a page is not?
posted by jedicus at 11:00 AM on May 19, 2020


I would put it under building good habits to avoid things like https://en.wikipedia.org/wiki/Self-XSS. What if the prompt had asked the user to paste the code into the console on a different site instead? I feel like the number of normal internet users who would understand the difference between these scenarios is small.
posted by OverlappingElvis at 11:18 AM on May 19, 2020 [1 favorite]


Also the tone is everything wrong with declarative math-y everything. It really can be perspective-changing and expressive but the energy spent around presenting such things as objectively and obviously superior (such that if you disagree you're obviously not understanding it) would be better spent considering "why" another choice (that mixes side effects, for example) might selected or how this solution would integrate into an existing complicated solution.
posted by abulafa at 11:41 AM on May 19, 2020 [9 favorites]


Well, I think it's neat. Thanks for posting this, cgc373. I'll be giving it a more careful reading later and I expect to learn some stuff.
posted by mpark at 12:11 PM on May 19, 2020 [1 favorite]


I'm team side-effects, 100%. Global variables? State? Bring 'em on.
posted by signal at 12:50 PM on May 19, 2020 [2 favorites]


I like the code but really don't like the way it is presented. The use of the word "purity" in particular made my eyes roll back. Every way of doing things has strengths and weaknesses. For example: this same engine could have been designed to ingest a JSON payload that described the animation, which would allow it to be called as an API for more flexibility. But that wouldn't be pure.
posted by grumpybear69 at 1:18 PM on May 19, 2020 [4 favorites]


This person's (very cool) cellular automata implementation I think sheds some light on why they think this is the best approach. I don't think I disagree with them philosophically, but let me just say that category theory is a hell of a drug.
posted by OverlappingElvis at 3:52 PM on May 19, 2020 [4 favorites]


this same engine could have been designed to ingest a JSON payload that described the animation, which would allow it to be called as an API for more flexibility. But that wouldn't be pure.

Declaring the animation in JSON and feeding it in that way would be pure, in the way "purity" is being used here- it would still have no side-effects.
posted by BungaDunga at 4:36 PM on May 19, 2020 [3 favorites]


"Pure" here appears to be shorthand for "purely functional."
posted by atoxyl at 4:56 PM on May 19, 2020 [3 favorites]


Yep. Pure is a math term here.
posted by j_curiouser at 10:26 PM on May 19, 2020 [3 favorites]


I don't see a superiority attitude at all – there are a couple of comparisons made to other libraries and that helps place this one in context. It's more like: the other library is like a food processor, this is a fork. The author is proud of the code ("I show off minanim.js"), but, does that have to be a bad thing? I enjoyed it!
posted by romanb at 3:23 AM on May 20, 2020


If I'm writing my own code, I'll happily mix side-effects and global state and keep all the balls in the air in my head. After all, this is my stuff and I'm an adult and that means I get to eat breakfast cereal whenever I want to.

But if I want to use a library, I need it to be thoroughly de-coupled as much as possible. I want clear, defined interfaces. I don't want to spend an age integrating it into my code only to be screaming "What the deuce is it doing??" and "You had one job!!!!".

So yeah, a library that says "Want animations that don't take over your entire environment? Here's some functions you compose, then just plug t into, and get back geometry data, which this other function can render for you if you're in a hurry!" is damn-near ideal.
posted by rum-soaked space hobo at 4:01 AM on May 20, 2020 [11 favorites]


Programmers, to the rest of the world: "It's a discipline that requires constant learning to stay relevant in. You have to maintain an open mind and and an unending sense of curiosity."

Programmers, to other programmers: "You tryna tell me what to do, you iv'ry tower mutherfucker? Global state ain't a problem if you're strong enough. Let the rest of us get back to work!"
posted by invitapriore at 3:25 PM on May 20, 2020 [11 favorites]


Programmers, to the rest of the world: "It's a discipline that requires constant learning to stay relevant in. You have to maintain an open mind and and an unending sense of curiosity."

Programmers, to other programmers: "You tryna tell me what to do, you iv'ry tower mutherfucker? Global state ain't a problem if you're strong enough. Let the rest of us get back to work!"


Every. Fucking. Day. At. Work.
posted by PMdixon at 9:34 AM on May 21, 2020 [3 favorites]


Back when I first learned to code on an Apple 2 clone, using the built-in Apple Basic, I always used to wonder about the purpose of the optional DATA section of the program. "Why wouldn't you just put the exact behavior you wanted into the code directly?"

Separating algorithms from specific uses of those algorithms is a lesson that took longer than I wish it had for me to learn. In my defense, I was a very eager student once I got it.
posted by jiv at 8:16 AM on May 22, 2020 [3 favorites]


« Older PowerToys 0.18 Goes Live with PowerToys Run   |   Antidepressants or Tolkien Character? Newer »


This thread has been archived and is closed to new comments