Exploring Collectors by Venkat Subramaniam

Поділитися
Вставка
  • Опубліковано 8 вер 2024

КОМЕНТАРІ • 73

  • @CostaKazistov
    @CostaKazistov 4 роки тому +75

    Venkat is phenomenal teacher. Of all Java speakers on UA-cam, he is my favourite. I've been watching his talks since about 2015. In many ways his style of teaching is even better than most online courses.

    • @kennethsizer6217
      @kennethsizer6217 3 роки тому

      Totally agree!

    • @tibettenballs4962
      @tibettenballs4962 2 роки тому

      Don’t forget about his recent arrest, for (I believe so don’t quote me) having naughty child pictures.

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

      @@tibettenballs4962 Where did you hear about this??

  • @snowy0110
    @snowy0110 4 роки тому +54

    Everybody likes Venkat

  • @skootdiggity1301
    @skootdiggity1301 3 роки тому +26

    Oracle should add an honorary Yeeinteger class for Venkat.

  • @sankarpandiarajan5808
    @sankarpandiarajan5808 4 роки тому +12

    Saw a comment in another of Venkat's talks..."the best stand-up comedian". he absolutely is...amazing how effortlessly he walks over such complex stuff.
    the mutant jaws...creating a new species with "mapFlattening" vs "flatMap" - man!!! hilarious.

  • @anversadhat760
    @anversadhat760 3 роки тому +9

    "Haskel feels like Cathedral and Java is like Bazzar" :) 17:00
    "It works" 21:45

  • @ruixue6955
    @ruixue6955 3 роки тому +9

    51:42 motivation of groupingBy
    51:56 imperative way of grouping - 52:11 question to resolve
    57:00 groupingBy

  • @monsterhuntergo
    @monsterhuntergo 2 роки тому +2

    I'm now a fan... I just started following him and a nice way to update my skills too. Functional programming is in-line with clean coding as well. Thanks so much for sharing.. Hope to have more of your videos.. Hope there are also updated videos of him.. :)

  • @ErfanHossainShoaib
    @ErfanHossainShoaib 4 роки тому +6

    One word for you, "Eloquent". Thank you Sir.

  • @asakchris
    @asakchris 4 роки тому +2

    Venkat - YOU ARE THE BEST!!!

  • @ricardotrejoruiz5776
    @ricardotrejoruiz5776 2 роки тому +1

    The golden conference everybody need to watch.

  • @RaviNagubandi
    @RaviNagubandi 4 роки тому +4

    Terrific session. Venkat is master

  • @BryanEaton
    @BryanEaton 4 роки тому +3

    This guy is awesome

  • @techpatil524
    @techpatil524 3 роки тому +1

    My favorite guy, best thing i learn from him👌

  • @RobinsonGames
    @RobinsonGames 4 роки тому +5

    This was really cool

  • @satyanarayanmohanty3415
    @satyanarayanmohanty3415 4 роки тому +3

    A true Guru.

  • @juansebastiangonzalezlopez9119

    Goosebumps & speechless

  • @anushasanpoudel3034
    @anushasanpoudel3034 3 роки тому +2

    what a legend Venkat is !

  • @mangeshpawar2255
    @mangeshpawar2255 4 роки тому +2

    Excellent explanation of stream collectors

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

    Very fun when he talk about flat map. Thank sir

  • @amazingvipul8392
    @amazingvipul8392 4 роки тому +1

    Awesome talk Venkat.

  • @bmiguelmf
    @bmiguelmf 4 роки тому +1

    My code hero!!!

  • @peter.g6
    @peter.g6 4 роки тому +3

    One minor correction, the term "idempotent function" means something different - it means applying the function on a result it gives yields again the same result. Sorting is a good example - if you have a list and you sort it, it can change, but if you sort it again, it stays the same.

    • @CostaKazistov
      @CostaKazistov 4 роки тому +2

      Thanks for clarification. I was confused when Venkat said that about idempotent function, as I remember the definition being exactly as you described.

  • @amazingvipul8392
    @amazingvipul8392 4 роки тому +3

    mapFlatten to flatMap reasoning was hilarious :D

  • @truth-7380
    @truth-7380 3 роки тому +2

    Here is how to get the oldest Person in every City: (value = Optional)
    Map oldestPersonByCity = Person.getPersonList().stream()
    .collect( groupingBy(Person::getCity,
    maxBy(comparing(Person::getAge))));

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

    Long live Venkat

  • @jaimealbertoobispooscco173
    @jaimealbertoobispooscco173 4 роки тому +1

    Fantastic.

  • @B-Billy
    @B-Billy 4 роки тому +12

    58:35 CameraMan is also lazy like Java Streams :)

  • @sushantkumarrout2198
    @sushantkumarrout2198 11 місяців тому

    Sir you are just awesome

  • @silvere4830
    @silvere4830 2 роки тому

    Venkat is THE master

  • @truth-7380
    @truth-7380 3 роки тому +5

    This is how get the name of the oldest Person with one statement:
    No NEED for collect(), no need for maxBy(), no need for collectingAndThen().
    String nameOfOldestPerson = Person.getPersonList().stream()
    .max(Comparator.comparing(Person::getAge))
    .map(Person::getName).orElse("Oldest not found");
    Sometimes Venkat exaggerate a little bit :-)

  • @dcngn_
    @dcngn_ 3 роки тому +1

    Man I learned to love streams, but I know how it felt like to see them when I haven't learned about them yet.. I wonder how my supervisor will feel like when he sees my thesis full of streams.

  • @mehmoodrehman6336
    @mehmoodrehman6336 2 роки тому +1

    1. Java and Functional Programming 0:00
    a. Lazy evaluation vs eager evaluation
    2. Common operations: filter 2:00, map 5:50, reduce 6:20

    3. Functions should be pure
    4. Avoid shared mutability
    5. A little example
    …gone wrong
    6. The right way, - delegate, be declarative,
    7. collect is a reduce operation
    8. Collectors utility class
    9. toList, toSet 30:00
    10. Should we not honor immutability?
    leave it to the APIs

  • @nitinagrawal6637
    @nitinagrawal6637 4 роки тому +9

    In the last 1 hour of this talk, I feel that I was looking at the complex or messy part of such functional programming.
    So, as Venkat says 'Once you get used to it...', it reminded me his earlier statement about the difference between simple & familiar.
    So after doing such functional programming, it becomes familiar & not simple...I think.
    I think one needs to have very fine balance between usage of Functional & Imperative programming to keep things simple & not just familiar.
    And if such stuffing goes on in Functional programming, then I fear that another Venkat will be giving lectures to use Imperative programming to get rid of complexities in Functional programing.
    Too much purity or Immutability, also sucks while doing programming. Please let me know if you have other thoughts to correct me.

    • @nO_d3N1AL
      @nO_d3N1AL 4 роки тому +3

      I agree. The groupingBy example with the nested Collectors is barely understandable for people familiar with the Streams API, let alone someone that's used to imperative style. Honestly in that case the imperative code is easier to work with, at least you can see what it's doing line-by-line/per-instruction explicitly without having to figure out the method signatures from documentation. The functional code is less understandable in that case because it hides the signatures and assumes you know the API and its semantics, whereas imperative code makes it clear what the interactions are. Oh and good luck debugging lambdas in streams / collectors. Admittedly however one can temporarily convert them to AICs using the IDE and convert them back after.

    • @truth-7380
      @truth-7380 3 роки тому +3

      Venkat made it indeed too complex, because he just loosed the orientation in the stream API:
      if you want to get the name of the oldest Person:
      String nameOfOldestPerson = Person.getPersonList().stream()
      .max(Comparator.comparing(Person::getAge))
      .map(Person::getName).orElse("Oldest not found");
      It is a matter of training to become familiar with the Stream API and in that case you will be able to pick the easiest syntax to get your job done.

  • @kookoon
    @kookoon 3 роки тому +1

    @1:26:47
    Java becoming Lisp

  • @ramachari1975
    @ramachari1975 4 роки тому +1

    It is excellent. No doubt about that. But, how is he able to print directly from groupingBy / partioningBy without iterating as (K,V) it returns map..Any pointers, please?

    • @MrMikomi
      @MrMikomi 3 роки тому

      Map has toString I think which works for wrappers or strings (I'm away from keyboard so not definite)

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

      Java can print collections directly as they all have a toString method. However if you have a collection of Primitives, then it will print the hashcode insted and in that case u need to iterate manually.

  • @nitinagrawal6637
    @nitinagrawal6637 4 роки тому +1

    I hear Venkat & really like his talks..but...but...The kind of Lazy Evaluation, he talks I see it as how the creators of such APIs want & write.
    The APIs which are marked as Lazy, are being termed as intermediate functions as he told himself & eager functions are Terminal ones as he told that also. So, intermediate functions are not supposed to be executed till Terminal function is called i.e. till this point the intermediate functions are being stacked only. And I say this as purely 'Postponing the actions' & it is smart way also, but not a lazy one.
    For example - When you need to purchase some item from the market & you don't need that right now, then you keep noting such items in a list. And when you see that you have sufficient number of items to buy from the market then you get out to buy them, so if you think such behavior as 'Lazy' one then can say it, else for me it is a smart decision to postpone certain actions till the right moment comes.
    But a lazy person, will be buying these items & may be not all or may be at his/her speed or may be not at the right time.
    So what is 'Lazy' in the definition given by Venkat, when these functions are not allowed to execute. These functions would have been lazy when they are allowed to execute immediately but still will execute only when they like.
    It is like, someone tie you with rope & then tag you saying that you are lazy & don't do any work.

    • @pn4684
      @pn4684 4 роки тому +5

      Lazy loading is a term used for deferred initialization/run. It is used in other languages, dbs and scripts too. It is not a new term coined just for streams here. It does sound a bit funny the way you put it though.

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

    How is teeing() different from reducing()?

  • @anudeepgrandhi4988
    @anudeepgrandhi4988 4 роки тому +1

    Super sir

  • @codewithshadab
    @codewithshadab 4 роки тому

    Great sir.. Can tell me what IDE you used??

  • @USONOFAV
    @USONOFAV 4 роки тому +1

    Is grouping by in java 8?

  • @mohitchandra5632
    @mohitchandra5632 4 роки тому +1

    I was trying reduce Operation and i saw when i turned it to parallel stream it started giving error so i believe we cannot use parallel streams for reduce for the exampe mentioned at ua-cam.com/video/pGroX3gmeP8/v-deo.html .

  • @dmitriypronichev7048
    @dmitriypronichev7048 2 роки тому

    omg, how can he speak so much without pauses :)))))

  • @amidfallen
    @amidfallen 2 роки тому

    "Brian is overloaded" ... lol xD 1:10:20

  • @JatinderSingh-is7gw
    @JatinderSingh-is7gw Рік тому

    True statement Paul is missing 23:12. People really missing Apostle Paul and are lost.

  • @plreuokjhg
    @plreuokjhg 3 роки тому

    2hrs 😱

  • @marweck
    @marweck 4 роки тому

    What is the fastest Java implementation of Collections used these days? Eclipse (former Goldman Sachs) collections, Guava collections? Any other famous implementation?

    • @snowy0110
      @snowy0110 4 роки тому +2

      tl,dr: imo, one should not strive to find the fastest collection implementation library if performance is not your direct job.
      I believe every implementation you mentioned is fast enough. The fastest one depends on hardware, running OS, implementation of JVM, kind of input data and Collections implementation. This basically means that if you want to see a real impact of having the fastest collection in your particular case, you need to write your code using interfaces and make an experiment for exactly your case: your hardware, your os, your JVM, your input data, and test several collection implementations. Only this way you can be sure that you've chosen the fastest (for your particular case).
      Disclaimer: I had a subject in a university when I was given a task to implement several searching algorithms for finding a substring in text. Back in those days, I was inexperienced just like my friends. Our instructor was a deeply theoretical man who decided to check our code by running performance tests. Based on benchmarks he wanted to check that our code was implemented correctly. We didn't believe our eyes when the same exact code showed completely different results on different machines. Moreover, sometimes, the same algorithm showed completely different results launched several times in a row. Sadly, the instructor didn't believe us and we were forced to fake the results by adding hackish "Thread.sleeps" just to pass the exam. Only later I had a class about computer architecture and realized what was going on. I finished my studies 5 years ago.

    • @pn4684
      @pn4684 4 роки тому +1

      Totally agree. And not to forget the randomness in the collection. Some algorithms are great when there some orderliness in the elements (even if not completely ordered) and some work better in scenarios where randomness is more.

  • @truth-7380
    @truth-7380 3 роки тому +3

    The lovely Venkat does not make the difference between max() and maxBy().
    The example with maxBy() is not good at all.
    You can do the same with max():
    people.stream().max(comparator) and the rest of the statement is not good programming at all.
    It seams that Venkat is trying to make an example with maxBy by any means.
    After a goggle search, it seams that the most people do not know good use cases for maxBy() and in almost all examples it was clear, that it is possible to use max(comparator) instead of collect(maxBy()) with surely les verbose code.

  • @LUQMAN72
    @LUQMAN72 4 роки тому

    what are the features that are available in java 8?

    • @pn4684
      @pn4684 4 роки тому +1

      This is the exhaustive list. www.oracle.com/java/technologies/javase/8-whats-new.html

  • @nO_d3N1AL
    @nO_d3N1AL 4 роки тому +2

    Venkat is always enthusiastic, but IMO he could've easily skipped the first 40 minutes since it was a basic refresher on Streams.