... a programming language. ...a functional programming language.

Slides:



Advertisements
Similar presentations
Developer Knowledge Sharing Eric Sun Dec, What programming language did you learn in school and since then? Now, its time to refresh …
Advertisements

The Microsoft Technical Roadshow 2007 Language Enhancements and LINQ Daniel Moth Developer & Platform Group Microsoft Ltd
Introduction to F# Scalable, Type-safe, Succinct, Interoperable, Mathematically-oriented Programming for.NET Don Syme MSR Cambridge
More ML Compiling Techniques David Walker. Today More data structures lists More functions More modules.
F# and its 11 features Guanru Li 2011 ACM class. F# is …... a programming language.
F# Overview: Immutable Data + Pure Functions. Acknowledgements Authored by – Thomas Ball, MSR Redmond Includes content from the F# team.
Type Checking, Inference, & Elaboration CS153: Compilers Greg Morrisett.
1 Smart Software with F# Joel Pobar Language Geek
ML Datatypes.1 Standard ML Data types. ML Datatypes.2 Concrete Datatypes  The datatype declaration creates new types  These are concrete data types,
Programming Languages Section 1 1 Programming Languages Section 1. SML Fundamentals Xiaojuan Cai Spring 2015.
Programovací jazyky F# a OCaml Chapter 3. Composing primitive types into data.
C# and LINQ Yuan Yu Microsoft Research Silicon Valley.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
F# Succinct, Expressive, Functional The F# Team Microsoft Developer Division Microsoft Research.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 6 Functions.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Introduction to ML Last time: Basics: integers, Booleans, tuples,... simple functions introduction to data types This time, we continue writing an evaluator.
Generic Simulator for Users' Movements and Behavior in Collaborative Systems.
CS 2104 : Prog. Lang. Concepts. Functional Programming I Lecturer : Dr. Abhik Roychoudhury School of Computing From Dr. Khoo Siau Cheng’s lecture notes.
0 PROGRAMMING IN HASKELL Typeclasses and higher order functions Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and.
Programovací jazyky F# a OCaml Chapter 5. Hiding recursion using function-as-values.
Functional principles for object-oriented
LINQ, An IntroLINQ, An Intro Florin−Tudor Cristea, Microsoft Student Partner.
An introduction to F# Bogdan Brinzarea-Iamandi Banca Romaneasca 22 February 2010.
Lambdas and Streams. Functional interfaces Functional interfaces are also known as single abstract method (SAM) interfaces. Package java.util.function.
PrasadCS7761 Haskell Data Types/ADT/Modules Type/Class Hierarchy Lazy Functional Language.
Mason Vail.  A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object.
7-1 7 Contextual analysis  Aspects of contextual analysis  Scope checking  Type checking  Case study: Fun contextual analyser  Representing types.
CSC 580 – Theory of Programming Languages, Spring, 2009 Week 9: Functional Languages ML and Haskell, Dr. Dale E. Parson.
Functional Programming With examples in F#. Pure Functional Programming Functional programming involves evaluating expressions rather than executing commands.
Functional Programming Language OCaml Tutorial 科大 - 耶鲁联合研究中心
Functions and Methods. Definitions and types A function is a piece of code that takes arguments and returns a result A pure function is a function whose.
C# 2.0 and Future Directions Anders Hejlsberg Technical Fellow Microsoft Corporation.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Inside LINQ to Objects How LINQ to Objects work Inside LINQ1.
Satisfy Your Technical Curiosity C# 3.0 Raj Pai Group Program Manager Microsoft Corporation
Advanced Functional Programming Tim Sheard 1 Lecture 17 Advanced Functional Programming Tim Sheard Oregon Graduate Institute of Science & Technology Lecture:
IAP C# 2011 Lecture 2: Delegates, Lambdas, LINQ Geza Kovacs.
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Swift. Introduced in 2014 Replaces Objective-C as “recommended development language” “safer, succinct, readable” Emphasizes type safety.
Chapter 6 Functions. 6-2 Topics 6.1 Modular Programming 6.2 Defining and Calling Functions 6.3 Function Prototypes 6.4 Sending Data into a Function 6.5.
Cs776 (Prasad)L2HOF1 Higher-Order Functions. cs776 (Prasad)L2HOF2 Higher-Order Functions A function that takes a function as argument and/or returns a.
Phillip Trelford 1. Goals Introduce F# Non-goals Cover every language feature Mass conversion to FP cult Sell books 2.
Functional Processing of Collections (Advanced) 6.0.
Enlargement Simple scale factors. Find the scale factor and the missing length ?
Luke Hoban Senior Program Manager Microsoft Corporation SESSION CODE: DEV307.
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
Functional Programming
Functional Programming
Programming Languages
CS 341 : Programming Languages
ML: a quasi-functional language with strong typing
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
New Features of C# Kuppurasu Nagaraj Microsoft Connect 2016
DotnetConf 11/19/2018 6:01 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE.
LECTURE 31: INTRO TO FUNCTIONAL PROGRAMMING
Functional Programming
Programming Languages
Objective caml Daniel Jackson MIT Lab for Computer Science 6898: Advanced Topics in Software Design March 18, 2002.
FP Foundations, Scheme In Text: Chapter 14.
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Python Primer 1: Types and Operators
CSE-321 Programming Languages Introduction to Functional Programming
Standard Version of Starting Out with C++, 4th Edition
Presentation transcript:

... a programming language.

...a functional programming language

... a functional programming language for.NET.

...a functional and object oriented programming language for.NET

...a functional, object oriented and imperative programming language for.NET

...a functional, object oriented, imperative and explorative programming language for.NET

...a multi-paradigm programming language for.NET

...a multi-paradigm programming language for.NET, ideally suited for technical, symbolic and algorithmic applications.

 General Purpose Language  Broad range of tasks  Also “A Bridge Language”  Researchers and Developers  Some Important Domains  Scientific data analysis  Data mining  Domain-specific modeling  Financial modeling and analysis  Academic

let data = (1,2,3) let f(a,b,c) = let sum = a + b + c let g(x) = sum + x*x g(a), g(b), g(c) Bind a static value Bind a static function Bind a local value Bind a local function Type inference. The static typing of C# with the succinctness of a scripting language Type inference. The static typing of C# with the succinctness of a scripting language

 Functions: like delegates + unified and simple (fun x -> x + 1) let f(x) = x + 1 (f,f) val f : int -> int Anonymous Function value Anonymous Function value Declare a function value Declare a function value A pair of function values A pair of function values predicate = 'a -> bool send = 'a -> unit threadStart = unit -> unit comparer = 'a -> 'a -> int hasher = 'a -> int equality = 'a -> 'a -> bool One simple mechanism, many uses One simple mechanism, many uses A function type

Values may not be changed Data is immutable by default Copy & Update, not Mutate

let data = (Some [1;2;3], Some [4;5;6]) val data : int list option * int list option match data with | Some(nums1), Some(nums2) -> nums2 | None, Some(nums) -> nums | Some(nums), None -> nums | None, None -> failwith "missing!" let data = (Some [1;2;3], Some [4;5;6]) val data : int list option * int list option match data with | Some(nums1), Some(nums2) -> nums2 | None, Some(nums) -> nums | Some(nums), None -> nums | None, None -> failwith "missing!"

List.mapSeq.fold Array.filter Lazy.force Set.union Map LazyList Events Async... [ ] [ for x in > (x, x * x) ] [| for x in > (x, x * x) |] seq { for x in > (x, x * x) } List.mapSeq.fold Array.filter Lazy.force Set.union Map LazyList Events Async... [ ] [ for x in > (x, x * x) ] [| for x in > (x, x * x) |] seq { for x in > (x, x * x) } Range Expressions List via query Array via query IEnumerable via query

open System.Collections.Generic let dict = new Dictionary (1000) dict.[17] <- "Seventeen" dict.[1000] <- "One Grand" for (KeyValue(k,v)) in dict do printfn "key = %d, value = %s" k v open System.Collections.Generic let dict = new Dictionary (1000) dict.[17] <- "Seventeen" dict.[1000] <- "One Grand" for (KeyValue(k,v)) in dict do printfn "key = %d, value = %s" k v Using.NET collections Mutability when needed Side effects when needed

open System.IO open System.Collections.Generic let readAllLines(file) = use inp = File.OpenText file let res = new List () while not(inp.EndOfStream) do res.Add(inp.ReadLine()) res.ToArray() open System.IO open System.Collections.Generic let readAllLines(file) = use inp = File.OpenText file let res = new List () while not(inp.EndOfStream) do res.Add(inp.ReadLine()) res.ToArray() Localization and Separation “use” = C# “using” “use” = C# “using”

open System.IO let allLines = seq { use inp = File.OpenText "test.txt" while not(inp.EndOfStream) do yield (inp.ReadLine()) } allLines |> Seq.truncate 1000 |> Seq.map (fun s -> uppercase s,s) |> Seq.to_array open System.IO let allLines = seq { use inp = File.OpenText "test.txt" while not(inp.EndOfStream) do yield (inp.ReadLine()) } allLines |> Seq.truncate 1000 |> Seq.map (fun s -> uppercase s,s) |> Seq.to_array Read lines on demand Pipelines

type Vector2D(dx:double,dy:double) = member v.DX = dx member v.DY = dy member v.Length = sqrt(dx*dx+dy*dy) member v.Scale(k) =Vector2D(dx*k,dy*k) type Vector2D(dx:double,dy:double) = member v.DX = dx member v.DY = dy member v.Length = sqrt(dx*dx+dy*dy) member v.Scale(k) =Vector2D(dx*k,dy*k) Inputs to object construction Exported properties Exported method

type Vector2D(dx:double,dy:double) = let norm2 = dx*dx+dy*dy member v.DX = dx member v.DY = dy member v.Length = sqrt(norm2) member v.Norm2 = norm2 type Vector2D(dx:double,dy:double) = let norm2 = dx*dx+dy*dy member v.DX = dx member v.DY = dy member v.Length = sqrt(norm2) member v.Norm2 = norm2 Internal (pre- computed) values and functions

type Vector2D(dx:double,dy:double) = let mutable currDX = dx let mutable currDY = dy member v.DX = currDX member v.DY = currDY member v.Move(x,y) = currDX <- currDX+x currDY <- currDY+y type Vector2D(dx:double,dy:double) = let mutable currDX = dx let mutable currDY = dy member v.DX = currDX member v.DY = currDY member v.Move(x,y) = currDX <- currDX+x currDY <- currDY+y Internal state Publish internal state Modify internal state

type MyTable(data: Set ) = let table1 = HashMultiMap.Create [ for x in data -> x.Length,x ] member x.GetStringsWithLength(n) = table1.FindAll(n) member x.GetStrings() = data member x.NumStrings = data.Length type MyTable(data: Set ) = let table1 = HashMultiMap.Create [ for x in data -> x.Length,x ] member x.GetStringsWithLength(n) = table1.FindAll(n) member x.GetStrings() = data member x.NumStrings = data.Length Immutable inputs Internal tables Publish access

Language and libraries clean-up and completion April 2008 Microsoft Research refresh release Most important language decisions finalized Foundation of F# Visual Studio integration September 2008 Current CTP Ships as part of Visual Studio 2010 Betas: Matching updates for Visual Studio 2008 Future Releases with Visual Studio 2010

 On the Web Don Syme - Luke Hoban -  Community  F# Samples