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.
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.
@@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!
@@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
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
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.
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 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 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
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.
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 :(
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.
Pattern matching in C# 8 is much improved since this video was released.
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
Just in case people have not noticed yet, .Net has also native, functional-first programming language called F#.
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.
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.
I am trying to apply functional C# in unity engine too
Great talk. Missing the Zoran Horvat courses on pluralsight in your 'Further reading' section.
I'm afraid I don't have a pluralsight subscription. Please feel free to share the link, though.
I have used language extensions which encapsulates the ideas mentioned here so no need to write own version. Great talk.
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
Can You please share the slides? This is super handy! Thanks for the useful video!
Thanks! I've just popped a link to the slides up
@@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!
@@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
Codes are not fully visible ,which hinders my understanding.
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
The nino validation returns true or false. How could it return and explanation on why it failed?
Great talk!
Thanks :)
Awesome
Thanks :)
Woaaah
That's a good "Wooah", I'm hoping!
Good intro but can't agree that FP is bad for UI programming!
it's not that it's bad, per se. It's more that you have to make some sort of compromise at that point.
I'm sorry, I think I have looked everywhere for the link to the slides?? Anyone see it?
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
Thanks Micheal, We'll stick it in the description too!
Also, for anyone interested, my website & blog are here:
www.thecodepainter.co.uk
When is Functional Programming *not*: UI
React: I beg to differ
Elm: B**** please :P
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.
As far as i know there's no difference between linq select and map
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.
@@simonpainter2242 but what would be the practical difference when running it on a collection?
@@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
@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
@@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
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.
some code samples are cut and not readable :-(
and you are talking about readability :-)
Which ones? I can pass you a copy of the slides, if you like?
That's our fault, not the speakers, HDMI recording seemed to have been cropped 😢 sorry about that.
I've added a link to the slides now
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 :(
I have used language extensions which encapsulates the ideas mentioned here so no need to write own version. Great talk.
While not covered in video I actually saw just now that the slides talk of language extensions as well.
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.