Stream.Eval vs Stream.generate

76 views Asked by At

I am a Scala programer. For a specific project i need to revert to pure java.

I have been meaning to learn what could be an equivalent for using fs2 in java.

I found several candidate such as reactor. However i wanted to start basic with java stream.

I am trying to understand what is the fundamental difference between

Fs2 Stream.Eval to execute an IO and java Stream.generate to execute a side effecting function. Is it exactly the same in practice ?

The book Grokking Functional Programming in chapter 9 seem to disagree.

Imperative approaches tend to suffer from one very important flaw: they don’t isolate side effects from pure functions. Their APIs tend to treat both impure and pure producers as equals.

Where imperative here is stream in imperative language.

What gotcha should i be aware of ? Because to me it sound pretty similar.

0

There are 0 answers