Effect: Next-Generation Typescript

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ •

  • @ethanniser
    @ethanniser  Рік тому +31

    CORRECTIONS:
    Recent versions of Effect have flipped around the order of the type parameters, so Effect is now Effect
    None of the concepts here have changed, but it might be a bit confusing if you go straight to the current docs
    - 4:10 The use of ‘functional programming’ here is a bit off, Effect is quite literally “full FP”. I meant to specifically highlight a naive method of dependency injection involving always passing every dependency to a function explicitly as a separate argument. Bundling this idea with the label “FP” was not the best way I could’ve put this.
    - 5:04 The Effect.acquireRelease api has changed to use positional arguments. The correct code now would look like 'Effect.acquireRelease(connectToDB, disconnectFromDB)’
    - 6:10 & 7:29 Concurrency not parallelism
    - 6:14 ‘pipe’ is unnecessary

    • @cerstvemlieko
      @cerstvemlieko Рік тому

      acquireRelease could be named `using` as the new keyboard in typescrit, no?

    • @ethanniser
      @ethanniser  Рік тому

      Using provides something similar to Effect’s Scope, but Scope is fully integrated with Effects ecosystem and runtime.

    • @magne6049
      @magne6049 Рік тому

      full FP: you didn’t explain why passing in requirements as parameters becomes unrealistic? The requirements could be passed down the functional hierarchy as part of some …rest parameters, right?

    • @ethanniser
      @ethanniser  Рік тому +2

      There’s no reason you couldn’t do that, it’s just one parameter in the example shown. But once you scale in complexity it can become difficult to organize and keep maintainable.
      Effect makes it extremely simple to consume a dependency, and clear what dependencies a Effect requires to run.

    • @magne6049
      @magne6049 Рік тому

      @@ethanniser Thanks, but how come it becomes harder to scale and organize than passing the requirements in as a type..?

  • @-ion
    @-ion Рік тому +116

    I like how mentioning the word "monad" is avoided.

  • @tobiaslins
    @tobiaslins Рік тому +20

    Great video! Would love to see more content on Effect. Rewriting an existing project to Effect would be dope

  • @Huntabyte
    @Huntabyte Рік тому +16

    Incredible introduction! I had never heard of effect and you sold me in a few minutes!

    • @benocxx7906
      @benocxx7906 Рік тому

      Do you plan to use Effect in MeltUI's code? Since its a primitive components library, it should be as type safe as possible right?

    • @plusquare
      @plusquare Рік тому +1

      @@benocxx7906 leaky abstraction, learn ocaml instead

  • @ShawnShaddock
    @ShawnShaddock Рік тому +6

    This video was very badly needed for Effect, thank you for doing it. I would love to see more like it

  • @dzigizord6567
    @dzigizord6567 Рік тому +42

    Effect needs much better docs and tutorials. In general FP libraries in all languages usually suffer from lack of good docs, especially for beginners to FP and FP language

    • @ethanniser
      @ethanniser  Рік тому +11

      I can assure you the team is working hard to improve the docs.
      There’s still a lot to cover but more than enough to get started.

    • @bigpopakap
      @bigpopakap Рік тому +3

      I also give a vote of confidence in Effect. The docs are definitely lacking right now, but that's largely because the maintainers are rapidly iterating on the framework itself. So their time is going towards that, and the API is still changing a bit.
      Based on some of the docs that *do* currently exist, I am excited for the rest of the docs to come. Usually, you're right that FP documentation is very esoteric, uses a lot of jargon, often relies on just the types to explain what a function does, and lacks concrete realistic examples. I don't think the Effect docs will have that problem, because the library is much more developer-friendly. It's geared towards writing real-world software, unlike many pure FP libraries that simply encode type theory into code

    • @dzigizord6567
      @dzigizord6567 Рік тому +3

      @@bigpopakap I hope that would be the case because that is the only way to get FP lib into mainstream. Looking forward to it!

    • @seannewell397
      @seannewell397 Рік тому

      Docs are products too; need time, dev, love, care, review. Let's help them make it sparkle ✨

    • @username-i8p6c
      @username-i8p6c 2 місяці тому

      I've learned to read types as an alternative to docs and source code. Sometimes good naming and types are sufficient to figure the things that will never be in docs.

  • @mathiasmaerker613
    @mathiasmaerker613 Рік тому +2

    Yes! Finally, keep the tutorials coming, it is badly needed to further push effect-ts

  • @justine_chang39
    @justine_chang39 Рік тому +2

    effect looks awesome, but also, AWESOME VIDEO MY GUY!

  • @melike2d
    @melike2d Рік тому +4

    amazing video! effect has become an irreplaceable piece in my workflow, and I still haven’t used all of the features it has to offer. 100% recommend trying it out :)

  • @goosebumpsfm
    @goosebumpsfm Рік тому +2

    very solid intro! - I've been trying to learn Effect.
    subscribed😄

  • @the_ebdm
    @the_ebdm Рік тому +1

    Just before you gave a shout out to No Boilerplate, I was very much noticing the parallels between you two. I’ve had the pleasure of speaking to Tris directly and I love him dearly, but his obsession with rust is one of the many things that mean, I probably won’t replicate his programming journey. You however are exactly on my path. I’m a JavaScript fiend at heart and a more recent TypeScript convert too. I came here from Prime talking about your BETH stack, and I eagerly (async ;P) await your videos in the future.
    All the best,
    Eric.
    P.S. if you want another nurse to talk to, I’d love to speak to you too.

  • @AlexTurpin
    @AlexTurpin Рік тому +2

    Super into this series, love the no boilerplate vibes

  • @thifeandfes5141
    @thifeandfes5141 Рік тому +2

    I see someone is a fan of no boilerplate! Nice video, keep it up!

  • @markzuckerbread1865
    @markzuckerbread1865 Рік тому +1

    Good video, love the NBP vibes! the idea of functional style handling with monads and pipes for promises sounds great imo

  • @samuelgunter
    @samuelgunter Рік тому +3

    When I started watching this, 0:49 looked bad and 1:04 even worse (admittedly, it's intentionally verbose), but that's probably because I've never seen code written that way before and everything new looks weird/scary when the code you have already works. 0:49 is basically .unwrap(). I still don't love the use of pipe instead of chained method calls but that doesn't really matter.
    5:53 I literally had a use case last night where I wanted 5 to 10 concurrent executions (scraping ~750 webpages of a site that's about to shut down). Doing one page at a time took 26 minutes, if I could've used this it would've been way shorter probably.
    Great first video, I can definitely feel the No Boilerplate inspiration (especially at 0:35 "wake us up at 4am") and he's a great one to get inspiration from. I've subscribed, looking forward to more vids. (don't pull a me by posting an amazing video or two and then giving up)

    • @ethanniser
      @ethanniser  Рік тому +1

      Thanks for the comment, glad you enjoyed the video.
      As for the end of your first point, definitely check out the “Using Generators” page of the docs. You can use Effect to its full extent and never use ‘pipe’ once. Also check out the “pipe method” section in “Building Pipelines”.

    • @username-i8p6c
      @username-i8p6c 2 місяці тому

      yea I prefer the pipeline js syntax compared to Effect.pipe(...args)

  • @NoxTuk
    @NoxTuk Рік тому +1

    This is amazing.
    I'll totally use Effect in my next personal project.

  • @M9625Rahul
    @M9625Rahul Рік тому +18

    Its like a combination of rust, tokio and rust fundamentals, maybe you should have talked about the cons too, anyways loved the video

    • @Jianju69
      @Jianju69 Рік тому

      Reminded me of Rust too.

  • @gnorts_mr_alien
    @gnorts_mr_alien 8 місяців тому +1

    inspiring. hope it takes off.

  • @reo101
    @reo101 Рік тому +4

    Really reminds me Scala's ZIO :D

    • @ethanniser
      @ethanniser  Рік тому +1

      It actually started as a ZIO clone for typescript, but has since done some things a bit different to better suit the language.

  • @figloalds
    @figloalds 10 місяців тому +1

    I don't like any of this and I really think it's a bad idea
    But specially here at 7:50 you can't tell me that the code on the bottom looks any good, it's very ugly
    How do you debug this madness tho, is there any doc on debugging this?
    How about performance and memory efficiency, how does this compare to simple promises?

    • @Lambdaphile
      @Lambdaphile 8 місяців тому

      It will probably be completely abandoned in few years, lol

  • @brooklyn1988flash
    @brooklyn1988flash Рік тому +1

    I have checked effect library and it's constantly evolving with breaking changes.
    I would also add that 'fp-ts' modules which are being merged in `@effect/data` are yet to achieve parity e.g.
    `'@effect/data/Option'` does not have `fromPredicate` function, or
    `@effect/data/Either` does not have `flatMap` etc.
    Regardless of above. it's indeed a great library which bring the goodness of ZIO in javascript world.
    Many thanks for covering it :)

  • @hannad
    @hannad Рік тому +38

    we are making simple things more complex.

    • @luckydev3911
      @luckydev3911 Рік тому +2

      They're reinventing Java?

    • @ethanniser
      @ethanniser  Рік тому +15

      In real applications the complexity is present no matter what. Effect gives you tools to handle that complexity in a more manageable way.

    • @hannad
      @hannad Рік тому +7

      @@ethanniser tbh I don’t buy it. It may be doing sometimes great. But I will always chose simplicity and understandable code over some complex thing which I don’t understand. I don’t in anyway mean this library or pattern is bad. But I feel we really are making things complex with these abstractions. And I may be wrong here but just an opinion on it 😄

    • @ethanniser
      @ethanniser  Рік тому +2

      Totally valid take.
      If your still interested but hesitant, consider trying Effect out on a small project and see what it feels like in practice.

    • @thevoidoid
      @thevoidoid Рік тому +4

      There are no simple things in typescript ecosystem. Your definition of simplicity is wrong. It would be more correct to say "convenient" instead of "simple". Even the most simple libraries are a complete disaster. No composability whatsoever, no simple DI whatsoever. But I understand you -- Effect is based around FP, and FP may not seem simple for an outsider. However, once you try it you will realize that FP is, in fact, more simple that any other existing solutions. Once you get the grasp of F[R, E, A] there is no going back.

  • @dominiktornow1052
    @dominiktornow1052 Рік тому +1

    Great video and also great production value 🚀

  • @liqo12
    @liqo12 Рік тому +2

    i had this issue in a typescript project where parallel async functions are called, upon success it will update a json file. I needed it to also update failure entries per function if the user sends a sigint. The resource release feature matches this perfectly. (if it triggers on sigint)

    • @ethanniser
      @ethanniser  Рік тому

      Definitely give Effect a try then
      If you have any questions or issues, people in the discord would be happy to help.

  • @tsooooooo
    @tsooooooo Рік тому +1

    Looks great, well designed and communicated

  • @bn5055
    @bn5055 Рік тому +2

    You: my mind is racing with possibilities! Me: .... I don't get it

  • @mikeyim9985
    @mikeyim9985 Рік тому

    Awesome video. Have been a fan of Effect for awhile and this video does it justice for sure :)

  • @skylerdjy
    @skylerdjy Рік тому

    You don't know how valuable this video is!!

  • @dontbeafraidfesfd5
    @dontbeafraidfesfd5 Рік тому

    you are my new mentor from now on

  • @hrmny_
    @hrmny_ Рік тому +6

    While this technically is typescript and effect probably was a lot easier to create because of typescript the code you write with it isn't really typescript any more, it's basically another language
    it's a DSL on top of typescript that could probably be easier to write and reason about if it had its own syntax, but that would probably also create a way higher barrier for entry
    hope I can get around to trying effect, it still seems very interesting

    • @ethanniser
      @ethanniser  Рік тому

      The best part about Effect is that isn’t a custom DSL.
      It introduces no new syntax, and requires no transpilation or compilation step. It’s all just plain typescript. You npm install and run the code.
      As I mention in the videos, many other projects that are DSLs suffer from the issue of cross compatibility, Effect does not.

    • @anc2k531
      @anc2k531 Рік тому +7

      Actually Effect is a custom DSL more precisely an « Embedded DSL » meaning that it’s defined within a host language, in that case TypeScript, and does not require additional tooling nor compilation steps to work which is exactly what Effect is. Even more precisely, Effect is an Embedded DSL with Initial Encoding meaning that the interpreter (runtime) is decoupled from the program description.
      Consequently Effect definitely benefits from the TypeScript tooling and can leverage its mainstream side. On the other hand, it inherits the limitations of the host language, but it’s a fair tradeoff.

    • @magne6049
      @magne6049 Рік тому +3

      Effect is a sociolect. It will intimately change the way nearly all your code is written, into a form that is unrecognizable by people not already familiar with Effect.

  • @MrDomiko
    @MrDomiko 12 днів тому

    I love how condescending merchants of complexity can be (c.f. 5:52).
    I'll stick to Observables and RxJs, myself, thank you.

  • @karanahlawat9106
    @karanahlawat9106 Рік тому +1

    This is great! I have to ask, is this somewhat inspired from ZIO in the Scala ecosystem?

    • @ethanniser
      @ethanniser  Рік тому +2

      It actually started as a ZIO clone for typescript, but has since done some things a but different to better suit the language.

  • @saramshshrestha7641
    @saramshshrestha7641 Рік тому +1

    damn everything just flew all over my head.

    • @ethanniser
      @ethanniser  Рік тому +1

      Totally ok, the docs are designed to be approachable so give them a shit if your interested.
      And if you have any questions, people will be happy to answer in the discord.

  • @jorgeosorio1613
    @jorgeosorio1613 Рік тому

    This library is awesome, i will be using it from now on

  • @bagfleet
    @bagfleet Рік тому

    Great vid! Thanks!

  • @sohn7767
    @sohn7767 Рік тому

    Hot sauce dropped. Try catch is no more!

  • @good-dev-student
    @good-dev-student Рік тому +1

    Keep going great job ❤🎉

  • @RasmusSchultz
    @RasmusSchultz Рік тому +1

    No question, the problems with JS are real. And under the circumstances, this looks like an okay solution. But the problems with importing concepts from other languages in this way are also very real. As appealing as it seems to solve these problems "once and for all", you are still effectively left with the burden of solving the problems - now with a better framework for doing so, but the problem is still very much there, and arguably now even more visible than it might be in hand crafted code that deals with the same problems. Every abstraction inevitably comes with new problems. Everything now needs to fit into a "box" with a very specific shape. It invites bike-shedding over when or where this is necessary - potentially complicating simple things. And there is the risk of this become a crutch for people who can't be bothered to learn how the native language primitives work. In my opinion, language features need to be language features, rather than libraries we try to tack on. What we really need is a new language. That said, under the circumstances, this does look like a good library - but it's unlikely I will use it, because I don't like straying from the platform, if I can help it. I would rather teach someone to use the language properly, than teach them how to use a library. But you're not wrong - the language definitely has real problems in this area.

  •  Рік тому +1

    Basically rxjs for angular

  • @invinciblemode
    @invinciblemode Рік тому +1

    This is great, almost rust levels of type safety and correctness!

  • @fire17102
    @fire17102 Рік тому

    You got covered by ThePrimeagen ! Hope you get raided! Also maybe respond & cover his worries about performance and debuggability . Would love to see Effects go far, I'm building similar things in python and svelte. All the best!

  • @nekony3563
    @nekony3563 Рік тому

    I would say that people use TypeScript not because of safety. More like because it allows avoiding safety. This way it is much easier to migrate a JS codebase to it and write code quickly. Exhaustive typechecking might be very... exhaustive. It's like leaving home to work always wearing a helmet in case if a brick falls on your head. That's why it isn't OCaml, but TypeScript.
    Tags are the Service Locator pattern.

  • @dn5426
    @dn5426 Рік тому +6

    Coming from the Scala world with ZIO, Monix and Cats, they are not worth it. It was fun to write clever code but on-boarding a junior dev on to our code base and trying to explain what the fuck EitherT or OptionT was a nightmare.

    • @michaelarnaldi6680
      @michaelarnaldi6680 Рік тому

      If you have to explain EitherT and OptionT your codebases makes usage of transformers. There is no need to do that with effect

    • @yurisich
      @yurisich Рік тому

      ​​​@@michaelarnaldi6680when a big selling point of a library is that it reliably returns an immutable Result | Error union type for internal program state, and that you're railroaded onto that paradigm everywhere, I find it hard to argue that this isn't an OptionT / monad / strict FP world that you have to learn coming from other languages. If you're lucky, beginners might have come from something like Python, which sprinkles the good parts of FP on top of a heavily procedural-based runtime.

  • @Algebraiic
    @Algebraiic 7 місяців тому

    Great video! What is the VSCode theme being used for the code snippets? I tried installing Material Theme and then enabling "Material Theme Darker", although it looks a bit different than this one. Any details would be greatly appreciated!

  • @adaliszk
    @adaliszk Рік тому +2

    Hmm, there are a lot of cool features to this library, great work on it!
    However, I wonder if the same features could not be done with RxJS? At least, that is a question that probably should be answered under "Why Effect?".

    • @tylorsteinberger8471
      @tylorsteinberger8471 Рік тому

      RxJS is an entirely different beast. It provides an implementation of the Observer pattern, nothing more, nothing less. Effect has nothing at all related to the Observer pattern by default. It does have a native Stream type, but it also not very like RxJS as it is pull-based. RxJS (or anything else push-based) couldn't hope to read a terabyte of data from a file stream because it is push-based (IOW, the file reading producer determines when to do work) but Effect's stream will happily do so because it is the consumer which is responsible for managing when to pull data.

  • @serdna8378
    @serdna8378 Рік тому +1

    great video !

  • @suya1671
    @suya1671 Рік тому +1

    Great video. I've been interested in effect for a while now and have been starting to test it out in some test projects. The only thing I don't understand is how dependency injection works and how I would inject multiple dependencies into 1 effect.

    • @ethanniser
      @ethanniser  Рік тому

      That’s actually pretty simple, use Effect.all
      Alternatively using generators you can just assign each dependency to a variable, and if you have multiple just use multiple.

    • @suya1671
      @suya1671 Рік тому

      @@ethanniser could you give a code sample or something? I'm still somewhat confused.

    • @ethanniser
      @ethanniser  Рік тому

      tsplay.dev/mba12N
      Hopefully this helps :)

    • @suya1671
      @suya1671 Рік тому

      @@ethanniser uhhh the link isn't taking me to TS Playground. Has it expired

  • @J-Random-Luser
    @J-Random-Luser Рік тому

    Is the No Boilerplate-like editing style and opening intentional? I don't mind it, I'm just curious haha.

    • @ethanniser
      @ethanniser  Рік тому

      Watch the last 30 seconds or read the description

  • @randomtvninja
    @randomtvninja Рік тому

    Would you suggest learning this over typescript or going back to learn JS? I havent used JS in a very long time.

  • @dr.d3600
    @dr.d3600 Рік тому +3

    Why not Rxjs?

    • @timsmart2982
      @timsmart2982 Рік тому +1

      Because RxJS sucks at error handling.

    • @dr.d3600
      @dr.d3600 Рік тому

      @@timsmart2982 why, catchError?

    • @timsmart2982
      @timsmart2982 Рік тому

      @@dr.d3600 catchError gives you a type of `any`, so you have no type safety.

    • @dr.d3600
      @dr.d3600 Рік тому

      Hmm, how effect do that to get error type?

    • @BrianARCHBOLD
      @BrianARCHBOLD Рік тому +1

      @@dr.d3600 In traditional Typescript, the consumer of a function does not know what errors that function will throw, it only knows through inference what the return type is. Hence with try/catch, your error is always initially inferred as unknown. With Effect, those errors are inferred by typescript. Imagine we had code like this:
      class BarError {
      readonly _tag = "BarError";
      }
      const flakyBar = Random.next.pipe(
      Effect.flatMap((n2) =>
      n2 > 0.5 ? Effect.succeed("yay!") : Effect.fail(new BarError())
      )
      );
      Effect infers this effect and knows that the type of flakyBar is Effect.Effect, so when we want to do something with this effect, we'll know that we'll only need to handle BarError instances, so we can do something like this:
      const recoveredBar = flakyBar.pipe(
      Effect.catchTag("BarError", () =>
      Effect.succeed("I've caught this error and now i'm ready to do something!")
      )
      );
      Now that we've handled this error in this effect, the type of recoveredBar is Effect and we can be sure that we don't need to do anything surrounding errors with it.

  • @javi___
    @javi___ Рік тому

    if you’re getting to the point where you reach for a library like this you should look into changing language, rescript or rust are much better suited for this

    • @ethanniser
      @ethanniser  Рік тому

      Rust has some great web frameworks and templating with macros but for many devs (me included) working in rust is more slower than in typescript. Doesn't mean rust is bad, its awesome, but if know if you need its extra performance or safety you know to not use this stack (or at least the typescript part of it)
      For many many apps, bun/elysia/typescript's performance is more than enough, and the dx from having access to JSX and garbage collection makes it worth using.

  • @BeffJezos69
    @BeffJezos69 Рік тому

    I'm going to learn this library and immediately piss off all my coworkers (in a good way).

  • @cobrasys
    @cobrasys Рік тому

    Love the video and I'm _very_ intrigued by Effect. Gonna give it a whirl for my next personal project for sure.
    I have a side question: you mention in the description that the theme you're using is Material Theme Darker, but there are quite a few "material" themes on VS Code's extension marketplace, and I couldn't find the proper one with that *beautiful* dark blue background... could you maybe supply a link to the specific one? Thanks!

    • @ethanniser
      @ethanniser  Рік тому +1

      this snippets in this video were actually created not in vscode so they are no the material darker theme
      I used Night Owl: marketplace.visualstudio.com/items?itemName=sdras.night-owl&WT.mc_id=twitter-social-sdras

    • @cobrasys
      @cobrasys Рік тому

      @@ethanniser Thanks Ethan!

  • @すべてに興味を失う
    @すべてに興味を失う Рік тому +2

    look like RxJS

    • @tylorsteinberger8471
      @tylorsteinberger8471 Рік тому

      RxJS is an entirely different beast. It provides an implementation of the Observer pattern, nothing more, nothing less. Effect has nothing at all related to the Observer pattern by default. It does have a native Stream type, but it also not very like RxJS as it is pull-based. RxJS (or anything else push-based) couldn't hope to read a terabyte of data from a file stream because it is push-based (IOW, the file reading producer determines when to do work) but Effect's stream will happily do so because it is the consumer which is responsible for managing when to pull data.

  • @MarcosVMSoares
    @MarcosVMSoares Рік тому

    why not try elixir with liveview?

  • @ninenums
    @ninenums 10 місяців тому

    Maybe I’m missing something… but what’s the difference with rxjs?

  • @cerstvemlieko
    @cerstvemlieko Рік тому +1

    what about testing? can you step-run the effect similarly as in redux saga?

    • @ethanniser
      @ethanniser  Рік тому

      Personally I’m not familiar with redux-saga, but if you asked in the discord someone might be more knowledgeable there.

  • @codingedgar4878
    @codingedgar4878 Рік тому +1

    Great video! thanks for the examples.
    4:10 there’s is no need to throw shade at FP, specially considering Effect is _very_ FP and stores/DI/Contexts are also _very_ FP, all the code and mindset is extremely “Full FP” 😂

    • @ethanniser
      @ethanniser  Рік тому +1

      You are totally correct, Effect is a FP library.
      The meaning with that statement was about FP in terms of explicitly passing every dependency to a function through its arguments. Effect essentially does this under the hood, but provides a much cleaner external api for a user.

    • @codingedgar4878
      @codingedgar4878 Рік тому

      @@ethanniser haha no worries I got the intention, it is just misleading as the Effect way is the _actual_ FP way to do it, no FP language/implementation/codebase passes hundreds references as fn args 😅

    • @ethanniser
      @ethanniser  Рік тому

      For sure. In hindsight I think saying something like “raw functional programming” could’ve been a bit more clear.

    • @codingedgar4878
      @codingedgar4878 Рік тому

      @@ethanniser passing arguments as DI has little to nothing to do with FP and it is not an actual practice in FP codebases 😅 there’s no need to mention FP when you think of naive references to it 🤝, it could be described as “naive dependency injection” by itself to reference the technique that is a concept of its own not tied to a programming paradigm.

    • @ethanniser
      @ethanniser  Рік тому +1

      I agree and will take this into consideration in the future, really appreciate the feedback.

  • @fluttermaster6148
    @fluttermaster6148 Рік тому

    How does it compare to something like effection and starfx? The effection is also 'next-gen' typescript library on top of generators to replace promises with better error handling, etc.

    • @timsmart2982
      @timsmart2982 Рік тому

      effection can only represent success values.
      Whereas Effect brings type safety to error handling and also dependency management.

    • @fluttermaster6148
      @fluttermaster6148 Рік тому

      @@timsmart2982 I see, thanks. I will try to play with both of them for some complex scenarios to see a difference in control flow, because effection can start 'processes' (they call it tasks) and it seems that Effect provides only a general 'gen' function

  • @andreas_tech
    @andreas_tech Рік тому

    Nice channel 👍

  • @dawid_dahl
    @dawid_dahl Рік тому

    Very interesting!
    At work I have introduced something to achieve something very similar where we use Nest JS for dependency injection, and the the library fp-ts (which gives us higher-kinder types like TaskEither for asynchronous operations that could fail).
    Have you heard of fp-ts? And if so, is there any reason to use this Effect lib instead of fp-ts? I’d be super curious, thank you! 🙂

    • @ethanniser
      @ethanniser  Рік тому

      fp-ts merged with Effect, and its creator is now on the Effect team. See: dev.to/effect-ts/a-bright-future-for-effect-455m

    • @dawid_dahl
      @dawid_dahl Рік тому

      @@ethanniserWoah what does this mean? That fp-ts won’t be developed any further?
      I’ve come to really enjoy fp-ts and their Haskell-like syntax (Do, for example). I’m not sure I’d want to switch, but will definitely read up in Effect much more right now. Much fun! 😃🙌🏻

    • @ethanniser
      @ethanniser  Рік тому

      Pretty sure yes. They felt it was too difficult for them to coexist.
      Effect does have a much more approachable api than the very haskell esc fp-ts, but anything you could do in fp-ts (and much more) you can do in effect.
      Definitely check out the Effect do syntax, but more more interestingly what they've been able to do with generators. Its like async await for Effects, but the errors magically bubble up
      effect.website/docs/essentials/using-generators
      effect.website/docs/guide/style/do

    • @dawid_dahl
      @dawid_dahl Рік тому +1

      I can see the appeal of this is some regards, definitely. It’s like they have one single super-charged monad instead of having a bunch of different ones.
      One drawback is that now everyone will need to use new words that this library came up with, instead of using stuff like Maybe or Option that are used in other famous languages like Haskell or Rust that people are already familiar with. Could potentially scare people away, just hearing all these new words. I just now had to learn that “Exit” is a kind of return type, that I now have to mentally map to other FP-concepts I already know.
      Ah well, thankfully I have a personality that enjoys learning new things.

  • @rafields2
    @rafields2 Рік тому

    Our fp-ts is evolving into Effect :V

  • @punio4
    @punio4 Рік тому

    When you say "The value produced by a Promise is implicitly memoized" - what does that mean exactly? I can't find any mention of it anywhere online.

    • @ethanniser
      @ethanniser  Рік тому

      basically, awaiting the same promise multiples times doesnt run it again and again
      after it settles it is frozen (memoized)

  • @guppy13
    @guppy13 Рік тому +1

    good video

  • @krtirtho
    @krtirtho Рік тому +2

    Effect looks great. But this does not seem to be usable in a real-world application or not yet
    No matter how many approaches we make, the main underlying issue is Error bubbling and no null-safety. There's no indication of a method/function throwing error

    • @michaelarnaldi6680
      @michaelarnaldi6680 Рік тому +2

      Using effect allows you to control errors very precisely, you simply need to wrap your building blocks with effect and then compose the effects

  • @ze2like
    @ze2like Рік тому

    Effect looks great for the most part but I have a question about dependency injection. Is Effect.provideService a static class method? Does it affect the whole process? If so, can I run tests in parallel or use different impls of an interface side by side ?

  • @amigos786
    @amigos786 Рік тому

    But somehow I feel like it has definitely some learning curve. Doubtful if it will have huge adoption. This is my personal opinion.

  • @irlshrek
    @irlshrek Рік тому

    Seems like theres a lot of overlap with ReScript!

    • @ethanniser
      @ethanniser  Рік тому +1

      Yes, although Effect doesn’t need to be compiled and fully integrates with normal JavaScript/TypeScript.

    • @irlshrek
      @irlshrek Рік тому

      @@ethanniser well i guess my concern is that we still have to make sure that everyone on the team exercises the same amount of discipline when it comes to expressing a throwable function, for example. I'm perfectly happy doing that myself but in my experience id have to spend a bunch of time trying to convince people that theyre playing too fast and loose with the language. While Effect certainly ALLOWS me to expressive im not sure that it would require me, or team-members, to be expressive too. Am i right about this or am i missing something?

    • @ethanniser
      @ethanniser  Рік тому +1

      You are correct. But technically this would be a feature, not a bug. Effect’s goal is to be a library, not a language. Thus, it can’t enforce anything new. It’s on the developer to use correctly.

    • @irlshrek
      @irlshrek Рік тому

      @@ethanniser very fair! and im really glad it exists. I expect ill need to work with typescript in the near future so im really happy you introduced me to this!

    • @ethanniser
      @ethanniser  Рік тому +1

      Glad to hear. If you end up having any questions or issues definitely ask in the discord, people will be happy to help.

  • @MrDejvidkit
    @MrDejvidkit 10 місяців тому

    Is this copy of Scala ZIO?

  • @nathanfranck5822
    @nathanfranck5822 Рік тому

    I'm usually a sucker for insane wrappers in my Typescript, but this feels both super verbose if done 'right' and easily cheatable if a programmer just wants to get stuff done without the Rust-like pre-amble of running the correct effect types all the way up your call stack. Are there linters to ban the use of IO if not used through the effect wrappers?

    • @ethanniser
      @ethanniser  Рік тому

      There are not linters as you described, mainly for compatibility. Effect is designed to be able to be used in just parts of your project, so a linter going after your existing code wouldn't be a great experience.
      A programmer 'cheating' as you described would just be not using Effect, which as I mentioned above is totally ok. If you just want to get stuff done fast (although I would argue using Effect properly would be faster) you can just write normal code, and Effect will be there when you want to bring it in.
      Where are you concerned about verbosity? Most of Effect's tools are abstractions that replace often verbose 'traditional' code.

    • @nathanfranck5822
      @nathanfranck5822 Рік тому

      @ethanniser i was looking at another talk about effect-ts where the presenter wrapped a console.log("hello world") in 4 layers of abstraction, and it just boggled me. Why not just return the data that would have been otherwise used in an IO call and do all tbe nasty real world changes near the entrypoint? Way less abstracting and more readable

    • @ethanniser
      @ethanniser  Рік тому

      I can not speak for this example you brought as I don't know what it is.
      Effect is an extremally composable library. There are many ways to solve the same problem.
      I highly recommended trying Effect for yourself and building a simple program, if you have any questions people in the discord would be happy to help.
      I hope you'll find that most Effect code is often simpler and shorter than a 'traditional' typescript approach.

    • @nathanfranck5822
      @nathanfranck5822 Рік тому

      ​@ethanniser How does this compare to Elm? I feel like either someone interested in this would love Elm

    • @ethanniser
      @ethanniser  Рік тому +2

      Elm is a completely new language that compiles down to JavaScript. This makes interoperability with existing code difficult or impossible. Effect is written in typescript and specifically designed to be incrementally adoptable.
      Elm is also semantically and syntactically very different than typescript, where Effect is about as close to traditional typescript as you get can with the additional functionality provided.
      Elm is also a web rendering framework first, where Effect is a universal library for building anything in typescript.

  • @radvilardian740
    @radvilardian740 Рік тому

    what's ur opinion of combining this with rxjs ?

    • @ethanniser
      @ethanniser  Рік тому +1

      Rxjs is kind of similar in some ways, but Effect has much superior error handling as well as a much larger and more robust ecosystem of supporting tools.

    • @radvilardian740
      @radvilardian740 Рік тому

      @@ethanniser I mean i agreed rxjs sucks in error handling, I might wanna ise thise effect in combination, cant leave rxjs behind as it is mostly the core of all of my custom libs, I am working woth angular with many rxjs observable. May be using this Effect to create a custom operator to handle stream error might be confinient. Idk, should give it a try.

    • @tylorsteinberger8471
      @tylorsteinberger8471 Рік тому

      @@radvilardian740 The will work great together. You'd likely just wrap the subscription process into Effect's Scope type to allow tracking the subscription over time if you'd like to embed RxJS into your Effects. IMO this is actually a pretty big win because you and your teammates can completely stop forgetting to unsubscribe Effect will handle this for you.

  • @ddsmax
    @ddsmax Рік тому

    Kinda glossed over all the important parts and assumed everyone watching just understands.

  • @michaelpayne5272
    @michaelpayne5272 Рік тому

    T3 stack on steroids

  • @titus7770
    @titus7770 Рік тому

    Why should I use this over fp-ts?

    • @michaelarnaldi6680
      @michaelarnaldi6680 Рік тому +1

      Fp-ts merged into effect, there will not be new fp-ts versions unless for maintainance purposes

  • @davidfonseca698
    @davidfonseca698 Рік тому

    Does it make sense to use on frontend or only on backend?

    • @ethanniser
      @ethanniser  Рік тому

      Effect can be used everywhere and find value.
      On frontend the data structures (check out @effect/data/Chunk for a well made immutable array) can be useful without that much “binding” code.
      Working with existing frameworks can require some work to merge the Effect world with what the framework expects, but it’s totally doable. I know there’s some threads discussing this on the discord if your interested.
      Long term, a front end framework written fully in Effect could be created which would be really cool.

    • @magne6049
      @magne6049 Рік тому +1

      Effect today mostly makes sense on the backend (due to its focus on concurrency and coming from ZIO which is for distributed systems / microservices). On the front end you have libraries like React Query, URQL etc. that can take care of the requests, retry policies, etc.

  • @taquanminhlong
    @taquanminhlong Рік тому

    Does this make typescript run faster?

    • @ethanniser
      @ethanniser  Рік тому

      Yes and no.
      Effect adds some overhead, but it more than makes for it with managed effects + concurrency which is where the big performance wins are

    • @taquanminhlong
      @taquanminhlong Рік тому

      this sounds great, but i guess it's not mine but someone else's solution

  • @SeanJMay
    @SeanJMay Рік тому

    Hey; lazy-eval monads that cover streams, sequences, and processes, in TS, without having to teach everyone monads. Will give this a look, in a bit.
    Thank you, algorithm. Good bot.

  • @doxologist
    @doxologist Рік тому

    Rust Error Handling for the frontend lol

  • @aghileslounis
    @aghileslounis Рік тому +1

    The idea is cool but for me, the API is not obvious, the naming and handling is weird and hard to understand

    • @ethanniser
      @ethanniser  Рік тому

      It can be a bit different at first, but no where near as abstract as most FP libraries.
      Give reading the docs or building a simple program a chance and I hope you’ll find Effect is easier than you imagine.
      If you have any questions, people would be happy to help you in the discord.

    • @theyreMineralsMarie
      @theyreMineralsMarie Рік тому

      Just the fact that Effect has a "loop" method. After working with Haskell I assumed something that simple was illegal.

    • @ethanniser
      @ethanniser  Рік тому

      With generators you don’t have to use loop ever.
      The code actually looks quite similar to what you would’ve written before.

  • @mfpears
    @mfpears Рік тому

    This is a lot like RxJS

    • @ethanniser
      @ethanniser  Рік тому

      Rxjs is kind of similar in some ways, but Effect has much superior error handling as well as a much larger and more robust ecosystem of supporting tools.

    • @mfpears
      @mfpears Рік тому +1

      @@ethanniser okay. Well, I see a need to rewrite RxJS on top of Angular signals as a primitive to enable resumability. I'll have to learn more about Effect in case it can help, at least as inspiration

    • @tylorsteinberger8471
      @tylorsteinberger8471 Рік тому

      RxJS is an entirely different beast. It provides an implementation of the Observer pattern, nothing more, nothing less. Effect has nothing at all related to the Observer pattern by default. It does have a native Stream type, but it also not very like RxJS as it is pull-based. RxJS (or anything else push-based) couldn't hope to read a terabyte of data from a file stream because it is push-based (IOW, the file reading producer determines when to do work) but Effect's stream will happily do so because it is the consumer which is responsible for managing when to pull data.

  • @HelloForeignWorld
    @HelloForeignWorld Рік тому

    Giff that language a for-comprehension or at least a do-block 🙏

    • @ethanniser
      @ethanniser  Рік тому

      It has do, and also generators which is arguably better than both

  • @95Ddannyy
    @95Ddannyy Рік тому

    Isn't this trying to make Typescript, Rust?

  • @hicoop
    @hicoop Рік тому +1

    This seems awesome but if you want this much of an upgrade for your typescript, just use rust lol

    • @ethanniser
      @ethanniser  Рік тому

      You're right, but unfortunately for many applications its not that simple (the whole web is built on javascript). What's great about Effect is having access to rust-like features in typescript.

    • @michaelarnaldi6680
      @michaelarnaldi6680 Рік тому +1

      Rust being a low level language doesn't really fit well for IO types that are really only possible with garbage collection so no Rust is nice for it's target but it isn't an option here

  • @MightyMoud
    @MightyMoud Рік тому +2

    I think this syntax will never fly. I do think it's terrible that error mgmt in JS is so basic. I like what you get with this, but the syntax is just not something I would build an application with

  • @ugudango
    @ugudango Рік тому

    This looks quite similar to neverthrow 🤔.

    • @ethanniser
      @ethanniser  Рік тому

      It is similar. But the Effect ecosystem is way bigger than just errors as values.

  • @edhahaz
    @edhahaz Рік тому

    WOW Did javascript people just invent the result feature that rust took from haskell ? Impressive

    • @timsmart2982
      @timsmart2982 Рік тому

      The result type represents a pure value, or in other words the actual result of the program.
      Effect represents the entire computation, so you can easily do things like `Effect.retryN(effect, 3)` and have the whole program retry up to 3 times if it fails.

  • @coding-master-shayan
    @coding-master-shayan Рік тому

    Hi sir, I think you should create a school website using Next js, Appwrite database, Tailwind CSS, shadcn ui. Sir everybody is creating the clones of other websites like UA-cam, Facebook etc. So why not different project.

  • @pedrosaraiva1930
    @pedrosaraiva1930 Рік тому +1

    oh god.. we need a javascript replacement.. not another library on top of javascript

    • @ethanniser
      @ethanniser  Рік тому +1

      JavaScript replacements already exist. There’s a reason we aren’t using them, the ecosystem is too big to move away.
      As we are forced to use JavaScript we might as well make it as good as possible, thus Effect.

  • @the_disco_option
    @the_disco_option Рік тому +2

    Effect.runSync(LikedAndSubscribed);