TylorS / typed-fx

Push-based streams for Effect-ts
https://tylors.github.io/typed-fx/
MIT License
11 stars 1 forks source link

comparison with effect-ts #1

Open adrian-gierakowski opened 1 year ago

adrian-gierakowski commented 1 year ago

Hi

I wonder if you're aware of https://github.com/Effect-TS and if so, if you'd be able to provide a short comparison between typed-fx and effect-ts. Thanks!

adrian-gierakowski commented 1 year ago

also, what it the relationship of this lib with https://github.com/TylorS/typed-fp?

TylorS commented 1 year ago

Hey @adrian-gierakowski, thanks for reaching out! Yes, I actually hang out in the effect-ts discord frequently because it's an awesome project. It's incredibly powerful, and if it solves your use cases I'd definitely recommend it.

At the moment, there isn't a whole lot of difference in Effect -> Fx as a user, but the internal designs are a bit different and depending on the micro-benchmark (all I've done so far) Fx tends to be slightly to maybe 2x faster.

The bigger differences come when you make it to our Stream abstractions. Effect-ts currently uses a pull-based stream abstraction and Fx intends to continue using a push-based stream abstraction. They're much better at modeling the events occuring within the DOM in realtime.

As an additional note, I'm primarily a frontend developer so my tradeoffs are going to lean towards bundle size, parse time, and these user-centric metrics. As such, Fx has much of the functionality but in a smaller size (the whole lib is ~30kb gzipped, before dead code elimination).


Regarding @typed/fp, it came first and it was an attempt to attach fp-ts instances to most of my favorite tools, but I've come across numerous limitations to that design. Currently I'm working on building this library to seed back into @typed/fp, so they can evolve separately. My goal with @typed/fp is to provide higher level abstractions atop of Fx that allow you to build web apps that run in node + a browser.

TylorS commented 1 year ago

Here in my latest iteration, I ended up just building the push-based streams atop of Effect-ts directly. It's resulted in a 5x in file size though of this library, so I'm not positive it's what I'll keep in the end

https://bundlephobia.com/package/@typed/fx@0.0.8

https://bundlephobia.com/package/@typed/fx@0.0.9

TylorS commented 1 year ago

Screen_Shot_2022-10-23_at_12.34.08_PM.png

This ended up being less true, after bundling for production the bundle size remains comparable. I'll likely continue down this path being built atop of Effect-ts

adrian-gierakowski commented 1 year ago

Very nice!

Thank you for your detailed response btw.

I was going to ask if you considered leveraging effect-ts and fp-ts 3 given the recent developments. I’m really glad you went down that path as it will be beneficial for the entire typescript fp ecosystem. I’m now following your project and hope to try it out in the near future. Keep up the good work!

TylorS commented 1 year ago

Yeah, precisely the merger of effect-ts and fp-ts is what made me reconsider my previous decisions. Feel free to open more issues and join the new stream-push channel in the effect-ts discord!