Your code can be beautiful AND fast (Higher order functions)

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

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

  • @SolathPrime
    @SolathPrime Год назад +58

    Haskell falls in a category of programming languages that makes you think about the code
    And forget that you actually have to code and I'm thankful for that
    take for example:
    ```hs
    Relu :: [float] -> [float]
    Relu x
    | x > 0 = x
    | otherwise = 0.0
    let xs = [-2.0, -1.0, 0.0, 1.0, 2.0]
    main :: IO()
    main = putStrLn map Relu xs -- prints [0.0, 0.0, 0.0, 1.0, 2.0]
    ```
    and suddenly machine learning was never that easy
    math was never that easy
    thinking about code instead of actually coding was never that easy
    oh I love haskell
    do I need to sleep? yes cause it's 2:19 AM and I have a work to do
    will I actually sleep? probably NO
    oh shit I'm ranting again

    • @peppidesu
      @peppidesu  Год назад +32

      what about
      map (maximum 0.0) xs
      :)

    • @SolathPrime
      @SolathPrime Год назад +4

      @@peppidesu woah I've never thought of it
      I always look at the mathematical shape and forget the easy simple form of it

    • @ゾカリクゾ
      @ゾカリクゾ Год назад +1

      @@peppidesu do you mean max?

    • @SolathPrime
      @SolathPrime Год назад +1

      @@ゾカリクゾ in haskell the `max` function is called: `maximum`

    • @mattetis
      @mattetis Год назад +5

      ​@SolathPrime No, the correct implementation is `map (max 0.0) xs`.
      `max` compares two values and `maximum` folds a Foldable with `max`, i.e. `maximum xs` gets you the biggest value in the collection

  • @justabarrelbomb4472
    @justabarrelbomb4472 4 месяца назад +16

    Please continue your series on this, you are a really good teacher and the videos are of superb quality.

  • @crckrbrrs
    @crckrbrrs Год назад +30

    your presentation is fucking beautiful, and i think its criminal that you only have 3k subs

  • @Yogesh-kr7bo
    @Yogesh-kr7bo Год назад +59

    yandere dev crying in the corner

  • @pi-stone460
    @pi-stone460 26 дней назад

    Man.
    This series is what anybody should call usefully beautiful.
    Your voice, tone, and explaining skills mixed with your great visual representations make for a perfect way to undestand so, at first glance, complex mechanisms.
    I just love the colors, animations (even the quirky ones) and shapes you use to represent everything.
    Thank you.
    I will learn haskell, and I will use this knowledge to improve my code.

  • @44mira
    @44mira Год назад +6

    You are definitely one of the best channels for these types of presentations, they're very sleek, clean and informative.
    I was wondering if you could make a video on your workflow when it comes to making these videos? I have also been considering making a channel entirely around FP as I think it is quite the outstanding and fun approach to programming, and having a video creation process to base it on would be much appreciated!

  • @learning-og4to
    @learning-og4to 7 месяцев назад +2

    this channel is great. you explain these concepts very well

  • @Marko-rc5nc
    @Marko-rc5nc 4 месяца назад +1

    Thank you for this series on haskell. I hope you will make videos again in the future ❤

  • @posfr292
    @posfr292 9 месяцев назад +1

    Wow. That's an absolutely beautiful video. I'm starting to understand it - especially with the aid of those fantastic function / higher-order function (HOF) diagrams. One comment, however: there appears to be a minor typo in the "Wrapping up" diagram at around 07:36. I think that the output of the filter HOF should possibly have the type [a]. Having just subscribed to your channel, I'm going to watch more of your Haskell videos in my quest to understand functional programming with TypeScript (of all things - possibly with the aid of the fp-ts library). Thank you.

  • @TheGRoques
    @TheGRoques Год назад

    Thank you. I've been thinking of starting Haskell for many years, and this video series serves as a concise and accessible introduction!

  • @maurolimaok
    @maurolimaok Год назад

    I'm just starting my journey at Odin Project, at 56yo
    At the moment my focus is on the basics, but this is very interesting.
    Hope to see more like this.
    Thanks!

  • @karl_zw
    @karl_zw Год назад +2

    Your vidoes are amazing, please keep them coming!

  • @ゾカリクゾ
    @ゾカリクゾ Год назад +1

    I absolutely loved the building blocks graphics!

  • @mtv.smorodin
    @mtv.smorodin Год назад +1

    looking forward for next episodes! thank you for your content 🎉

  • @Zetty
    @Zetty Год назад +8

    another banger from peppidesu

  • @fabricehategekimana5350
    @fabricehategekimana5350 Год назад +1

    Incredible video ! I like your work and I hope the best for you

  • @SilverStarStorm.
    @SilverStarStorm. 11 месяцев назад +2

    Continuation when? :p

  • @SimGunther
    @SimGunther Год назад +4

    While map itself is embarrassingly parallel, there are tasks that are not "embarrassingly parallel" that would be better used for a work stealing scheduler that accounts for shared resources.
    There's a set of "embarrassingly sequential" problems such as dynamic programming (load balancing and 90% of leetcode questions) and state machines (tokenizers included) you'll have to keep in mind before blindly throwing a bunch of threads on a problem. Well aware that there's mapM for monadic mapping over a list along with parMapM for a parallel version of that listing, but make sure you solved the problem correctly single threaded or else you'll be in "big trouble in little CPU town: multi threaded edition."

    • @0LoneTech
      @0LoneTech 11 месяцев назад +1

      ... RUclips ate the two previous versions of this reply without warning, so pardon the duplicates if there are any.
      Work stealing is a particular example of a parallel load balancing algorithm, and tokenizers are usually easily parallelizable (typically neighbour aware map followed by partitioned reduce for longer tokens). Sometimes there's a specific choice, as in signature chains vs Merkle trees, but a lot of the time there's a perspective to be found that isn't obvious at first glance.
      As for parMapM, bear in mind that not all monads are IO. They are distinguished in Control.Monad.Par.

  • @dycan0716
    @dycan0716 11 месяцев назад

    Any tutorial about vizualisation in the new perspective section? looks sophisticated.

  • @Sk8erMorris
    @Sk8erMorris Год назад +1

    Hope all is well, wondering for the continuation of the series :)

  • @alexanderskusnov5119
    @alexanderskusnov5119 9 месяцев назад

    2:49 foo needs a function of one argument (type a), it's not a plus function of 2 arguments (x, y).

  • @zsuato
    @zsuato 7 месяцев назад

    this is so cool

  • @GamingKing-jo9py
    @GamingKing-jo9py Год назад +2

    i've been known to make my code borderline unreadable to others because it saved one more variable (pointfree* is cool)
    i don't know why but now i find them ugly
    *mostly

  • @harune6594
    @harune6594 9 месяцев назад

    oh man heartbroken you didnt continue this series

  • @kedislav_
    @kedislav_ Год назад +2

    beautiful code for a beautiful man

  • @callyral
    @callyral Год назад

    oh, like rust iterators! haskell sounds pretty cool

    • @0LoneTech
      @0LoneTech 2 месяца назад

      @AndreiGeorgescu-j9p Rust iterators are basically a blend between Haskell lists and Python generators.
      Haskell: bs = [f(a) | a

  • @theaveasso
    @theaveasso Год назад +1

    Do you have any recommend open source that Haskell beginners can work on?

  • @konstantinrebrov675
    @konstantinrebrov675 Год назад

    Is it possible to use higher order functions in C, C++, or Rust? Maybe with some clever ways of coding tricks?

    • @peppidesu
      @peppidesu  Год назад

      Rust features them out of the box with iterators and closures. I am not very familiar with C++, but it should have them in the standard library as well. As for C, you probably need to make them yourself. In general, if a language supports passing functions as arguments (spoiler: most of them do), you can use higher order functions!

    • @konstantinrebrov675
      @konstantinrebrov675 Год назад

      @@peppidesu I don't know how to make them in C.

    • @CarlBach-ol9zb
      @CarlBach-ol9zb Год назад

      @@konstantinrebrov675, you can do it in C++, I think. C++11 and latter ones have lambda expressions. May not be as elegant as in Haskell or other Functional Programming languages.
      In C, you can pass functions to other functions via their pointers and dereference, but this will be kind of a bad practice, and it's limited.

    • @konstantinrebrov675
      @konstantinrebrov675 Год назад

      @@CarlBach-ol9zbOk

    • @aev6075
      @aev6075 Год назад

      It's pretty easy on C++. You can make lambdas and callback function with function pointers aswell.

  • @adriansomor
    @adriansomor 11 месяцев назад

    amazing series

  • @GustavoSpaki
    @GustavoSpaki Год назад

    Great video :D

  • @dootsi9452
    @dootsi9452 Год назад

    great video

  • @WayOfTheCode
    @WayOfTheCode Год назад

    Amazing videos

  • @BashkaMen
    @BashkaMen Год назад

    What is name of font?

  • @yash1152
    @yash1152 Год назад

    8:01 whatttt?

  • @cemgecgel4284
    @cemgecgel4284 Год назад +1

    I do not like Haskell's whitespace sensitive syntax. I would prefer a simple functional language with a simple C-like syntax.

    • @Yogesh-kr7bo
      @Yogesh-kr7bo Год назад +1

      It's just a syntatux sugar you can use the C-like syntax

    • @0LoneTech
      @0LoneTech 11 месяцев назад

      Specifically this is discussed in the Haskell language report section 2.7 Layout:
      "Haskell permits the omission of the braces and semicolons used in several grammar productions, by using layout to convey the same information. This allows both layout-sensitive and layout-insensitive styles of coding, which can be freely mixed within one program. Because layout is not required, Haskell programs can be straightforwardly produced by other programs."

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

    COME BAAAACK

  • @flikkie72
    @flikkie72 Год назад

    Wow you sounds so, so similar to Rutger Bregman

  • @null-0x
    @null-0x 4 месяца назад

    5:10, 7:37 "...in an upcoming video..". Well, there is none.

  • @Treston-ri7of
    @Treston-ri7of Год назад +2

    A good use of showing anonymous functions to cybersec students, this is how you reel them from crow into the functional programming & math pipeline

  • @sunofabeach9424
    @sunofabeach9424 Год назад

    cool. now write UI

    • @0LoneTech
      @0LoneTech 11 месяцев назад

      UI for what? Would you like it in Monomer, Brick, Reactive Banana, Grapefruit, Concur, Reflex...?