260 likes | 391 Views
F#. Steven Anderson Tyler Stigliano. Overview . Introduction History Purpose Main Features Code Examples Final Remarks. Introduction. Targets .NET framework Intertwine with other .NET languages (C#, C++, VB) Variant of ML Largely compatible with OCaml syntax Functional Language
E N D
F# Steven Anderson Tyler Stigliano
Overview • Introduction • History • Purpose • Main Features • Code Examples • Final Remarks
Introduction • Targets .NET framework • Intertwine with other .NET languages (C#, C++, VB) • Variant of ML • Largely compatible with OCaml syntax • Functional Language • With object oriented and imperative disciplines
History • Developed by Don Syme • Being developed at Microsoft Development Division • Releases • Version 1.0 – 2005 • Version 2.0 – 2010
Purpose • To combine multiple programming paradigms into one • Functional Programming • Scientific modelers, mathematicians, financial institutions and more • Heavy number crunching • Get problems solved in a concise manner • Higher-Order functions • Type Inference
Purpose cont. (Use Case #1) • Banking Firm in Europe • Uses mathematic models to manage investment portfolios • Built small units of functionality and combined them to create a model • Claims to have sped development by 50% • Quotes • “We could not have developed 200 models in two years without F# and Visual Studio” • “With a functional language like F#, we can create simple, compositional code, and so we naturally see a high degree of code reuse”
Purpose cont. (Use Case #2) • Major energy company in UK • Application to balance national power generation schedule • Benefits • “Sweet spot” for algorithmically complex analysis of large data sets • Units of measurements • Used c++ to build interface; injected F# to do calculations • Code reduction • Parallelism
Main Features • Characteristics • Strongly Typed • Immutable vs. Mutable • Eager evaluation • Parallelism • Encompasses: • Functional Programming • Imperative Programming • Object-Oriented Programming
Main Features • Functional Programming • Functions as Values • Function Composition • Type Inference • Automatic Generalization • Pattern Matching • Lambda Expressions • Code Quotations
Main Features • Imperative Programming • Control Flow • Arrays • Mutable Collections • Basic I/O • Exception Handling • Object-Oriented Programming • .NET Framework Object Model • Data Encapsulation • Operator Overloading • Type Extensions
Code Examples Structure of F# program
Code Examples Immutable Variables
Code Examples Mutable Data
Code Examples Function Declaration
Code Examples Function Return Values
Code Examples Recursion
Code Examples Nested Functions
Code Examples Pattern Matching
Code Examples Tuples and Records
Code Examples Tuples and Records cont.
Code Examples Arrays
Code Examples Loops
Code Examples Additional Features • Higher-Order Function • Option Types • Lists & Sequences • Classes • Advanced Data Structures
Final Remarks • Current Compilers • Sharp Develop (www.icasharpcode.net) • MS Visual Studio 2010 (www.msdn.com)
References • http://en.wikibooks.org/wiki/F_Sharp_Programming/Basic_Concepts • http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/ • http://blogs.msdn.com/b/dsyme/archive/2011/01/12/f-for-energy-trading-and-energy-portfolio-optimization.aspx • http://msdn.microsoft.com/en-us/vstudio/hh388569.aspx
F# Steven Anderson Tyler Stigliano