3 ms·
This imperative/declarative shift happened as part of UIKit -> SwiftUI too. However, it’s still pretty well accepted that if you’re doing anything “complicated”
by didgeoridoo 1y ago
This imperative/declarative shift happened as part of UIKit -> SwiftUI too. However, it’s still pretty well accepted that if you’re doing anything “complicated” you’re going to end up writing UIKit imperative code.
I wonder if there’s any research (PL or maybe even more philosophical) on whether declarative approaches can logically cover all imperative use cases.
Basically: is there something special about “verbs” (imperative) that let you do things that “nouns” (declarative) cannot, at least within reasonable verbosity constraints?
- nicce 1y agoAren’t declarative approaches just abstractions over imperative? Somehow you need to get there. (Processor executes instructions, in the end)
- eyelidlessness 1y agoA (the?) major area where this is generally considered unanswered, and active in PL research, is “effects” (as in, side-effects).
- banalico 1y agoI think there are declarative languages that are Turning-complete, like Prolog, etc. So declarative approaches should be equally good.
- hombre_fatal 1y agoYeah, one of the qualities of the abstraction is how often you have to reach for the escape hatch, how nice it is to use the escape hatch, and whether it's an escape hatch vs. just two clean modes of tooling working together. SwiftUI has failed pretty much all of those for me. In react-pixi / react-three, you have your declarative component tree alongside a `useTick`/`useFrame` function that you can use to do more surgical work, and it works well together. Each component can tap into the tick to update itself. const Enemy = ({ initalPos, size }) => { const [pos, setPos] = useState(initialPos) useTick(dt => { setPos(/* Move in a circle */) }) return <Sprite src="/enemy.png" size={size} pos={pos} /> } I've migrated a few medium-sized pixi/three projects to their React wrappers, and the code cleaned up so well that I could work on them again. Before that, I'd tried modeling games in Elm and then using its port system to send the game state to JS which then updates the pixi/three world. But it's exactly this updateWorld(oldWorld, newState) that's hard to write, yet that's what these libs do for you.
- gf000 1y agoWell, you can interpret the program's text as a declarative (and completely static) approach to describe what will happen at runtime. But you can actually see this dichotomy in template libraries, they usually have constructs making them fully Turing-complete (loops, conditionals, etc).