The Power of JS Generators by Anjana Vakil

Sdílet
Vložit
  • čas přidán 20. 06. 2022
  • Generators have been around in JavaScript since ES2015, yet remain largely ignored by many JS devs, who don’t see why or how they’d use them in their day-to-day work. But generators - which we can think of as special functions whose execution can be “paused” and resumed later on - are actually extremely powerful tools for producing and consuming series of data. That makes them perfect for implementing lazy sequences, custom iterables, animation, even the convenient asynchronous programming we now enjoy with “await”! In this talk we’ll dive into how JS generators work, what makes them so powerful, and why you should care.
    jsconfbp.com/speakers/anjana-...
    About Anjana:
    Anjana suffers from a chronic case of curiosity, which led her from philosophy to English teaching to computational linguistics to software development. These days she mostly codes & teaches from her home base in San Francisco, but she’ll always be a traveler at heart. Nerd out with her about functional programming & JavaScript, ask her about the Recurse Center & Outreachy, and definitely invite her to your karaoke party!
  • Věda a technologie

Komentáře • 184

  • @ilearnedtoday6014
    @ilearnedtoday6014 Před 2 lety +161

    she is back

    • @tikendying
      @tikendying Před 2 lety +23

      Folks been waiting for her like a star wars trilogy

    • @Hunt92
      @Hunt92 Před 2 lety +5

      Exactly my thought every time i see her in a video

    • @miloslazic3636
      @miloslazic3636 Před 2 lety +1

      @@bradyfractal6653 She is just excited and happy to be presenting.

  • @EddyVinck
    @EddyVinck Před 2 lety +296

    I knew I recognised her from the Functional Programming talk I saw years ago! It's one of the first talks I ever saw and it drove me to learn more JS! Go Anjana!

    • @mohammedsalah4954
      @mohammedsalah4954 Před 2 lety +9

      same thing here bro she is amazing 🔥🔥

    • @kishanc8697
      @kishanc8697 Před 2 lety +4

      Same here

    • @jacobyoung2045
      @jacobyoung2045 Před 2 lety +5

      Yay! One more Anjana talk on the internet.

    • @2000mipo
      @2000mipo Před 2 lety +6

      THAT TALK WAS SO GOOD RIGHT?!

    • @carlospedroza2604
      @carlospedroza2604 Před 2 lety +1

      She has given several awesome talks, and you can find multiple of them here in youtube! Search for her name, the subjects she covers are varied.

  • @Play_Streams
    @Play_Streams Před 2 lety +57

    I love her energy. Great presentation too! I've always struggled understanding generators.

  • @dianyuanda3383
    @dianyuanda3383 Před 2 lety +8

    I've never seen any speaker in a tech conference that talk so enthusiastic like her

  • @khushalbhardwaj6192
    @khushalbhardwaj6192 Před 2 lety +2

    just fascinated how can something that's so under talked and underrated small little thing can be this powerful and cool.

  • @damians.7859
    @damians.7859 Před 2 lety +99

    Such a nice talk, it's a shame that the person that editted it made a lot of cuts when code was presented and instead showed audience from the back...

    • @user-vj3cu3wv9l
      @user-vj3cu3wv9l Před rokem

      idk what are u talking about

    • @4ipon4ik
      @4ipon4ik Před rokem +6

      @@user-vj3cu3wv9l approx. 20:15 - 22:30 she explains her code step by step, but we don't see it because it's zoomed out.

    • @user-vj3cu3wv9l
      @user-vj3cu3wv9l Před rokem

      @@4ipon4ik anyway u can't learn js by watching conferences

    • @4ipon4ik
      @4ipon4ik Před rokem +12

      @@user-vj3cu3wv9l idk what are u talking about

  • @neonsamurai
    @neonsamurai Před 2 lety +20

    Very good intro. And yes you're totally right, generators are underused. Very much appreciate your talk!

  • @hello2131991
    @hello2131991 Před 2 lety +21

    Her energy is unmatched

  • @ShubhamKumar305
    @ShubhamKumar305 Před 2 lety +2

    I've read about the iterators and iterables from MDN and since then I was like, now I know what can be iterated on JS and how. And when I read about generators I was like, yeah they are there, but how to effectively use them. Thank you Anjana for showing us the various ways.

  • @chhavimanichoubey9437
    @chhavimanichoubey9437 Před rokem +1

    I can't believe that this video helped me understand generators better than anything I ever saw or read on generators.

  • @rishabhkalra9505
    @rishabhkalra9505 Před 2 lety +13

    Finally we have a great explanation to generators. I knew about these for quite some time but since they are not much used, had limited knowledge on how to make them work with complex things, especially async ones. Great session.

  • @alex_chugaev
    @alex_chugaev Před 2 lety +1

    It was so exciting it ended in a blink of an eye. Thanks Anjana, generators have big potential. I’m gonna experiment with them, doing state manager and renderer.

  • @stannone7272
    @stannone7272 Před 2 lety +23

    start at 9:18

  • @shegsdev
    @shegsdev Před 2 lety +4

    Big fan of Anjana. Good to see her again.

  • @griof
    @griof Před 2 lety +3

    Another excellent talk. I'd recommend a talk she has about functional programming. She is a super good communicator!

  • @phoneix24886
    @phoneix24886 Před 2 lety +8

    Anjana is very energetic which makes the presentation interesting!

  • @user-ms9ir3lx3o
    @user-ms9ir3lx3o Před měsícem +1

    As always, her presentation is amazing!. One small observation: Actually the cardDeck, can be expressed in a purely functional way, as the generators returned by generator function are iterable as well as iterator:
    const cardDeck = function* () {
    const suits = ["♣", "♦", "♥", "♠"];
    const court = ["J", "Q", "K", "A"];
    for (let suit of suits) {
    for (let i = 2; i

  • @hyperrealhank
    @hyperrealhank Před 2 lety +2

    This could be among my favorite conference talks

  • @VKD007
    @VKD007 Před 2 lety +2

    I studied generators few years ago but this explanation is so fun man

  • @oleanddro
    @oleanddro Před rokem

    Excellent presentation of GENERATORS! (who saw the introduction will understand)
    Great energy of Anjana Vakil! Thanks!

  • @rollandbryan9908
    @rollandbryan9908 Před 2 lety +26

    Brilliant talk. Please keep the code being talked about on the screen!

    • @meljones2922
      @meljones2922 Před 2 lety +3

      Yup! Here's the code/slides observablehq.com/@anjana/the-power-of-js-generators

  • @throbicon
    @throbicon Před 2 lety +2

    Thank you for speaking in this video. I have never heard of generators but now I am curious. Thank you.

  • @user-dk5uv1xy5j
    @user-dk5uv1xy5j Před 2 lety +10

    We want more conf with her !

  • @bmehder
    @bmehder Před 2 lety +4

    Anjana's talks are always bangers.

  • @code_react
    @code_react Před 2 lety +4

    No doubt its very useful but
    Why would you switch camera while she is explaining the code 20:15. :(

    • @alvarobyrne
      @alvarobyrne Před 2 lety

      yeah, producer was sleeping or editor mistake, or what?

  • @stevekyhon
    @stevekyhon Před 2 lety +3

    Watched from the beginning to the end. Good stuff!

  • @pavelmikhadiuzk310
    @pavelmikhadiuzk310 Před 2 lety +2

    she is crazy)) and Is it contagious) It spreads) I even see how I shout "Generators!" in the middle of night while I am sleeping

  • @ZiedHF
    @ZiedHF Před rokem

    Love her energy, what a beautiful soul. Thanks for this wonderful presentation!

  •  Před 2 lety +2

    awesome Anjana Vakil, thanks for this masterclass

  • @kevinrobertandrews
    @kevinrobertandrews Před 2 lety +2

    Taking from infinite sequences absolutely blew my mind! Thanks for sharing 😊

  • @taz2392
    @taz2392 Před 2 lety +3

    I have no idea what she’s talking about but it looks cool

  • @adittttya
    @adittttya Před 2 lety

    Amazing stuff! One of the best talks ever! 🙌

  • @phanCAbe
    @phanCAbe Před 2 lety +14

    This is a great talk! However I always think back to the JS platform docs at my second job (at a very large company).... " Generators: Don't use generators."
    And it still makes sense because no matter what you do you'll always end up with code that's "too clever".

    • @schobihh2703
      @schobihh2703 Před 2 lety

      thanks!

    • @anikets4699
      @anikets4699 Před 2 lety

      😂🤣😅

    • @jincyquones
      @jincyquones Před 2 lety +1

      "too clever" a.k.a. requires prerequisite knowledge of how they work, which most devs lack because they're too scared to use them

    • @RamkrishanYT
      @RamkrishanYT Před 11 měsíci

      Bruh how is this too clever? It literally is explained in a 30 minute talk

    • @McQuinTrix
      @McQuinTrix Před 10 měsíci

      +1

  • @TheLexuguin
    @TheLexuguin Před 2 lety +3

    You've been using them without even knowing it. Async/Await are basically syntactic sugar for generators. Before them, to achieve a similar functionality, you had to use generators.

  • @Glibenko
    @Glibenko Před rokem

    I really appreciate your performance. Now I know more about generators and wanna apply them.😎

  • @zokizuan
    @zokizuan Před 2 lety

    Thanks Anjali for showering us with your...

  • @oleksandrvorovchenko8674

    Great presentation! Thanks!

  • @mahmoudaldawleh1982
    @mahmoudaldawleh1982 Před 2 lety +2

    i love her energy😃

  • @angelbates5672
    @angelbates5672 Před 3 měsíci

    Wow, this is such a great video. Thanks so much!

  • @KresnaPermana
    @KresnaPermana Před 2 lety +1

    Finally the legendary is showing up

  • @moosesnWoop
    @moosesnWoop Před 2 lety +1

    Great to see Anjana again, wow.

  • @qodesmith520
    @qodesmith520 Před 2 lety +2

    At 2:38 she says "duck-duck-go'ing them..." #BOSS

  • @Thanadit231
    @Thanadit231 Před 2 lety +4

    love her power

  • @amarwavare711
    @amarwavare711 Před 2 lety

    She made generators quite simple to understand !

  • @rojonali3374
    @rojonali3374 Před 2 lety +2

    Definitely she is amazing 😊

  • @phytonprogrammer1998
    @phytonprogrammer1998 Před 2 lety

    Happy to see you again 💜💜

  • @michalkotlicki4710
    @michalkotlicki4710 Před 2 lety +3

    She becomes more energetic every time she takes a sip of this "water".

  • @misterl8129
    @misterl8129 Před 5 měsíci

    Anyone make the Starwars example work? I cant. How it is working? How i can console.log the object starwars with all the data?
    Thanks

  • @savi_sandbox
    @savi_sandbox Před 2 lety

    is there a way to download the slides, presented in the video?

  • @mknijnenberg85
    @mknijnenberg85 Před rokem

    What is the tool/website called where Anjana makes her code blocks with?

  • @Rollmops94
    @Rollmops94 Před 2 lety

    I looked for this for ages

  • @nitsanbh
    @nitsanbh Před 2 lety +5

    Good code is clear, not tricky.
    Implementing a bidirectional channel using a proper object would be so much more readable (and customizable) than using generators’ .next tricks

  • @Hoppi1001
    @Hoppi1001 Před 2 lety +3

    Would it be possible to get those code snippets from somewhere? Yes, I can copy from the screen but maybe I can save some typing if it is.

    • @soumen_pradhan
      @soumen_pradhan Před 2 lety

      observablehq.com/@anjana/the-power-of-js-generators

    • @omgd00d
      @omgd00d Před 2 lety

      observablehq.com/@anjana/the-power-of-js-generators

    • @anastasiiasolop6653
      @anastasiiasolop6653 Před 2 lety

      the link was on the screen in the beginning observablehq.com/@anjana/the-power-of-js-generators

    • @rdil
      @rdil Před 2 lety +1

      The slideshow is linked at the beginning of the talk.

    • @user-df1gs1kf8w
      @user-df1gs1kf8w Před 2 lety

      Get a mac

  • @mich_thedev
    @mich_thedev Před rokem

    One of the best speakers.

  • @farhanbajwa4954
    @farhanbajwa4954 Před 2 lety

    So one of the most important things generator does is that you cannot store an infinite amount of data on your memory like calculating factorials, or stream of data through api it look something like pagination only bring that part of data, when it actually needed.

  • @sayeednazir8884
    @sayeednazir8884 Před 2 lety

    wovvv ,,,,,, really amazing....!

  • @yoni532s9M5w
    @yoni532s9M5w Před 2 lety

    Why isn't js pressed about using generators for iteration like c# is? Isn't enumeration of entire arrays really bad in general?

  • @prigithjoseph7018
    @prigithjoseph7018 Před 2 lety

    Still need to be explain, what is the easiest way of implementing data science and Machine learning with js, and to more often a offline ide for such purpose.

  • @xeoneraldo1254
    @xeoneraldo1254 Před 2 lety +1

    Really cool technology, great to finally have it in JS. We already have that in C# for years, its nothing new.
    I wonder when will source generators come for JS.

  • @kishorrathva4097
    @kishorrathva4097 Před rokem

    How does event loop handles it?

  • @thoril.pegason
    @thoril.pegason Před měsícem

    Wow this is very cool!

  • @sankaraishema5963
    @sankaraishema5963 Před rokem

    Awesome I finally understand ;)

  • @mdistiakhossain1035
    @mdistiakhossain1035 Před 2 lety +6

    She is back again

  • @ravierkonan1694
    @ravierkonan1694 Před 2 lety

    Knew Anjana from her talk on Functional Programming. On her way to be the public voice of JavaScript.

  • @mohammedkaif1236
    @mohammedkaif1236 Před 2 lety

    AWESOME

  • @spiral5799
    @spiral5799 Před 2 lety +2

    She is amazing, fun, smart, and beautiful

  • @AvanaVana
    @AvanaVana Před 2 lety

    I thought I understood generators. This blew my mind.

  • @sudheerpoojary8975
    @sudheerpoojary8975 Před 2 lety

    nice explanation

  • @espectropolitico
    @espectropolitico Před 2 lety +4

    You're like an Marvel Superhero, but to JS. Trully saved me a day (again).

  • @Rene-tu3fc
    @Rene-tu3fc Před 2 lety +1

    not sure if python stole from js or the other way around, but they seem to look and function identically. very fun to use, but easy to create unreasonable code imo.

  • @ihatethesensors
    @ihatethesensors Před rokem

    I'm watching this right now with the console open. Haha!

  • @chhiringtamang7875
    @chhiringtamang7875 Před 2 lety +2

    HOT NEW FEATURE FROM 6 YEARS AGO 🤣 BTW loved it.

  • @vladislavpeev5822
    @vladislavpeev5822 Před 2 lety +1

    Quality content, but I needed to slow down the video speed a little :D

  • @soltsdev
    @soltsdev Před 2 lety +1

    legend is back

  • @mohammedkaif1236
    @mohammedkaif1236 Před 2 lety

    awesome

  • @pahrurozi
    @pahrurozi Před rokem

    What is music intro?

  • @SachinDolta
    @SachinDolta Před 2 lety

    Welcome back Anjana

  • @vytenisurbonavicius9593
    @vytenisurbonavicius9593 Před 9 měsíci

    Great presentation and great energy! Regarding generators - it might be just me but it still feels to me like generators are a cool yet much less readable way to do stuff. Yield makes code run in a non-linear and less intuitive fashion. I wonder if it is just me...

  • @iliyaskhan3803
    @iliyaskhan3803 Před 2 lety

    Anjana knows the best way to engage all your senses

  • @hajiamano22
    @hajiamano22 Před 2 lety +1

    Generators are so underutilized. I created a javascript framework with them that let's me build web apps in 1/10th of the time it took me before.

    • @Ty-13
      @Ty-13 Před 2 lety

      Is it open source?

    • @hajiamano22
      @hajiamano22 Před 2 lety

      @@Ty-13 Not currently, and there are a lot of reasons for that. One there are a lot of better frameworks out there more suited for speed that people should consider like solidjs. My framework is different.
      It doesn't have custom components, just pre-built components that all fit together in a grid system. The cool thing is getting data from the user happens synchronously. So you don't need to have call back functions for forms. When it's on the screen the program yields and waits for the form to be submitted before continuing execution

  • @samuellawrentz
    @samuellawrentz Před 2 lety +1

    Great talk! Love how generators can be used for various usecases. Also lowkey, I'm getting Zendaya vibes.

  • @sandro6103
    @sandro6103 Před 2 lety +2

    She is fire 🔥

  • @limitless9483
    @limitless9483 Před rokem

    great talk btw you guys could have at least linked up the resources from the end of the video to your descriptiopn

  • @uubaidullah
    @uubaidullah Před 2 lety

    og is back ❤️

  • @fabiovictorino350
    @fabiovictorino350 Před 2 lety +3

    Good to see you.

  • @stacksagar
    @stacksagar Před 2 lety

    ❤️❤️🔥

  • @mzubair10
    @mzubair10 Před rokem

    I didn't realize generators were so powerful

  • @SamruddhaShah
    @SamruddhaShah Před 2 lety

    Like your energy

  • @Tony-dp1rl
    @Tony-dp1rl Před rokem

    Makes you wonder why they can't get Tail Recursion into JavaScript compilers, if they can do this stuff :/

  • @Randomguy48279xyz
    @Randomguy48279xyz Před 2 lety

    👍

  • @nhieljeff2156
    @nhieljeff2156 Před 2 lety

    this is straight up sorcery

  • @dc22199x
    @dc22199x Před 2 lety

    Looks similar to php's generator, but basically this is mostly borrowed concept of disappearing pointers.

  • @user-vj3cu3wv9l
    @user-vj3cu3wv9l Před rokem

    i'm not sure why do we need to use them

  • @officialrajdeepsingh
    @officialrajdeepsingh Před 2 lety

    wooo

  • @SuperQuwertz
    @SuperQuwertz Před 8 měsíci

    21:30 I want to see the code...

  • @farhanbajwa4954
    @farhanbajwa4954 Před 2 lety

    I learned generators in python and it looks the same in javascript.

  • @microcodes6887
    @microcodes6887 Před 2 lety

    If you shows on the screen that's how it will execute then it will much better

  • @workout.trending
    @workout.trending Před 2 lety

    can anyone tell me how to learn javascript as fast as possible

    • @mikoaj1954
      @mikoaj1954 Před 2 lety +3

      don't fixate on learning as quickly as possible, this is wrong approach. Just write your own code, bc that's the only way to get better at solving problems with help of programming language of ur choice.

    • @madcalm2024
      @madcalm2024 Před 2 lety +1

      Only in practice on complex projects with many real-life featutes.

    • @workout.trending
      @workout.trending Před 2 lety

      @@mikoaj1954 true thanks man

  • @rushikeshbunge2945
    @rushikeshbunge2945 Před 2 lety +2

    Ah shit, here we go again

  • @MartinCharles
    @MartinCharles Před 2 lety

    generators are sick