DEV Community

Discussion on: Structured concurrency and pure functions

adamw profile image
Adam Warski Author

I think purity isn't a binary property but can be considered in multiple contexts. Do you write to disk? Do you do network I/O? Do you print to the console? Do you rely on system time? Do you read env configuration? And finally - do you spawn threads?

Running an async Task might have side effects, but it's one thing if you know that once the task completes (you usually can schedule a callback or a subsequent computation when that happens) that some logging will happen, or that a network request will be sent (and complete!); it's another to have a runaway computation running concurrently, even though the calling one completed. That's the guarantee that structured concurrency can give you.

Thread Thread
iquardt profile image
Iven Marquardt

Agreed. Thanks for taking the time!