Both effectively allow a “linear” function to be decoupled from its call-stack, and be treated more like data.
Hybrid solutions that move only bits of the code into the realm of data are promises/futures and coroutines. There are also related alternatives like behavior trees, which are actually quite similar to a “call stack in data” but much more flexible. Whether you're designing the flow of a multi-screen app, or new interactions and animations, Principle helps you create designs that look and feel amazing.
So what can you use instead? The tried and tested alternative is always a state-machine. Principle makes it easy to design animated and interactive user interfaces. And using the call-stack and instruction pointer to model those states makes them particularly unsuitable to being interacted with. These kinds of programs usually have some spooky and sponteanous interactions between different, seemlingly unrelated objects, and weird transitions between states. And there’s one critiria for when it should most certainly minimized as much as possible: highly interactive programs, like user interfaces, games, machine control systems and AI agents. But is it bad? Well, it is certainly good to know when you’re using implicit state like that. This cannot really be avoided while keeping some kind of conceptual separation between code and data. And even a small thing like this already prevents you from doing certain things, for example easily serializing your complete UI state. This is usually not a big problem, but it demonstrates nicely how state can be hidden unintentionally in an application. The instruction pointer is now tied to this state: while it does not move out of that function, the message box is still shown. It is blocking until the the message box is closed again, thereby implicitly modeling the “This message box is shown” state by this thread’s instruction pointer and position on the call stack. But we’re explicitly setting data there, you say. So this appears to be harmless, but is actually one of the most common cases were state is modeled implicitly. What other way is there, really? Let me give you an example, from the widely used Qt library: Now you will probably think: of course, I do that too. One aspect is that they all rely on explictly modeling an application’s state as data. What do libraries like React and Dear Imgui or paradigms like Data-oriented design and Data-driven programming have in common?