4 ms·
In Dataflow -programming (or something like that) how do you program a decision that depends on the result of some component? It would seem like I need to susp
by galaxyLogic 6y ago
In Dataflow -programming (or something like that) how do you program a decision that depends on the result of some component?
It would seem like I need to suspend my computation then "ask" the result from some component, get the result back, and then alter my computation based on that result.
Pure flow-forward would not seem to support this easily. Or can it? Or does it come down to that we always will need BOTH sync- and async- functions? (unless of course we limit the problem domain)
- erichocean 6y agoSpreadsheets are a variant of Dataflow programming, so however they do it.
- galaxyLogic 6y agoRight but spreadsheets are hardly used for "general purpose programming". They are good for the tasks they are used for but "systems" are not implemented with spreadsheets.
- erichocean 6y agoIf you are implying that normal, for+while loop programming is difficult with dataflow approaches…you're right.
- galaxyLogic 6y agoThat's what I would suspect. Dataflow programing would seem to hold great promise in making programs more understandable. But there would seem to be limits as to where it can be applied (for-if) etc. It is not a universal model for practical programming, I assume. It's a bit like "pure functional programming". We can't really do that in practice because we need IO. The best we can do is to divide the program into two parts, purely functional, and imperative. Similarly I assume we could (and should try to) divide programs into "data-flow-part" and "synchronous-part".
- dustingetz 6y agoI think you are talking about Self-Adjusting Computation, so the answer is yes dataflow can do that https://blog.janestreet.com/breaking-down-frp/ https://blog.janestreet.com/breaking-down-frp/
- DonaldFisk 6y agoYes, it can. The simplest way is with when/unless vertices which take a boolean input and some other inputs, and which either output the other inputs if the boolean input is true/false, or output nothing.
- galaxyLogic 6y agoBut can the boolean input come from some other component to which I send data?
- DonaldFisk 6y agoYes, it would typically be the output of a boolean function. It wouldn't be much use if it couldn't.
- galaxyLogic 6y agoYes boolean function, but wouldn't that have to be a synchronous function, one that the component doing the decision making calls? I understand that there can be loops in the dataflow and feedback can alter the processing logic of a component at some point in the future - since processing is async, the alteration can only happen in the future. But when a component needs to make a decision, not alter its processing logic but simply make a choice, can it somehow 'ask a question" from some other component which is part of the data-flow, before it it decide which branch of the data-flow to send data to? My question is simply is it possible and/or practical to do general programming with only (asynchronous) dataflow between the components/functions/units-of-computation? Or do we need both synchronous and asynchronous components/functions/agents etc. ?
- DonaldFisk 6y agoDataflow doesn't require synchronization because vertices wait until there are values with the same tag on all their inputs before executing. In pure tagged dataflow systems, asking a question doesn't happen: programs are directed graphs and like most other programming systems vertices have to wait for values. However, at a higher level, you could have vertices sending messages to one another and receiving answers back.
- bmitc 6y agoFor dataflow programming, you introduce structures. For example, in LabVIEW, one has many types of structures such as for loops, while loops, case structures (for making decisions), event structures (for listening to and responding to user events), type specialization structures (for reacting, at development/compile time, to types in a dynamic way as a type of development/compile time polymorphism), conditional compile structures (for conditionally compiling different parts of code), and disable structures (for disabling certain parts of code). Here's a simple case structure for a decision based upon a boolean value: https://imgur.com/a/YyzXVhU https://imgur.com/a/YyzXVhU This is really no different than the type of dataflow you have in other functional languages like F# or Racket. Values flow into special syntax forms such as if or match that allow branching.