Skip to main content
added 114 characters in body
Source Link

Functional programming is about sharing information through function composition, recursion but not through shared state/memory. In other words, move (move semantics would be considered purity preserving in that sense). Asynchronous

Asynchronous programming is an orthogonal paradigm, itto functional programming. Asynchronous programming is merely about how should tasks/chunks of work be scheduled "in the future" as a response to events, including. Events include task invocation/scheduling events internally generated from your programat run-time. As opposed

Contrary to your reasoning, and as long as state information of a task/function is fully encapsulated within the closure/scope of that function, I do not see how thisasynchronous programming would violate purity as such. In other words, I see asynchronous programming naturally co-existing with functional programming, as long as we keep all our functionstasks/taskschunks of work pure/stateless. For example, in a pure function, program counter (state) must not exist, thus we cannot generate events/function invocations in a sequence of lines"calls" inside the "function"from inside an asynchronous task as no such thingprogram counter state should exist. I would think Instead, functional primitives for function composition should be asynchronously scheduled instead.

Think of a language like Haskell yet compiled underneath toruntime that implements purely functional code as asynchronous invocations of functions. The asynchrony in this case is totally hidden from the developer, as it turns out to be more of an implementation detail, thus hiding any state required for its operation, inside the compiled code, assumed to be correctruntime.

Long story short, you can very well gain the benefits of both worlds by hiding asynchrony in the wayto part of the functional language compiler implements the generated coderuntime.

Functional programming is about sharing information through function composition, recursion but not through shared state/memory. In other words, move semantics would be considered purity preserving in that sense. Asynchronous programming is an orthogonal paradigm, it is merely about how should tasks/chunks of work be scheduled "in the future" as a response to events, including task invocation/scheduling events internally generated from your program. As opposed to your reasoning, and as long as state information of a task/function is fully encapsulated within the closure of that function, I do not see how this would violate purity. In other words, I see asynchronous programming naturally co-existing with functional programming, as long as we keep all our functions/tasks pure. For example, in a pure function, program counter (state) must not exist, thus we cannot generate events/function invocations in a sequence of lines inside the "function" as no such thing should exist. I would think of a language like Haskell yet compiled underneath to asynchronous invocations of functions. The asynchrony in this case is totally hidden from the developer, as it turns out to be more of an implementation detail, thus hiding any state required for its operation, inside the compiled code, assumed to be correct.

Long story short, you can very well gain the benefits of both worlds by hiding asynchrony in the way the functional language compiler implements the generated code.

Functional programming is about sharing information through function composition, recursion but not through shared state/memory (move semantics would be considered purity preserving in that sense).

Asynchronous programming is orthogonal to functional programming. Asynchronous programming is merely about how should tasks/chunks of work be scheduled as a response to events. Events include task invocation events internally generated at run-time.

Contrary to your reasoning, as long as state information of a task/function is fully encapsulated within the closure/scope of that function, I do not see how asynchronous programming would violate purity as such. In other words, I see asynchronous programming naturally co-existing with functional programming, as long as we keep all our tasks/chunks of work pure/stateless. For example, in a pure function, program counter (state) must not exist, thus we cannot generate events/function invocations in a sequence of "calls" inside from inside an asynchronous task as no program counter state should exist. Instead, functional primitives for function composition should be asynchronously scheduled instead.

Think of a Haskell runtime that implements purely functional code as asynchronous invocations of functions. The asynchrony in this case is totally hidden from the developer, as it turns out to be more of an implementation detail, thus hiding any state required for its operation, inside the runtime.

Long story short, you can very well gain the benefits of both worlds by hiding asynchrony to part of the functional language runtime.

Source Link

Functional programming is about sharing information through function composition, recursion but not through shared state/memory. In other words, move semantics would be considered purity preserving in that sense. Asynchronous programming is an orthogonal paradigm, it is merely about how should tasks/chunks of work be scheduled "in the future" as a response to events, including task invocation/scheduling events internally generated from your program. As opposed to your reasoning, and as long as state information of a task/function is fully encapsulated within the closure of that function, I do not see how this would violate purity. In other words, I see asynchronous programming naturally co-existing with functional programming, as long as we keep all our functions/tasks pure. For example, in a pure function, program counter (state) must not exist, thus we cannot generate events/function invocations in a sequence of lines inside the "function" as no such thing should exist. I would think of a language like Haskell yet compiled underneath to asynchronous invocations of functions. The asynchrony in this case is totally hidden from the developer, as it turns out to be more of an implementation detail, thus hiding any state required for its operation, inside the compiled code, assumed to be correct.

Long story short, you can very well gain the benefits of both worlds by hiding asynchrony in the way the functional language compiler implements the generated code.