What is the F# language created to accomplish?

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?


Solution 1:

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

  1. Showing it can be done.
  2. Publishing scientific papers showing it can be done.
  3. 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.]

Solution 2:

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:

  • In what areas might the use of F# be more appropriate than C#?
  • What are the benefits of using C# vs F# or F# vs C#?

Solution 3:

I have found some resources that touched on my question:

What & Why Choose F#?

How will F# be used?

Nine reasons to use F#

Why should I use F#?

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.

Solution 4:

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.