Functional Programming in C#

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

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

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

    I have used language extensions which encapsulates the ideas mentioned here so no need to write own version. Great talk.

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

      While not covered in video I actually saw just now that the slides talk of language extensions as well.

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

      Yeah, LangExt is out there & seems fine. I'm not necessarily advocating everyone to go out and write your own implementation of this, but I think it's important to know how you *might* do it, to help with understanding.

  • @ProgrammingMadeEZ
    @ProgrammingMadeEZ 4 года назад +6

    Pattern matching in C# 8 is much improved since this video was released.

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

      Very true. I'd also strongly recommend looking at the new Record types in C#9. They're one of the best functional features in a while

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

    Just in case people have not noticed yet, .Net has also native, functional-first programming language called F#.

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

      It absolutely does. I've never learned it myself, but I'd be happy to if I were in a team that was up for it. Sadly I still think we're a long way away from mainstream support for F#, so there's nothing wrong with trying to make use of those same principles in C# itself.

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

    I found this workshop handy. Although, I code in Typescript now. I have done .NET / C# for 8 years.
    Maybe I can find some use for this in the game development space. There is a UI/User interaction, but I suppose that's where I'd do plain old OO, and where we process gamedata and models, rather use Pure functions where possible.

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

    Can You please share the slides? This is super handy! Thanks for the useful video!

    • @madsimonj
      @madsimonj 4 года назад +1

      Thanks! I've just popped a link to the slides up

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

      @@madsimonj I have a question, until now I thought I've been doing FP in javascript but I guess I'm not. Sometimes I'm still using some ifs inside my function (probably just to check if the input is null) and then you said that there are no if statement in FP.
      So how does the real FP handle the if condition? using ternary operator? (I saw that in your slides) and if it does use ternary, doesn't it just the same?
      Btw, superb presentation!

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

      @@hirisraharjo the ternary expression is an operator, not a statement, so its fine. Its a quick way of performing somd logic, but without the messy tendencies of true If statements. Also- thanks. I'll try and make more when I have time

  • @FXK23
    @FXK23 4 года назад +2

    Great talk. Missing the Zoran Horvat courses on pluralsight in your 'Further reading' section.

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

      I'm afraid I don't have a pluralsight subscription. Please feel free to share the link, though.

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

    The nino validation returns true or false. How could it return and explanation on why it failed?

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

    Great talk!

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

    Awesome

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

    Codes are not fully visible ,which hinders my understanding.

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

      Apologies for that. I've done this same talk for a number of other venues. The code is probably easier to read on some of those. If you check out the NDC Conferences channel, you'll find an updated version of this I did for NDC Porto earlier this year

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

    Good intro but can't agree that FP is bad for UI programming!

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

      it's not that it's bad, per se. It's more that you have to make some sort of compromise at that point.

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

    Woaaah

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

    I'm sorry, I think I have looked everywhere for the link to the slides?? Anyone see it?

    • @mikepike2000
      @mikepike2000 4 года назад +1

      Found it.. he left off the h so it didn't appear to be a link: www.dropbox.com/s/wfcug5871erbfzc/Functional%20C-Sharp%20-%202020-01.pptx?dl=0

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

      Thanks Micheal, We'll stick it in the description too!

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

    When is Functional Programming *not*: UI
    React: I beg to differ

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

      Elm: B**** please :P

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

      It's not that Functional can't do UI, it's more that compromises have to be made at that point. You can't write an applicaiton entirely of side-effect free pure functions and still have external interactions.

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

    I would have watched more of this but many of the slides are cut off at the bottom, which is very annoying. The first 10 minutes talk about how wonderful functional programming is, the implication it is better then OO, which is not true. Both paradigms have their advantages and disadvantages.
    I'm a programmer of more than 20 years and I am always happy to learn and try new things, but forcing an OO language to use functional paradigms is a bit like using a spanish guitar to play heavy metal - it's just plain wrong. If you want to do functionla programming use a functional programming language!
    Functional programming does not hold state and is stateless? And becasue of that it is great at data processing. But as it is stateless what data does it process? Immutablity is where you get better thread safety and while that concept may have originated from the mathematical functional world it's not a functional programming feature, you can create immutable classes in c# (and I have been for years), that doesn't make it functional.

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

    Also, for anyone interested, my website & blog are here:
    www.thecodepainter.co.uk

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

    As far as i know there's no difference between linq select and map

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

      There is. Select operates exclusively on Enumerables (and derivatives) an element at a time, so 'x' for a Select statement is an individual item in an array of some kind. Map operates on _any_ object and on the whole object, so you could call Map on a string, or an integer. If you called Map on an Enumerable, then 'x' would be the entire enumerable, not just a single element of it.

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

      @@simonpainter2242 but what would be the practical difference when running it on a collection?

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

      @@emilorefors6277 if you passes an arrow function with a parameter 'x' to a Select statement on at Enumerable, then the type of x is T.
      If you called Map on that same Enumerable, then x would have the type Enumerable.
      I.e. map operates on the whole original object, not just individual elements within it

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

      @Simon Painter im pretty sure this is not how it works. For example, map in javascript and also in f#, will both have x being the type of T

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

      @@emilorefors6277 you're right, but we have Select in C# that performs the same role as Map in JS. I _could_ have called it Bind too, but I thought that Map was a friendlier name

  • @joandimko3063
    @joandimko3063 4 года назад +1

    some code samples are cut and not readable :-(
    and you are talking about readability :-)

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

      Which ones? I can pass you a copy of the slides, if you like?

    • @dotnetsheff
      @dotnetsheff  4 года назад +2

      That's our fault, not the speakers, HDMI recording seemed to have been cropped 😢 sorry about that.

    • @madsimonj
      @madsimonj 4 года назад +2

      I've added a link to the slides now

    • @ayoubihbibibi2404
      @ayoubihbibibi2404 4 года назад +6

      why are you like that ? we have free and great explanation on functional programming , and you are still not happy ...you could have stopped with the first line of your comment. Please reboot or format/ reinstall your mindset ...you will make life very hard for you and people around you otherwise :(

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

    I have used language extensions which encapsulates the ideas mentioned here so no need to write own version. Great talk.

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

      I agree. No need, but its a good learning exercise & I think the syntax can be cleaner sometimes when you roll your own compared to LanguageExt