Поделиться через


What's New in Visual F# 2010

F# is a multiple-paradigm programming language for the .NET Framework that is available in Visual Studio 2010. F# supports functional programming, object-oriented programming, and imperative programming.

Features of the Visual Studio 2010 Release of Visual F#

The following sections describe some of the features that are available in the first release of Visual F#.

Support for Functional Programming

Functions are treated as values, and can be passed directly to other functions. This feature makes it easy to code higher-order functions (functions that operate on functions). This makes it easy to write more declarative code, which tends to be less error-prone.

F# supports compositional programming. You can compose and call functions in sequence by using simple operator syntax. You can combine function calls by using the pipeline operator, which enables the output or return value of one function to be given to another function as input. You can also define new functions by combining functions by using the composition operator.

For more information, see Functions (F#).

Lambda Expressions

Lambda expressions enable functions to be defined in place, without having to be named. For more information, see Lambda Expressions: The fun Keyword (F#).

Useful Data Types

F# provides types that support functional programming styles, such as tuples for simple collections of data and discriminated unions for structured symbolic data. For more information, see Tuples (F#), Discriminated Unions (F#), and Options (F#).

Immutable Data Types

F# provides immutable data structures, such as immutable lists, maps, sets, sequences, and records. For more information, see Lists (F#), Sequences (F#), and Records (F#).

Pattern Matching

The pattern matching functionality allows you to decompose data into constituent parts and perform complex branching based on the decomposition of data. Pattern matching is also extensible. For more information, see Match Expressions (F#), Pattern Matching (F#), and Active Patterns (F#).

Asynchronous and Parallel Programming

F# supports asynchronous programming, and includes constructs that make this programming easier than ever. For more information, see Asynchronous Workflows (F#). F# can also be used in conjunction with the Parallel Extensions to the .NET Framework. With the F# Power Pack, you can also use Parallel LINQ (PLINQ) with F#. For more information, see Parallel Programming in the .NET Framework.

Interactive Programming

Visual F# includes an F# interpreter, F# Interactive (fsi.exe), which compiles and executes code interactively. This enables you to easily prototype your code and try coding constructs without needing to compile a project. F# Interactive is also integrated with the Visual Studio IDE. For more information, see F# Interactive (fsi.exe) Reference.

Delayed Computations

F# supports lazy computation, which enables you to delay a calculation until a result is needed. For more information, see Lazy Computations (F#).

Support for Object Oriented Programming

F# supports object-oriented language features that give F# programs full access to the .NET Framework, in addition to letting you produce .NET Framework APIs in F#. For more information, see Classes (F#), Members (F#), and Inheritance (F#).

Support for Imperative Programming

F# supports imperative code constructs such as mutable variables and arrays, functions that have side effects, and looping constructs, for situations in which this kind of programming is the best way to solve a problem.

Support for Mathematical Calculations

F# supports mathematical calculations. This includes operator overloading support, operators that work with generics, and a full set of mathematical operators, including an exponentiation operator.

F# also features support for floating-point data that has associated units of measure, which enables unit-checked floating-point formulas.

Advanced Type System

F# supports generic programming. For more information, see Generics (F#).

F# is a statically typed language that supports type inference. This means that all program elements have a definite type at compile time, guaranteeing type safety, but that you do not have to specify the types of every value explicitly. Because the F# compiler can frequently infer the type of a program element without an explicit type being provided, code is more compact and some types of programming errors associated with type mismatches are reduced. Type inference also includes automatic generalization, which means that functions that can be generic are automatically compiled as generic. For more information, see Type Inference (F#).

Useful Libraries

Visual F# includes a set of libraries that provide support for the core language, collection types, reflection over F# assemblies, and formatted I/O. F# also provides access to the full functionality of .NET Framework 4, such as the Parallel Extensions to the .NET Framework and Windows Presentation Foundation. For more information, see .NET Framework 4.

See Also

Other Resources

F# Language Reference

Getting Started with F#