Why are Type Classes useful in Scala? | Rock the JVM

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

КОМЕНТАРІ • 56

  • @Mia12946
    @Mia12946 4 роки тому +36

    please don't ever stop making these type of awesome videos.

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

    I was really struggling with this concept and this down to earth explanation has really helped a lot much thanks :)

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

    2:50 this dream came true in Java ;) in Java 17 we have pattern matching in switch that works with recognizing different classes
    nice video overall, explains a lot

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

    Your last sentence in the video cracked it for me. "Define specific implementations for certain types and not for others". It is unbelievably simple, you only need the right explanation, by the right guy. Thanks!

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

      Glad to hear it clicked! Share it if you think this would help someone!

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

    Ok let's write some compliments. That was the best, and the simplest explanation of type classes, and the first one which I was actually able to understand. Thanks good job.

  • @RaviAndOlly
    @RaviAndOlly 3 роки тому +6

    You make hard things easy, you rock. I watch Rock the JVM videos as much as I can, I even have bought many courses on Udemy. I hope you soon start videos on cats-effect examples. Thanks a ton!

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

      I'm in the business of making hard things easy. Enjoy!

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

    Amazing video. I have spent hours trying to understand the term. Turns out I have both used and employed type classes before, but have never made the connection between the term and what it implies despite having read multiple articles on it.
    Thank you so much!

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

    Excellent explanation, you made type classes obvious. (as opposed to some other attempts to explain them).

  • @sabita1225
    @sabita1225 5 місяців тому +1

    really great and simple explainer easy to understand.. big thanks

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

    Thanks Daniel. This lesson is very inspiring!!

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

    Awesome video. More of that!

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

    Awesome video - short and upto the point. Can you please make some videos on the more functional programming concepts/constructs like side-effects, referential transprency, Mondas, Functors, IO Effects etc.

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

    My solute and 100% respect to you please accept. Your knowledge is awesome.

  • @no_more_free_nicks
    @no_more_free_nicks 3 роки тому +6

    Also it would be interesting to mention where the name "type classes" comes from.

  • @cherrejim
    @cherrejim 11 місяців тому +1

    awesome explanation!

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

    So gorgeously clear

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

    Awesome video Daniel!

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

    great content as always !

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

    Excellent as usual :) Waiting for next videos

  • @demchuckdima
    @demchuckdima 7 місяців тому +1

    Thanks, good and short wxplanation

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

    Awesome video! Finally cleared things up for me.

  • @pierreabounaoum3713
    @pierreabounaoum3713 19 днів тому

    Nice tube, but in my opinion, isn't comfusing more than useful using implicit? I don't think I will remember what I did myself for while , what about the team I worked with, if I decide to use this topics??? for sure they thow the code in garbage and write another simply because they don't understand a thing??? what do you think about that?

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

    Is there a way in Scala to make of use implicits in methods to choose implementaion based on same arguments but different return type? I tried the way below to return 5/"hello" based on return type defined for processMyList method call,with same argument. But fails with error 'ambiguous implicit values'
    object testTypeClass {
    trait Summable[T] {
    def sumElements(list: List[String]): T
    }
    implicit object IntSummable extends Summable[Int] {
    override def sumElements(list: List[String]): Int = 5
    }
    implicit object StringSummable extends Summable[String]{
    override def sumElements(list: List[String]): String = "hello"
    }
    def processMyList[T](list: List[String])(implicit summable: Summable[T]): T = {
    summable.sumElements(list)
    }
    def main(args: Array[String]): Unit = {
    val intSum: Int = processMyList(List("scala","is","awesome"))
    val stringSum: String = processMyList(List("Scala","is","awesome"))
    println(intSum)
    println(stringSum)
    }
    }

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

      If I understand the question correctly: no, you can't pick which implicits to use. There can be only one for a given type.

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

    The link ti the written form doesn't work: Sorry, we couldn't find that page

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

    such an awesome video, explained well!

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

    Thanks, Denial! Awesome video :) But can you add more examples of using this technic, I mean more real word?

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

      I'm just getting started - will definitely add more content (and context) around this topic!

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

      @@rockthejvm super! Because I see similar example, but I don't understand how to apply this in real word project 🤔

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

    you definitely are my favorite Romanian !

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

    Would be nice to menton some real world example where type classes are normally used.

  • @GabeNicholson
    @GabeNicholson 5 місяців тому

    Implicits in general should be used VERY sparingly. This works here but when you’re reading older code and they use them, it almost always turns out to not be worth it.

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

    Very clear

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

    You are awesome ^^

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

    Nicely explained

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

    strategy pattern

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

      It is kind of, but at a type generic level

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

    Awesome

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

    Multumesc!

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

    Tip: Try to make the font bigger. so much screen real estate - just wasted. Cheers.

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

      Wow, really? My screen feels like a billboard when I record. Will do. Question: are you using the video on half the screen?

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

      @@rockthejvm Not really. I switch back and forth between movie & full screen mode. I watch short videos in movie mode and longer videos in full screen mode.

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

      Forgot to add that I have a 15" laptop. I don't have a big ,21" or greater, screen. Maybe that is sort of an issue, but on my side?