Phillip Trelford 1. Goals Introduce F# Non-goals Cover every language feature Mass conversion to FP cult Sell books 2.

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

F# and its 11 features Guanru Li 2011 ACM class. F# is …... a programming language.
... a programming language. ...a functional programming language.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
A Crash Course Python. Python? Isn’t that a snake? Yes, but it is also a...
James Tam Object-Oriented Design Approaches to object-oriented design Some principles for good design Benefits and Drawbacks of the Object-Oriented Approach.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
Introduction to ML Last time: Basics: integers, Booleans, tuples,... simple functions introduction to data types This time, we continue writing an evaluator.
Mark Hennessy CS351 Dept Computer Science NUI Maynooth 1 Types CS351 – Programming Paradigms.
What’s new in ASP.NET 3.5? Mike Ormond Developer & Platform Group Microsoft Ltd
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
F# Shiva Srivastava David He Peter Bingel. Overview F# (pronounced "F sharp") is a functional and object oriented programming language for the Microsoft.NET.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
Programming Languages
F# Chris Mattera. Outline History of F# Resistance to F# Why use F#? Setting up Demonstration of F# F# for president 2008 F# takes over the world.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
An introduction to F# Bogdan Brinzarea-Iamandi Banca Romaneasca 22 February 2010.
Chapter 1. Introduction.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
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 Languages and Design Lecture 7 Subroutines and Control Abstraction Instructor: Li Ma Department of Computer Science Texas Southern University,
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
Do it now activity Last term we learnt about how data is represented in a computer and about how to identify different volumes of data. How many bits in.
CSE 131 Computer Science 1 Module 1: (basics of Java)
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
CSC 580 – Theory of Programming Languages, Spring, 2009 Week 9: Functional Languages ML and Haskell, Dr. Dale E. Parson.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
Robert Vitolo CS474.  Branched off of ML (metalanguage)  Developed at Microsoft, available as part of the Visual Studio 2010 software package, integrated.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
Functional Programming Language OCaml Tutorial 科大 - 耶鲁联合研究中心
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Python Functions.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
An Introduction. What is Python? Interpreted language Created by Guido Van Rossum – early 90s Named after Monty Python
CMSC 330: Organization of Programming Languages Functional Programming with OCaml.
CMSC 330: Organization of Programming Languages
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
OOP Basics Classes & Methods (c) IDMS/SQL News
1 Objective Caml (Ocaml) Aaron Bloomfield CS 415 Fall 2005.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Phillip Trelford Blog:
Phillip Trelford Blog: 1.
Chapter 1. Introduction.
Principles of programming languages 12: Functional programming
CS 341 : Programming Languages
CS 61C: Great Ideas in Computer Architecture Introduction to C
CS4450: Principles of Programming Languages
Functional Programming in a Nutshell with Haskell and F#
Chapter 3: Understanding C# Language Fundamentals
MIS Professor Sandvig MIS 324 Professor Sandvig
CSE 341: Programming Langs
Functional Programming
Module 2: Understanding C# Language Fundamentals
Creating Your First C Program Using Visual Studio 2010
Creating Your First C Program Using Visual Studio 2010
Reference semantics, variables and names
CS410 – Software Engineering Lecture #5: C++ Basics III
Troubleshooting Compiler Errors
Presentation transcript:

Phillip Trelford 1

Goals Introduce F# Non-goals Cover every language feature Mass conversion to FP cult Sell books 2

1. Background 2. Programming Syntax 3. Code Sample 3

F# is multi-paradigm language, that is: Functional Object Orientated Imperative (A bit like Python) It also happens to be: A first class.Net language with Visual Studio integration 4

A paradigm where computation is declared as math functions: Avoiding state and mutable data Think C++ const correctness as the default Functional Programming Examples: Haskell Excel JavaScript 5

Target communities Scientific (Microsoft Research, AdCenter) Academic (French Universities use OCaml) Financial (Morgan Stanley, Credit Suisse) Target problem domains Maths Meta programming Scripting 6

Created by Don Syme (Microsoft Research Cambridge) (Creator of.Net Generics & Cup user) Influenced by ML OCaml To provide first class functional programming for.Net 7

Visual Studio integration Product announced on Somasegar’s blog (Oct 2007) CTP release available from MSDN site Books Expert F# book (Dec 2007) Foundations of F# (May 2007) Community Planet F# - RSS feed HubFS Forum 8

Programming in F# can be a bit like programming in C++ with const permanently turned on: 9 C++F# const int x = 10;let x = 10 mutable int x; void foo() const { x = 20; } let mutable x = 10; x <- 20

Beware.Net reference types don’t hold any implicit immutability guarantee. (As C#). Anything that isn’t a value type is a reference type. 10 C# pass by referenceF# pass by reference var x = 10; Foo(ref x) x = 20 x let x = ref (10) Foo x x := 20 !x

Anonymous/Lamda functions: [“Hello”,”World”] |> List.iter (fun i -> Debug.WriteLine(i)) Function nesting: let OuterF () = let InnerF word = Debug.WriteLine (word) InnerF “Hello” InnerF “World” 11

Tuples are type safe anonymous structures (no indexer): let me = (“Phil”, Male, 1.92, 1971) let name, sex, height, year = me Boost has a Tuple library: Ticker ticker = make_tuple(“Barclays”, , ) double price = get (ticker); 12

let mul x y = x*y let tentimes = mul

let (|>) x f = f x Reduces scope of temporary variables 14 F# Code Sample // Shows name and first line of all cpp files modified today on drive C “*.cpp”, SearchOption.AllDirectories) |> Array.filter (fun name -> File.GetModifiedTime(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))

if total > 21 then print "Bust" if total > 21: print "Bust” 15

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

Not a pure functional language –.Net reference types do not have explicit immutability guarantees Can lead to bottom up programming In wrong hands code can be write only Less samples than C# Currently minimal F# project wizards C# slowly absorbing best F# features 17

Fewer lines ≈ Fewer errors Const correctness ≈ More correctness Reduced state ≈ Less errors Meta programming Asynchronous workflows Units of measure 18

19

20

21