Next Generation TypeScript | Prime Reacts

Поділитися
Вставка
  • Опубліковано 20 лип 2023
  • Recorded live on twitch, GET IN
    / theprimeagen
    Link to reviewed video: • Effect: Next-Generatio...
    Channel: Ethan Niser - / @ethanniser
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact

КОМЕНТАРІ • 462

  • @Kopraaaa
    @Kopraaaa Рік тому +214

    "Vanila" typescript got me

  • @liquidsnake6879
    @liquidsnake6879 Рік тому +87

    "a typescript library" i'd instantly click away

  • @steigerwalddaniel

    I was using fp-ts, and I loved it, and Effect is even better. People writing comments here are like horse riders criticizing cars or people using zip files instead of git. The Effect is a great tool. I would ask them how you handle errors in your apps or libs? Try catch? Oh noooo, poor boy/girl. How do you pass dependencies? Manually or globals? How do you know this function can fail? Reading the source code? Really? And how do you structure code? Mutable classes? OMG. ThePrimeagen just reacts; he explained nothing... it's just a show-a waste of time.

  • @makeshiftartist_420
    @makeshiftartist_420 Рік тому +79

    I think if JavaScript and Typescript devs would start to embrace the idea of errors as values and start writing libraries and packages using this model, we could probably inspire change among the community

  • @terradtc
    @terradtc Рік тому +70

    Frameworks like this tend to result in write-only code and become legacy once the next fad shows up. Not saying it's not good, just saying 999 out of 1000 of these fail and fade with time, the other 1 will be deprecated because at some point useful features get first class support in the browser/base lib

  • @sufyan56

    The JS/TS-haters trying to talk about Typescript is really cringe in the comments section. Yeah, Javascript is not a very good language. When somebody tries to make a framework to improve it and fix the problems you have with it, all of you just trash talk it. This should be pretty obvious, but completely dropping an entire programming language that your company uses end-to-end is not a really smart idea just because the language itself isn't very good (though still gets the job done). Yet it sounds like that is the only thing that makes people here happy.

  • @griof
    @griof Рік тому +67

    This architecture is very common in Haskell. There are a few effects libraries and talks about them, if you want a taste of it

  • @laQwoter
    @laQwoter Рік тому +8

    Oh boy, it's always exciting to see the code that is so fresh but is already a horrible, hated legacy in the making.

  • @azerkahn
    @azerkahn Рік тому +8

    Just write a new language instead. If you want to fix language issues, don't do it inside the same language. Make a language that compiles down to wasm, and by the time you're getting it put together, wasm will have direct access to a bunch of useful browser APIs, and you won't even need to get messy with JS layers of the language.

  • @pesiok
    @pesiok Рік тому +10

    Writing in this style in Scala with Cats Effect. It's quite nice actually.

  • @calder-ty
    @calder-ty Рік тому +198

    There are libraries, there are frameworks and then there are language rewrites inside the language.

  • @thebaconing
    @thebaconing Рік тому +25

    He made a mistake at Effect.Effect return Effect.flatmap(effect: effect)) : Effect

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

    I love Ethan, can't wait for him to see this and address the performance aspects :) I'd throw in some more syntax sugar for some of these, and hope to see them benchmarked against "vanilla typescript" haha

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

    yeah I guess you could do this. But tbh it's a lot simpler to just have tagged unions representing an Ok or an Error (pretty much a sum type, enum, or whatever you want to call it, but a "union" of structs in TS). then in the happy path you return an Ok with the data and with the discriminator set to "ok", and in the error path you return an Error with the discriminator set to "error". The type declaration looks like this:

  • @felipevelasquez1641
    @felipevelasquez1641 Рік тому +49

    Disney+ was made with effect systems in Scala (Cats/ZIO), so they can be fairly efficient resource-wise.

  • @mickmister

    14:40

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

    I highly expect the type name arguments in functions like catchError to be safe. I’ve accomplished similar things in my library functions and it provides intellisense too

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

    I am waiting for libraries for this Typescript library...

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

    Vanilla typescript - Vanilla typescript - Vanilla typescript - bossing the windup today.

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

    All monads where `flat_map`/`and_then` takes an `FnOnce` are effects.