F#
Shiva Srivastava
David He
Peter Bingel
Overview
• F# (pronounced "F sharp") is a functional and object oriented
programming language for the Microsoft .NET platform
• A strength of F# is its setting within .NET
• The core language is similar to that of the Objective Caml language:
both are members of the ML programming language family.
• Like the Scala programming language, it implements a functional
programming language on top of a platform originally designed for
object-oriented programming paradigm.
• The F# environment includes the ability to run interactive sessions,
allowing users to run pieces of code at will, collecting and analyzing
the results without having to compile whole programs.
Problem Domain
• The F# programming language has many applications ranging from
scripting to cross-platform application development
• Ideal platform for scientific computing, filling the gap between lowlevel but high-performance numerical languages like Fortran and
high-level but slow languages like Mathematica
• Can be spawned from interactive sessions, giving F# the essential
functionality of many expensive technical computing environments.
History
•
F# was initially developed by Microsoft Research, but now is being
developed by Microsoft developer division after it was announced on
October 17, 2007 that F# will be productized as a fully integrated language
in Visual Studio[1]. The latest released version, 1.9.2.9, was released on
July 31, 2007.
•
F# is derived from a series of different imperative and functional languages
as are most modern languages (including Java and C).
•
At the heart of F# lies Objective Caml, or OCaml, and the .NET language
C#.
•
So, let's leave it at this: F# is, in essence, another dialect, or "manifestation"
as Microsoft calls it, of a functional ML-like language mixed with the power
of C#.
Language Concepts
• interactive scripting like Python
• the foundations for an interactive data visualization environment like
MATLAB
• the strong type inference and safety of ML
• easy access to the entire range of powerful .NET libraries and
database tools
• The only language that is scripted/ functional /imperative/ objectoriented
Defining Variables
let x = 3 + (4 * 5)
let res = (if x = 23 then "correct" else "incorrect")
Hello World Program
• let x = "Hello World";;
System.Console.WriteLine(x);;
Interesting features
•
•
•
•
•
•
•
•
F# includes support for the foundational features of functional programming including tuples, lists,
options, function values, local function definitions, pattern matching and sequence expressions.
The powerful type inference mechanisms of F# allow code to be both succinct and yet fully typechecked.
F# also includes support for advanced functional programming constructs such as active patterns
and computation expressions. Computation expressions can be used to express data queries and
client/server modalities in AJAX-style web programming. They enable programmers to write
succinct and robust reactive agents through the use of asynchronous workflows. Computation
expressions are related to ``monads'' in Haskell.
F# embraces object-oriented programming and includes support for type-inferred, succinct
descriptions of object types.
F# allows types and values in an F# program to be accessed from other .NET languages in a
predictable and friendly way.
F# includes support for a form of meta-programming, inspired by LINQ. This allows data queries
to be expressed and type-checked in F# code and then dynamically compiled and translated to
target languages such as SQL using the LinqToSql framework.
F# fully supports .NET generics and the language was designed partly with this in mind.
Through .NET, F# supports advanced language and runtime features such as Unicode strings,
dynamic linking, preemptive multithreading, and SMP support.
Comparison with OCML
•
Some identifiers are now keywords.
–
•
Some operator names are used for quotations.
–
•
<@ some string @>
There are some minor parsing differences.
–
–
–
•
null, inline
!x.y.z
!(x.y.z)
(!x).y.z.
Two top-level definitions with the same name are not allowed within a module
or a module type.
–
–
let x = 1
let x = 3
F# Vs OCml
Similarities To Other Languages
• interactive scripting like Python,
• the foundations for an interactive data
visualization environment like MATLAB,
• the strong type inference and safety of ML,
• a performance profile like that of C#,
• a foundational simplicity with similar roots
to Scheme,
Sources
•
•
•
•
Microsoft
http://research.microsoft.com/fsharp/
Wikipedia
http://en.wikipedia.org/wiki/F#
Descargar

F# - Computer Science & Engineering