I recently built a new AI model. You've probably seen where other teams have trained AI to "write" poetry or to "paint" images (often with nightmarish effects). Well, I trained my AI by feeding it transcripts of actual conversations that I've had with other people in tech - on the web or IRL. I then tasked it with creating a single, unified transcript that best reflects all of those dialogs in a single conversation.
My first test of the model was to feed it every discourse I've ever had with React Acolytes. The following is a fairly accurate representation of all such conversations distilled into a single transcript.
The Conversation
React Acolyte: How can I help you, Grasshopper?
Me: Well for starters, my name is Adam.
React Acolyte: How can I help you, Adam Grasshopper?
Me: I've run into a strange bug while dealing with a state variable in React.
React Acolyte: Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth...there is no spoon. Then you'll see that it is not-
Me: What the hell does a spoon have to do with React state??
React Acolyte: Oh, right... sorry about that. What I meant to say was: Do not try and bend the state. That's impossible. Instead, only try to realize the truth...there is no state. Then you'll see that it is not the state that bends, it is only yourself.
Me: OK, first of all, that makes no friggin sense whatsoever. Second, that's a pretty blatant rip-off from The Matrix.
React Acolyte: <Shrugging>
Truth is universal.
Me: So is copyright. But do you have any insight that can help with my problem?
React Acolyte: Maybe some more detail about this "state" problem?
Me: Sure. You see, when the user clicks this button, it triggers an event. And that event, in turn, checks the state value before determining whether to proceed.
React Acolyte: Do not try and bend the event. That's impossible. Instead, only try to realize the truth...there is no-
Me: STOP THAT!!!
React Acolyte: What???
Me: Endlessly regurgitating that tired quasi-spiritual claptrap from The Matrix. It's irritating. And it's not helpful.
React Acolyte: But you wanted help with events and state. And this is exactly what I was told at the latest React conference.
Me: How is that even remotely useful??
React Acolyte: Well... state is responsible for complexity in apps. It's the mutable nature of state that makes it the source of most bugs.
Me: OK, I get that. Mutations cause complexity and complexity breeds fragility. But what am I supposed to do about that?
React Acolyte: Remove state. Resist the temptation to use it.
Me: You do realize that "state" is essentially an app's memory, right?? And that without memory, most apps are utterly useless??
React Acolyte: Possibly. But we should still strive to write code that is state-agnostic.
Me: Yeah, yeah... whatever. Shrink state. Minimize mutations. That all sounds good on paper. But I have to deliver an app to my employer. One that will, you know... remember stuff. And that won't be happening any time soon unless I can manage state. And "managing" state means that, occasionally, it needs to be updated.
React Acolyte: I sense much fear in you - fear of purity.
Me: I write "pure" stuff all the time. Pure functions. Pure components. Thousands of them. I don't have any "fear" of them. Besides, that sounds a lot like something that-
React Acolyte: Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to imperative programming.
Me: OK, now you're stealing from Star Wars. I mean, if you're gonna be so blatant, at least gank something from the original trilogy. I don't understand how any of this helps me to fix my bug.
React Acolyte: Pure functions have no state. No dependencies. They work the same way, every time, without nasty side effects.
Me: Yeah... I've known that for years. And like I said, I write pure functions all the time. Whenever I can, in fact. But you can't build an entire enterprise-level app without using state, and at least some "impure" functions, and the occasional events that essentially tie them together.
React Acolyte: Why have you cut yourself off from the Force - of Declarative Programming?
Me: What?? No! Whatever gave you that idea??
React Acolyte: You spoke of... events!
Me: Well... yeah. The user clicks this button, which triggers an event, which then-
React Acolyte: Much defiance I sense in you.
Me: Crappy Yoda impressions you make.
React Acolyte: Sarcasm leads to the Dark Side.
Me: Oh. Then maybe you should call me Darth Adam.
React Acolyte: Darth Grasshopper, you have forsaken Declarative Programming.
Me: That's ridiculous. I love me some JSX. I got my Functional Programming Merit Badge. Every night I urinate on a statue of the jQuery God. I've even been... declared to be a declarative programming guru!
React Acolyte: That was a really bad pun.
Me: Someone doing bad Yoda impressions and ripping off The Matrix wants to judge my puns?
React Acolyte: <Shrugging>
We all have our own standards. My standards require the shunning of all events.
Me: So... your programs run with no user input whatsoever??
React Acolyte: Of course not.
Me: When your users click that button, you don't think of it as an "event"?? Maybe you call it "The Clickening"? Or... "mashing"??
React Acolyte: It's not that my code doesn't have events. It's that my events are not handled in an imperative manner.
Me: Oh... so you mean, in your React apps, that all of the event handling is programmed directly inside of the JSX?
React Acolyte: Precisely.
Me: And you believe that if I were to cram all of my conditions, and loops, and any other logic inside of my JSX, that this would magically fix my event/state bug??
React Acolyte: Bugs are the purview of weak minds. Minds that program... imperatively.
Me: I'm leaving.
React Acolyte: But we haven't fixed your bug yet!
Me: I now realize that we are never going to fix this bug.
React Acolyte: But I have so much more to teach you, Darth Grasshopper!!
Me: Smell ya later, Holmes.
React Acolyte: No! Don't leave!! Try to snatch this pebble from my hand!
Me: Please lock up on your way out.
React Acolyte: What is the sound of one hand clapping?!?!
Me: Peace out.
React Acolyte: Grasshopper! You haven't left me, have you Grasshopper?! Darth Grasshopper! Come back!!!
Top comments (3)
I have a GPT-2 based AI that said something just too creepy/edgy to post it here
I would love to see a real demo :D
True art. It was just too beautiful :tears_of_joy: