4 ms·
Not trying to contradict you, but I think C# is special in than it has absorbed a lot of things from the academic functional programming world and presented the
by zengid 8y ago
Not trying to contradict you, but I think C# is special in than it has absorbed a lot of things from the academic functional programming world and presented them in a nice 'friendly' form for the masses; IE, LINQ; first class functions like delegates and Func<> and Action<>; and now tuples and pattern matching in C# 7 (among many other things).
I know having mutability the default still lets one shoot themselves in the foot (and nullable reference types), but I'm always impressed when I find more of the nice FP ideas baked into the language. It's a pretty good compromise for me.
- jasim 8y agoMy cursory experience with C# was very pleasant too, and Erik Meijer managed to put in some monads into the language thru LINQ when no one was looking (https://queue.acm.org/detail.cfm?id=2024658 https://queue.acm.org/detail.cfm?id=2024658) Java 8 was a joy to work with as well - FP is filtering down through lambdas and map, filter, fold et al.
- markdoubleyou 8y agoGreat article, thank you for sharing!
- bad_user 8y agoFunctions in C# aren't really first class. A static method for example isn't a Func< > or an Action< > and neither are normal methods, both of which are prevalent. To say that C# has first class functions is a misnomer. And on anonymous methods (delegates), Func< > and Action< >, that there's even a difference between the 3 shows C#'s age and some of its quirks. > now tuples and pattern matching in C# 7 Note the pattern matching in C# is a far cry from what you get normally in FP languages. First of all C# does not have ADTs, which means it cannot do exhaustiveness checking, making pattern matching only a superficial syntactic sugar. Tuples are nice though. > academic functional programming world and presented them in a nice 'friendly' form This is sort of a marketing myth. C# is not an FP language and I rarely see actual FP built in C# (same goes for Java). In my opinion you should try out the languages in the "academic functional programming world". Because you'll then notice that C#'s way of doing things is not "friendly", unless by that you mean half baked and annoying ;-)
- zengid 8y agoI totally agree that FP in C# isn't super nice (its clear that it's bolted on) but to match the style of my co-workers, I can't do much more than sneak in a few little things here or there. The bulk of the code is clearly OOP, and I've accepted that, but at least I can have a little fun with some LINQ and a few extra vars that I don't mutate. :)
- bad_user 8y agoTrue :-)
- Bizarro 8y agoFP is a style of programming and not a language. You can write imperative code in Haskell.