Functional Programming (Theory of Python) (Python Tutorial)

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

КОМЕНТАРІ • 22

  • @millerdane
    @millerdane 4 роки тому +8

    I am glad I found your channel

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

    While it makes the code look more elegant, it doesn't remove the obvious, procedural nature of python. By writing code like this you are making sure that a smaller number of people actually understand it, because for loops are more ubiquitous. Granted, it would take more lines of code but the flow would be easier to understand (even with yields) and also easier to debug.
    That being said, we should be enforcing pure functions wherever possible. Sometimes it's a bit less practical and can make for long argument lists particularly in web frameworks, but the reward is that things become very easy to unit test. So, what you've paid in longer argument lists, you're getting a return in unit tests.

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

      I'll admit that it's not the greatest presentation. I think it is valuable for the student to understand how it works and work out a few contrived examples. In practice, things are way easier and the complicated scenarios aren't that common.

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

    Have a great day, you too. Thanks.

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

    Much thanks for a video that returns clarity in pure way independent of global state :)

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

    Chopin at the end; nice touch!

  • @harshit.jindal
    @harshit.jindal 4 роки тому +5

    Thank you for this tutorial. It's really helpful

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

    question: an iterator is an object that inherently has state! (same as a function that has a yield statement). So why is an iterator considered part of functional programming, which so frowns upon states??

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

    So reduce is the python equivalent to fold in haskell? As in foldr and foldl?

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

    I enjoy functional programming but it feels like it's an after thought in Python

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

    Tail recursion doesn't work in python right? Ran into a problem with large stacks recently.

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

      @Noob Programmer That's not necessarily true. One could write a python interpreter or compiler which does optimize for tail calls. I'm not sure if it exists though, likely because functional style is not generally "pythonic".

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

      @@alxjones Python doesn't know before hand that the recursive function call is the last statement in the function (tail recursion) since its interpreted. So, on every recursive function call, a new element containing the state of the latest function call is pushed onto the runtime stack (doesn't replace the previous element).

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

      @@alxjones You're thinking about interpreters that have a huge compilation step beforehand like C#, Julia, etc. CPython has a compilation step but it's nothing like what those languages have. Recursions generally suck in Python and are not encouraged.

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

    I love this video

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

    really helpful. many thanks.

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

    Liked and Subcribed

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

    I want to know the person who has no existing knowledge on functional programming to watch this video and immediately starts converting his classes into functions. Seriously, have some overarching examples. You literally only just explained the Python docs in writing throughout the video.

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

      It's kind of hard to teach even a meaningful portion of functional programming in 20 minutes. Maybe one day I'll do a bunch of videos on functional python.

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

    Terrible handwriting

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

      Wait till you see mine

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

      He's no calligrapher but it certainly isn't terrible.