Phillip Trelford Blog:

Slides:



Advertisements
Similar presentations
Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Advertisements

1 Matchete Paths through the Pattern Matching Jungle Martin Hirzel Nate Nystrom Bard Bloom Jan Vitek 7+8 January 2008 PADL.
Intro to Python Welcome to the Wonderful world of GIS programing!
A Crash Course Python. Python? Isn’t that a snake? Yes, but it is also a...
C# Console Application
The F# language Tomáš Petříček Microsoft C# MVP
Introducing the Erlang Language Why Erlang?  Exemplifies the “you can have code and concurrency that is free from side effects…there is no other way”
Programming in Scala Chapter 1. Scala: both object-oriented and functional Scala blends –object-oriented and –functional programming in a –statically.
F# Shiva Srivastava David He Peter Bingel. Overview F# (pronounced "F sharp") is a functional and object oriented programming language for the Microsoft.NET.
CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Winter 2013.
Living Requirements using Behavior Driven Development
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
Introduction to Functional Programming (SCALA) John Woodward.
1-Sep-15 Scala Apologia. 2 Java What’s wrong with Java? Not designed for highly concurrent programs The original Thread model was just wrong (it’s been.
Object Oriented Programming Class
MONGODB NOSQL SERIES Karol Rástočný 1. Prominent Users 2  AppScale, bit.ly, Business Insider, CERN LHC, craigslist, diaspora, Disney Interactive Media.
Data Formats CMSC 491 Hadoop-Based Distributed Computing Spring 2015 Adam Shook.
JSON The Fat Free Alternative to XML. Data Interchange The key idea in Ajax. An alternative to page replacement. Applications delivered as pages. How.
An introduction to F# Bogdan Brinzarea-Iamandi Banca Romaneasca 22 February 2010.
CS1022 Computer Programming & Principles Lecture 1.2 A brief introduction to Python.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Subject: Programming in C++ 1. LEARNING OUTCOME  At the end of this slide, student able to:  Know the brief history of C++.  Explore Microsoft Visual.
Conditionals CS 103 February 16, Blast from the Past: C14 Dating Problem Statement: Calculate the age of a fossil from its C-14 radioactivity Problem.
Functional Programming Language OCaml Tutorial 科大 - 耶鲁联合研究中心
Reactive pattern matching for F# Part of “Variations in F#” research project Tomáš Petříček, Charles University in Prague
Today we’re gonna talk about… therightabstractions.com.
Homogeneous tuples What are they? –S 2 = S x S –S n = S x S x … x S Cardinalities –#(S 2 )= (#S) 2 –#(S n )= (#S) n –#(S 0 )= (#S) 0 =1 What is S 0 ? –It.
24 HOURS LATER Phillip Build Stuff, Lithuania, 2014.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
6-Feb-16 Scala Apologia. 2 Java What’s wrong with Java? Not designed for highly concurrent programs The original Thread model was just wrong (it’s been.
Jonathan Aneja Program Manager Microsoft Corporation Session Code: DTL336 Anders Hejlsberg Technical Fellow Microsoft Corporation.
1 Objective Caml (Ocaml) Aaron Bloomfield CS 415 Fall 2005.
Programming for Beginners Course Introduction SoftUni Team Technical Trainers Software University
uses of DB systems DB environment DB structure Codd’s rules current common RDBMs implementations.
Phillip Trelford 1. Goals Introduce F# Non-goals Cover every language feature Mass conversion to FP cult Sell books 2.
Phillip Trelford Blog: 1.
Apache Avro CMSC 491 Hadoop-Based Distributed Computing Spring 2016 Adam Shook.
13-Jun-16 Scala Apologia. 2 Java What’s wrong with Java? Not designed for highly concurrent programs The original Thread model was just wrong (it’s been.
Lucian Wischik SESSION CODE: DEV401. Advanced Use of the New Microsoft Visual Basic 2010 Language Features Lucian Wischik, VB spec lead.
Programming Languages 2nd edition Tucker and Noonan
CSE341: Programming Languages Lecture 11 Type Inference
Principles of programming languages 12: Functional programming
dr Robert Kowalczyk WMiI UŁ
Outline Introduction Programming in eclipse Debugging in eclipse
Programming Languages Dan Grossman 2013
Outline Introduction Programming in eclipse Debugging in eclipse
Functional Programming
ML: a quasi-functional language with strong typing
Zane Moser.
Designing a DSL in KOTLIN
slides created by Marty Stepp
Functional Programming in a Nutshell with Haskell and F#
Type system of Go/C# Seminar
Data.
EXTENSION AND INTEGRATION
FP Foundations, Scheme In Text: Chapter 14.
CSE341: Programming Languages Lecture 11 Type Inference
Closure Closure binds a first-class function and a lexical environment together This is a complex topic, so we will build up our understanding of it we.
Scala Apologia 1-Jan-19.
CSE341: Programming Languages Lecture 11 Type Inference
Madhusudan Parthasarathy (madhu) 3112 Siebel Center
CSE341: Programming Languages Lecture 11 Type Inference
What is TypeScript, and Should You Care?
CSE341: Programming Languages Lecture 11 Type Inference
CSE341: Programming Languages Lecture 11 Type Inference
Presentation transcript:

Phillip Trelford Blog:

Talk Goals Goals Introduce F# Non-goals Provide in-depth understanding Mass conversion to functional programming cult Sell my own books

Talk Structure 1. Background 2. Language Syntax 3. Code Samples

Jargon Buster OO = Object Orientated FP = Functional Programming Lambda = Anonymous Function DSL = Domain Specific Language

What is F#? F# is multi-paradigm language, that is: Functional Declarative Object Orientated Imperative.Net language with VS integration (a bit like Python)

Languages circa 2010 Functional Clojure Erlang F# Haskell Scala Dynamic Groovy JavaScript Python Ruby OO C++ C# Java VB.Net

Functional Programming Key Features Functions are idempotent Functions are first class High order functions Languages: Scala Excel JavaScript

Real World FP Erlang Document DB: CouchDB, Amazon Simple DB Messaging: RabbitMQ, ejabberd F#/OCaml Financial: Credit Suisse, Jane Street Capital, UBS Technical Halo3,Bing Haskell Academic

A Brief History of F# Created in 2002 by Don Syme (Microsoft Research Cambridge) (Creator of.Net Generics & Cup holder) Influenced by OCaml (1996) ML (1973) Mission: First class functional programming for.Net

Books

F# Community RSS: Microsft F# Developer Center Forums: HubFs London F# User Group

Performance

Conditions C#: int x; If(result) x = 1; else x = 0; F#: let x = if result then 1 else 0 C#: var x = result ? 1 : 0;

Light syntax (like Python) F#: if total > 21 then print "Bust" Python: if total > 21: print "Bust”

Tuples NameExample Single(1) Pair(1,2) Triple(1,2,null) Quadruple(1,2,3.0, null) Quintuple Sextuple Septuble Octuple Nonuple Decuple

Tuples F#: let me = (“Phil”, Male, 1.92, 1971) let name, sex, height, year = me C# (.Net 4.0): var me = PhiPTuple.Create(“Phil”,1971); var name = me.Item1; C++ (Boost ): Ticker ticker = make_tuple(“Barclays”, , ) double price = get (ticker);

Partial Application F# let times x y = x*y let tenTimes = times 10.0

Composition let (|>) x f = f x F# Code Sample "*.cpp", SearchOption.AllDirectories) |> Array.filter (fun name -> File.GetLastWriteTime(name) > DateTime.Now.Date) |> Array.map (fun name -> name, using (File.OpenText (name)) (fun reader -> reader.ReadLine()) ) |> Array.iter (fun (name, firstLine) -> Console.WriteLine (name) Console.WriteLine (firstLine))

Classes type Child(name,age) = member this.Name = name member this.Age = age override this.ToString() = sprintf "%s %d" name age

Records type Child = { Name:string; Age:int } with override this.ToString() = sprintf "%s %d" this.Name this.Age

Discriminated Unions type Child = Child of string * int type Sex = Male | Female type Tree = | Branch of Tree * Tree | Leaf of 'a

Automating Acceptance Tests Scenario X: given a customer buys a black jumper type ``Scenario X`` = let basket = Basket() member this. ``given a customer buys a black jumper`` = basket.Add(“Black Jumper”,1)

Gotchas Order of declaration of functions and modules Values may be redefined Obscure syntax, e.g. what is :?>

F# Strengths F# MathSuccinct Language Orientated Concurrency.Net Integration

Demos