I have noticed more and more a growing number of resources for developing applications using the F# programming language and the question came to mind of what the F# language was created to accomplish. Is it made for a specific platform, for example, Desktop, Mobile Devices, Web Applications? Also, did it include features not available in other programming languages that are currently available for developing .NET applications? Also is it still possible to create applications for the desktop, mobile, and web using F# as we can use VB or C#? Also, are there other languages similar to F# that I can use to cross-check against to get a better understanding of how functional programming works?
-
20you can build anything with assembly too – David Heffernan Apr 12 '11 at 22:50
-
4@loyalpenguin Learning to program in F# can change many preconceptions about how programming always works. It can be very useful for expanding one's horizons. – Peter Olson Apr 12 '11 at 22:51
-
maybe it's a response to Scala? – devoured elysium Apr 12 '11 at 22:51
-
@Peter: that is hardly a good reason to learn F#. If change preconceptions is your goal, go straight to haskell. – devoured elysium Apr 12 '11 at 22:52
-
My point exactly. Why add another language? – Edward Apr 12 '11 at 22:53
-
@penguin: I think ohmantics is spot on. – devoured elysium Apr 12 '11 at 22:54
-
15F# came out of Microsoft Research, Don Syme was the lead. MR is a bit annoying, they keep creating projects that turn into actually usable products. We'll have @ohm whip them to behave like real scientists. – Hans Passant Apr 13 '11 at 00:56
-
1@Hans Passant so will F# be a usable language for developing applications (web, mobile, desktop, etc) or is more of a "special occassion" type of language? – Edward Apr 13 '11 at 01:53
-
3*That's* the kind of question you can ask without it getting closed. – Hans Passant Apr 13 '11 at 02:01
-
2http://stackoverflow.com/questions/952318/what-are-the-benefits-of-using-c-vs-f-or-f-vs-c http://stackoverflow.com/questions/141985/why-should-a-net-developer-learn-f http://stackoverflow.com/questions/159356/why-is-f-so-special http://stackoverflow.com/questions/328329/why-should-i-use-f – Mauricio Scheffer Apr 13 '11 at 04:22
-
@Maurcio this is great. I'm still wondering though what languages are similar to F# so I can cross check. Any ideas? – Edward Apr 13 '11 at 04:39
-
3Good question. Although there already are discussions about the qualities and weaknesses of F# compared to other language, this question touches the history and original intent of the creators of F#. – Joh Apr 13 '11 at 07:24
5 Answers
What is the F# language created to accomplish?
The F# research project sought to create a variant of the OCaml language running on top of the .Net platform. A related project at MSR Cambridge, SML.NET, did the same for Standard ML. (OCaml and Standard ML are both variants of the ML language.) The motivations for this might have included
- Showing it can be done.
- Publishing scientific papers showing it can be done.
- Because ML is incredibly cool.
This shouldn't distract you from the fact that the F# product is a general-purpose programming language for the .Net platform. The benefits of F# extend across all domains. There may be users who are adopting F# more rapidly - scientific and financial programming are often mentioned - but the real reason for that is because those organizations are more amenable to adopting new technology (small teams, smart people, few managers).
Is it made for a specific platform for example Desktop, Mobile Devices, Web Applications?
No.
Also did it include features not available in other programming languages that are currently available for developing .NET applications?
Yes. They include:
- Algebraic datatypes
- Pattern matching
- Type inference
- Succinct syntax
- Sequence expressions
- Asynchronous workflows
- Units of measure
Also is it still possible to create applications for the desktop, mobile, and web using F# as we can using VB or C#?
Yes but the tooling in VS2010 is incomplete. In particular, anything involving code-generation isn't well supported e.g. WPF code-behind and the Winforms designer. This may not be a problem in practice. For instance WPF with MVVM works fairly well.
Also are there other languages similar to F# that I can use to cross check against to get a better understanding how functional programming works?
Yes. Have a look at these:
- Standard ML
- OCaml
- Haskell
- Clojure
[Edit: Added comment about tooling in VS2010.]

- 10,555
- 15
- 68
- 131

- 1,827
- 12
- 15
-
4This answer needs an update after improvements made to C# over the last couple of years. – Thorkil Holm-Jacobsen Jan 22 '17 at 09:42
F# was created to bring a functional programming language to .NET.
It isn't intended for any particular platform. According to Microsoft Research, it "has particular strengths in data-oriented programming, parallel I/O programming, parallel CPU programming, scripting and algorithmic development". F# is used for financial and scientific applications in particular.
C# was created for Microsoft to have a modern C-like language since they were restricted from extending Java to take advantage of Windows. It was designed to be a component-oriented language and isn't specialized for the Web in any way.
F# is primarily a functional language whereas C# and VB are both primarily object-oriented.
See also:

- 1
- 1

- 98,437
- 31
- 224
- 236
-
Man, why all the upvotes on this question (which I'm sure has been repeated) and why the downvote for this answer? – Jay Riggs Apr 12 '11 at 22:51
-
I don't know why the downvote. I just entered a simple sentence to start with while I add more as I compose it in my head. – Mark Cidade Apr 12 '11 at 22:52
-
1@Mark Cidade yes I read that it is a functional programming language. But what does it help us do when developing applications that C# doesn't? Objected Oriented development languages seem to address quite a few scenarios of projects (desktop, mobile, web) we run into on a normal basis. What benefit does a functional programming language like F# present? – Edward Apr 12 '11 at 23:05
-
@Mark thanks for the links but I guess my question is not to compare C# and F# but more of why I would want to use F# in the first place. Really this question could be directed at VB but I just chose C# because thats my primary language. – Edward Apr 12 '11 at 23:32
-
1The discussions in the linked questions give reasons for using F# in itself. – Mark Cidade Apr 12 '11 at 23:55
-
5@loyalpenguin, most of the F# benefits are not directly related to its functional nature. It is a language with support for type inference, algebraic data types and pattern matching. You simply can't to anything comparable with C#. For example, a compiler in F# is 10 times shorter and easier to read than the similar implementation in C#. – SK-logic Apr 13 '11 at 00:11
-
@SK-login thats interesting. Never looked at it from that perspective. Although it would be nice to know when using one over the other would make our life easier. – Edward Apr 13 '11 at 00:17
-
1@loyalpenguin, F# shines in any problem domain where you need complex data structures (e.g., compilers, NLP, logic); It is relatively good (at least much better than C#) in scientific computing, but of course a specialised language and environment will be better there. – SK-logic Apr 13 '11 at 00:20
-
@SK-logic this is good to know. So if I understand you correctly F# can not be a used to replace say VB or C#? It was made as a specialized language for certain applications? – Edward Apr 13 '11 at 01:56
-
No, F# is a general-purpose language. It just has features that make it easier to write complex apps, especially if they have a lot of math. – Mark Cidade Apr 13 '11 at 01:57
-
1@loyalpenguin "most of the F# benefits are not directly related to its functional nature". I could not agree more. F# is a clean fresh .NET language. C# is old enough to have accumulated quite a few design mistakes. – Joh Apr 13 '11 at 07:28
-
@Joh, in fact, ML is much, much older than C# and just a little bit younger than C. It is cleaner simply because it had an academic origin with a very well researched foundation, whereas C# is product of evolution, with all that rudimentary tails, appendices, genetic diseases etc. – SK-logic Apr 13 '11 at 10:27
-
1@loyalpenguin, most of the practical problems are somehow related to data structures, so F# is pretty much a general purpose language. I do not know of any practical areas where VB.NET or C# will fit better than F#, besides various code generators (like WinForms designer or Linq2Sql model designer). – SK-logic Apr 13 '11 at 10:30
-
@loyalpenguin: "if I understand you correctly F# can not be a used to replace say VB or C#" Perhaps I can highlight a flaw in your logic by inverting it. Equivalently, C# has `goto` but F# does not so C# can be better for applications that benefit from this. Therefore, C# is a domain specific language that could not replace F# or VB. As you can see, this makes no sense. Both languages have strengths and weaknesses but they are still both general purpose languages. – J D Apr 13 '11 at 15:14
I have found some resources that touched on my question:
When does it make sense to use F# over C# or VB.NET
From what it looks like there is no clear answer as is usually when trying to determine to use a particular language. Although I have never used functional programming before from some of the examples I have seen it can be extremely useful. It seems like another great option when developing .NET applications.
When trying to take advantage of ideas from functional programming, such as the focus on immutability, and optimizations that can come from this, including using tail-end recursion, you will find that it is possible to improve the readability of the code, improving on maintainability.
But, by using a language such as F# is makes it easier to do language-oriented programming (http://en.wikipedia.org/wiki/Language-oriented_programming), as you create domain-specific languages, so, for example, you can write a small language for a chemist where they use the terms they are familiar with to write equations, or to model molecules, and the program can parse that and react with the expected behavior.
Because C# is so object-oriented, it makes it harder to have the language be so simple to use, as, in F# you can skip the '.' in method calls, so Jacob buys 100 shares of IBM
because a series of function calls.
Concurrency is simpler due to some of the constructs, such as previously mentioned immutability, so, some of the features we see in F# will probably help improve on C#.
So, F# helps MS to get into areas, such as science programming and modeling, as it is better than C# for these, due to these and other benefits from the language.
But, you can also use the .NET assemblies, and if you write your code well, you can do the math intensive parts in F# and have C# or VB.NET call your functions, so we can use the best language for each task.
UPDATE:
After reading some of the new comments, one area that has become a problem is how to write good code that takes advantage of multi-core CPUs. So, functional programming has become more popular, as seen by F#, Scala, Clojure, naming just a few, so MS went into this to help programmers take better advantage of the new chip architectures.

- 1
- 1

- 41,583
- 10
- 86
- 166
-
-
2@Mark Cidade - My attempt at explaining a DSL that is possible with F# that isn't with C#, since in C# you would need to do Jacob.buys(100, "IBM"), for example. – James Black Apr 12 '11 at 23:26
-
If you watch this video by Don Syme maybe you'll get some of the answers you're looking for.
update After watching the video it would seem that he created it because at the time (1998) he didn't like Java or what he saw of C# but liked functional programming like OCaml. Since he worked for MS research he wrote F#.
I imagine the genisis of a number of languages that target the cli (A#, ronPython, IronRuby, etc) are similar.

- 51,984
- 12
- 96
- 155