3 ms·
F# is not a functional language. Even says so in the docs: https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/ https://learn.microsoft.com/en-us/dotn
by CharlieDigital 4y ago
F# is not a functional language.
Even says so in the docs:
https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/ https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/
F# has full support for programming with objects in .NET, including classes, interfaces, access modifiers, abstract classes, and so on. For more complicated functional code, such as functions that must be context-aware, objects can easily encapsulate contextual information in ways that functions cannot.
https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/classes https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
Classes represent the fundamental description of .NET object types; the class is the primary type concept that supports object-oriented programming in F#.
https://learn.microsoft.com/en-us/dotnet/fsharp/what-is-fsharp https://learn.microsoft.com/en-us/dotnet/fsharp/what-is-fsha...
F# has full support for objects, which are useful when you need to blend data and functionality.
The underlying CIL representation of a lambda expression is an object; the functional side of .NET (whether C# or F#) is syntactic sugar on top of an OOP runtime.
(C#/.NET dev by day dabbling in F#)
- pharmakom 4y agoI don’t see how your quotes imply that F# is not a functional language.
- andix 4y agoYou can find arguments to justify any point of view :)
- CharlieDigital 4y agoIt literally says on the box that it's not a functional language and it's clear that the actual underlying CIL is class based. If you still want to call that FP, then by all means. But then so is C# since you can do nearly exactly the same things in C#.
- pharmakom 4y agoCan you quote this part?
- kaba0 4y agoAs is often the case in CS, there are no definitions for plenty of concepts. FP is simply “programming with functions”. Most languages are multi-paradigm, and in my book any language that has lambdas is already functional - but it is a spectrum. Java has ways to express functional programs, but it is of course much less functional than, Haskell - which itself is also not 100% pure FP.
- CharlieDigital 4y agoIf every language can be functional, than no languages are functional. Would you agree that C# is not functional? If you agree that C# is not functional, than F# is also not functional. Nearly every construct that can be expressed in F# can be expressed in C#.
- kaba0 4y agoNo, C# has plenty of features making functional programming possible, so it is definitely on the spectrum of FP languages. Let’s go at it from the other direction - is Haskell functional? Because it has unsafe pointer access and unsafe IO, so it can pretty much express every C# program as well, right?