|
F# FAQ
These pages document F# as a research project. You can find out all about the latest happenings with F# at the MSDN F# Developer Center. This FAQ covers some general questions about the F# language and its background as a research language. A language FAQ is being developed by the F# community on the F# Wiki. The best way to start is to download the implementation and to give the samples a try. Alternatively, the F# manual and quick tour will give you a feel for the language. The presentation Introducing F# gives an initial orientation to F#: what it is, what it is good for and the advantages it gives over other .NET languages and ML implementations. F# is derived from the ML family of languages, part of the functional programming language tradition. However, F# is not simply a functional language: it is a multi-paradigm langauge that attempts to capture the best of both functional and object-oriented programming in the context of .NET. Furthermore, even when used as a purely functional language F# is remarkable for the sheer power of the libraries and tools available through .NET. The distinctive features of all ML-family languages are strong static type checking, excellent type inference, lightweight and typesafe function types, safe and syntactically convenient discriminated unions. These core work together to allow for succinct yet efficient solutions to many programming problems, and repeatedly permit common patterns of coding to be abstracted very easily. One way of looking at it is that the purpose of F# is to solve all of the 7 major problems described in Wadler's classic paper Why no one uses functional languages: Libraries, Portability, Availability, Packagability, Tools, Training and Popularity. Of these, F# solves the issues of libraries (by immediately giving high-quality, no-wrapper access to hundreds of .NET libraries), portability (the .NET bytecode is portable, e.g. the Mono project provides an implementation for many platforms), packagability (.NET assemblies are an excellent packaging mechanism) and tools (.NET tools for other languages nearly always work with F# as well). The remaining issues are partly solved by the fact that F# has a core design similar to that of OCaml, a popular functional language implementation for which a good amount of training material is available, and also that huge amounts of excellent training material for the .NET platform is available on the web. In more detail, the aims of F# are as follows:
There are several key application areas for a language like F# on the .NET platform. In particular, such languages excel at mathematically-oriented programming, and, given the right libraries and visualization tools, a range of scientific and engineering tasks as well. These languages are also well known to be extremely powerful when used to implement sophisticated symbolic analyses such as hardware verification, software verification, optimization, machine learning and compilation. You can read about many applications of F# on Don Syme's blog. The minimal technical requirements for a powerful scientific and data-intensive .NET programming language are as follows:
Here are some of the things that make F# highly distinctive in this arena:
F# is, technically speaking, neutral with respect to concurrency - it allows the programmer to exploit the many different techniques for concurrency and distribution supported by the .NET platform. However, functional programming is one of the primary known techniques for minimizing, tracking and isolating the use of mutable state, essential for emerging techniques such as software-transactional-memory. F# can directly use multi-core programming libraries such as ParallelFX. F# also includes language and library support for asynchronous workflows, a technique to write reactive programs and asynchronous message passing agents in a natural and compositional style. One of the striking features of F# is its combination of dynamic and static features. For example, F# Interactive provides a strikingly powerful dynamic compilation environment, where dynamically entered code is executed using the full performance power of high-quality native code. Another key feature of dynamic languages is succinctness. As with previous versions of ML, F# manages to be as succinct as many dynamic languages through its use of type inference, but like-for-like computationally-intensive samples will typically execute faster than other dynamic language implementations. F# permits the use of other dynamic techniques such as a universal 'object' type, runtime code generation, runtime inspection of the properties of values and the runtime analysis of type parameters. F# doesn't share all the features of dynamic languages. For example, it is not yet easily hosted inside other applications. At a language level, some operations characteristic of dynamic languages are not permitted. Likewise, it doesn't directly target the Dynamic Language Runtime, though may do so in the future. "ML" is a language design that has had several manifestations, from Edinburgh ML to Standard ML and through to the current SML '97 and OCaml languages. F# follows the tradition of the Caml design group who seek a balance between stability and innovation. Both F# and OCaml use a simple, elegant core language and add interesting extra features. For the past several years, Ocaml has been a de-facto standard in the applied ML programming. As such, F# takes the design of core OCaml as a starting point, but combines the enormous strengths of the core OCaml language with those of .NET. |