5
Elyz
4y

Do any of you all have any recommendations on how to drill functional programming concepts into my brainhole? Any good resources or things that helped you learn? My brain is object oriented and I'm really struggling to "see the light" and become another FP hypebeast (which is what I feel most people become when they really learn this stuff)

Send help
Regards,
A desperate loser who doesn't wanna fail her course 🥺🤷

Comments
  • 5
  • 3
    Abandon loops and variables.
  • 4
    My breakthrough came when we challenged each other at work to create space invader in F#.

    Of cause using ascii graphics to not make it to complex.

    It was a weeks job and very fun.

    But basically, you replace loops with either recursive calls or mapping over items. C# linq is a good example with its Select syntax.

    Or map reduce in js.
  • 3
    I'll get shot for saying this I'm sure, but despite what people say, FP is just another tool in the toolbox for solving tasks. It's not the holy grail of programming, and people that treat it like it is in every case often write some of the crappiest, most convoluted code I've seen.

    That being said - if your goal is to learn it, pick Haskell, get to work. There's no avoiding it there, it's a "pure" functional language so you can't really cheat and just do something an OO way. It's also a very nice language to learn, and some of it's more commonly useful features are slowly making their way into mainstream languages.
  • 1
    @Voxera
    Nitpicky, but reduce (catamorphism) isn't recursive. It's iterative application, or folding.

    Hylomorphisms are recursive.
  • 1
    @SortOfTested select and map reduce are mappers, not recursive call yes.

    But most already know about recursive, but mapping is often overlooked so I wanted to provide examples from the object oriented world :)
  • 3
    @Voxera
    Just making sure OP didn't come away with the conclusion that reduce was recursive. That's lost points on a test. 😸
  • 1
    @SortOfTested curriculum between this course and an earlier one already covered both but thanks 😂
  • 1
    I would say that some languages lend themselves better than functional programming than others. I learned it from Common Lisp even though it is not purely functional. For something like that to reaaaally stick I would say consider Haskell since it has no two ways of writing code, it is pure functional.

    Scala would be a good fit for training, but that language can be written without using functional programming.
  • 0
    @SortOfTested you are 100% correct, but I mean, would they still get points for properly associating reduce with the underlying category math and associative functional programing paradigms? :P
  • 2
    @AleCx04
    If you're recommending Haskell, I'd say that's a hard yes.
  • 0
    @SortOfTested ypu can also look at erlang or elixir. Buth functional languages.
  • 1
    @AlmondSauce I am of the same opinion.

    Yes functional is very good for many problems but I am not sure its the easiest for every situation.

    And I am also not sure it will preserve its readability when the project get very big.
Add Comment