paldepind / flyd

The minimalistic but powerful, modular, functional reactive programming library in JavaScript.
MIT License
1.56k stars 85 forks source link

differences with bacon and kefir: isn't it inspired in CES? #38

Closed cocodrino closed 9 years ago

cocodrino commented 9 years ago

Hi, kefir and bacon seems to be inspired in Compositional event system, I'm more familiar with kefir and for instance, if you need get a stream value in kefir, you need generate an event, instead in flyd you only do

someStream()

you can't get the value of one stream directly except calling some event which generate other stream and use composition of streams, also all the functions works returning new streams (similar to flyd) but for instance in kefir you can't write side effect or not transparent functions this little change is a big difference in the way how you build your algorithms, for instance, in flyd I can write this


flyd.stream([sa],()=>{sb(sa() ....)}) 

I admit than it's pretty cool although a bit nasty: the function is not even transparent where generally in CES I can't write this kind of code...

at the end I don't know if it's a bit weak or if It's other kind of FRP than I dont know (I've never used languages like elm or some libs from haskell) is flyd inspired in elm or it's a more flexible and not so formal CES?? I've admit than right now I found this pretty cool but I also feel than it's not so frp formal

in kefir when I need generate side effect I use onValue(stream,stream->void) where flyd doesnt provides this function but it's not so necessary because you can use stream or even map, flyd doesnt care about it although use map would be very dirty...

how is flyd compared to elm and other FRP like RX or kefir?...is it other kind of frp or you build it thinking in a more flexible approach?

it's interesting because more formal CES sometimes can be a bit pita and flyd seems avoid these situations with a more flexible philosophy...

paldepind commented 9 years ago

I don't know about CES. Flyd is inspired by functional reactive programming.

in kefir when I need generate side effect I use onValue(stream,stream->void) where flyd doesnt provides this function but it's not so necessary because you can use stream or even map, flyd doesnt care about it although use map would be very dirty...

Yes. That is nasty. I added flyd.on earlier today to solve that. It was needed.

it's interesting because more formal CES sometimes can be a bit pita and flyd seems avoid these situations with a more flexible philosophy...

Exactly. Flyd is made to be as flexible as possible. You can do whatever you want (but you probably shouldn't). I personally prefer to program in a more "formal" FRP style (whatever that means) but I specifically designed Flyd not to restrict what users can do. This is not another kind of FRP. You should consider it FRP + ad-hoc flexibility. I designed Flyd so that it could express something quite similar to FRP in Elm but I also added these extra features because I saw no reason not to and because I believe that breaking the rules can sometimes be beneficial.