Phillip Trelford Blog: 1.

Slides:



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

The Software Lifecycle. Example Problem: Update a Checkbook Write a program that allows the user to enter a starting balance, a transaction type, D or.
R for Macroecology Aarhus University, Spring 2011.
Lecture 4: Javascript Basics Javascript is a scripting language based on pieces of C, C++, shell scripts, Pascal, Java, etc. Scripts – loosely typed C++
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
ML Declarations.1 Standard ML Declarations. ML Declarations.2 Declarations o Re-declaration of names in ML o The reserved words "val rec" o Pattern Matching.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
ML: A Strongly Typed Functional Language Interpreted (compilers available): -bash-3.00$ poly Poly/ML 5.4 Release > 1+3; val it = 4 : int >o ^D -bash-3.00.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
A Crash Course Python. Python? Isn’t that a snake? Yes, but it is also a...
Computer and Programming
Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
Session Objectives# 24 COULD code the solution for an algorithm
Standard ML- Part I Compiler Baojian Hua
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
Introduction to ML You will be responsible for learning ML on your own. Today I will cover some basics Read Robert Harper’s notes on “an introduction to.
Mark Hennessy CS351 Dept Computer Science NUI Maynooth 1 Types CS351 – Programming Paradigms.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
F# Shiva Srivastava David He Peter Bingel. Overview F# (pronounced "F sharp") is a functional and object oriented programming language for the Microsoft.NET.
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
Chapter 1. Introduction.
CSE 341 Programming Languages Racket Datatype Style Programming Zach Tatlock Spring 2014.
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:
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
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++
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
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,
ALBERT WAVERING BOBBY SENG. Week 4: JavaScript  Quiz  Announcements/questions.
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
A Level Computing#BristolMet Session ObjectivesU2#S12 MUST describe the terms modal and pretty printing in term of input and output facilities. SHOULD.
Prof. Hilfinger CS164 Lecture 51 The Pyth Language Lecture 5.
CMSC 330: Organization of Programming Languages Functional Programming with OCaml.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
24 HOURS LATER Phillip Build Stuff, Lithuania, 2014.
CMSC 330: Organization of Programming Languages
By Jordan SEKE MBOUNGOU MOUYABI Senior LAN Administrator & E-learning Site Administrator Oliver Schreiner building, School of law.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
Programming Objectives What is a programming language? Difference between source code and machine code What is python? – Where to get it from – How to.
Writing Better C# Using C# 6 By: Mitchel Sellers.
1 Objective Caml (Ocaml) Aaron Bloomfield CS 415 Fall 2005.
William Perry U.S. Geological Survey Western Ecological Research Center Geography 375 Final Project May 22, 2013.
Phillip Trelford 1. Goals Introduce F# Non-goals Cover every language feature Mass conversion to FP cult Sell books 2.
Phillip Trelford Blog:
Topics for today: 1.Comments 2.Data types 3.Variable declaration.
Introduction to Algorithms. What is an algorithm? ‘A process that performs some sequence of operations’ Sequence Rigorously defined Discrete, mechanical.
Introduction to F# Kit Eason – –
Chapter 1 Object Orientation: Objects and Classes.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L05-1 September 21, 2006http:// Types and Simple Type.
Chapter 1. Introduction.
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
Lesson 06: Functions Class Participation: Class Chat:
‘C’ Programming Structures and Commands
Exam #1 You will have exactly 30 Mins to complete the exam.
Principles of programming languages 12: Functional programming
Sharing, mutability, and immutability
MIS Professor Sandvig MIS 324 Professor Sandvig
Variables ,Data Types and Constants
Sharing, mutability, and immutability
Topic 1: Problem Solving
Lesson 06: Functions Class Chat: Attendance: Participation
CSC 253 Lecture 7.
Madhusudan Parthasarathy (madhu) 3112 Siebel Center
Introduction to JavaScript
Presentation transcript:

Phillip Trelford Blog: 1

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

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

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

© Trayport PROPRIETARY & CONFIDENTIAL Key Features Functions are idempotent Functions are first class High order functions Languages: Haskell Excel JavaScript 5

Communities Scientific (Microsoft Research, AdCenter) Academic (French Universities use OCaml) Financial (Investment Banks, Hedge Funds, etc) Problem domains Maths DSLs Scripting 6

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 7

© Trayport PROPRIETARY & CONFIDENTIAL 8

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

© Trayport PROPRIETARY & CONFIDENTIAL 10

© Trayport PROPRIETARY & CONFIDENTIAL 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; 11

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

© Trayport PROPRIETARY & CONFIDENTIAL NameExample Single(1) Pair(1,2) Triple(1,2,null) Quadruple(1,2,3.0, null) Quintuple Sextuple Septuble Octuple Nonuple Decuple 13

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

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

let (|>) x f = f x Reduces scope of temporary variables 16 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” 17

© Trayport PROPRIETARY & CONFIDENTIAL type Sex = | Male | Female type BinaryTree = | Branch of BinaryTree * BinaryTree | Leaf of ‘a 18

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

Fewer lines ≈ Fewer errors Const correctness ≈ More correctness Less state ≈ Less errors DSLs Asynchronous workflows Units of measure 20

21

22