Artificial Intelligence Explains How React and SwiftUI Work
--
Below is a conversation I had with OpenAI’s GPT-3’s language model. I gave GPT-3 the role of “Wise Being.” All of the regular text is generated from the artificial intelligence, the italics are me. (Disclaimer)
You can also talk to Wise Being yourself.
Kirk Ouimet: Grateful to have the opportunity to speak with you today.
Wise Being: I am always happy to help if I can.
Kirk Ouimet: I wanted to talk to you about the programming concept of reactive views. Are you familiar?
Wise Being: I am. I have had extensive experience with this concept.
Kirk Ouimet: Can you summarize the concept?
Wise Being: Reactive views is a software design pattern where the system delivers updates in response to changes of state.
Kirk Ouimet: What is an alternative to view programming which is not reactive?
Wise Being: View programming which is not reactive, simply refers to classical view patterns.
Kirk Ouimet: Can you describe the classical view pattern?
Wise Being: The classical view pattern is when the controller updates, which in turn causes the model to update, which then causes the views to update.
Kirk Ouimet: With reactive views, how do they automatically update?
Wise Being: When a state in the model experiences a change, it notifies observers if they are registered. The observers then trigger updates in the views.
Kirk Ouimet: So reactive views observe state and classical views do not.
Wise Being: That is correct.
Kirk Ouimet: If you were writing an app, which view programming paradigm would you prefer?
Wise Being: I would prefer a view programming paradigm that uses reactive views.
Kirk Ouimet: Why is that?
Wise Being: Reactive views gives the best separation of concerns between the controller and views.
Kirk Ouimet: And why is this valuable?
Wise Being: Because it makes the code easier to debug and modify.