This Doesn't Make Sense - Scala Loops

Поделиться
HTML-код
  • Опубликовано: 19 сен 2024

Комментарии • 22

  • @sevret313
    @sevret313 4 года назад +5

    Funny that you say that, as when I learnt Scala at uni maybe 6 years ago, they did not start with normal loops but got straight into the functional way of doing things.

    • @rockthejvm
      @rockthejvm  4 года назад

      That's the idea! I'm simply amazed how many Scala tutorials and trainings start with variables and loops.

    • @D4no00
      @D4no00 10 месяцев назад

      To me it seems that scala introduced loops and all of the other imperative concepts to make migration of codebases from Java to Scala easy, however it seems that having so many features makes it lack a certain philosophy and direction.

  • @coffeezealot8535
    @coffeezealot8535 4 года назад +9

    Thank you for all your content. I already finished your Udemy Scala courses and they are amazing. I am about to start the Spark course, soooo excited!

  • @piotrbeda6887
    @piotrbeda6887 4 года назад +3

    Your channel getting hits rapidly, keep going ! Awesome content

  • @chetansp912
    @chetansp912 3 года назад +1

    You surely have amazing content in your channel Daniel.!! Love the fact that you also have the information documented in your blogs.!

    • @rockthejvm
      @rockthejvm  3 года назад +1

      Much appreciated - more to come!

    • @chetansp912
      @chetansp912 3 года назад

      @@rockthejvm Awesome, will look forward to it.. :)

  • @michielpeeters2027
    @michielpeeters2027 3 года назад +2

    So do you think for comprehensions are good or bad? They seem similar to 'do' notation in Haskell.

    • @rockthejvm
      @rockthejvm  3 года назад +1

      For comprehensions are actually pretty awesome, because they're expressions not instructions.

  • @user-fe1tw9zn4q
    @user-fe1tw9zn4q 2 года назад +1

    great series thanks

  • @mourikogoro9709
    @mourikogoro9709 3 года назад +1

    What do you think about regular 'for loop' (eg. in Java)? Is it better or safer than 'while loop'?

    • @rockthejvm
      @rockthejvm  3 года назад

      It's not the syntactic form that makes the difference. The Java for/while loops mean the same thing.

    • @mourikogoro9709
      @mourikogoro9709 3 года назад

      @@rockthejvm but 'for loop' doesn't have mutable indexing statement like "i = i+1" inside its block. so should it be safer in concurrent-workload environment?

  • @sourabh234me
    @sourabh234me 2 года назад

    You mentioned how foreach is different from that of Java and that here it is higher order function taking another function as argument. When I opened this foreach function by the standard library, I see it is actually using a while loop to iterate over the elements. So does it not make it same as Java ?

    • @rockthejvm
      @rockthejvm  2 года назад +1

      The difference is in how you think code.

  • @mayabartolabac
    @mayabartolabac 3 года назад

    I would agree that functions are better than loops in dealing with data structures, but what about the case where I want to loop in a game? Maybe I'm programming a chess game and I want to alternate between 2 players and that requires a loop. Do I stick to loops or should I use recursion for that?

    • @rockthejvm
      @rockthejvm  3 года назад

      You can still use recursion, of course.
      Look, loops aren't the devil. You can use them, that's why the language supports them. The point I want to make in the video is that learning Scala needs to come with learning a different mindset, and learning just the Scala syntax while keeping the old imperative mindset is a disservice to the learner.

    • @mayabartolabac
      @mayabartolabac 3 года назад

      @@rockthejvm Ah thanks for replying quickly! I've decided to use loops for the main part of the game, since recursion and passing state is pretty tedious with that, but I'll put them off for other parts of the program.

  • @scotttang6229
    @scotttang6229 2 года назад

    Bought all three of your courses on Udemy. Thank you