Functional Programming in a Nutshell with Haskell and F#

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

Programming Paradigms and languages
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
CSCI 330: Programming Language Concepts Instructor: Pranava K. Jha Control Flow-II: Execution Order.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Programming Languages Structure
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
Foundations of Programming Languages – Course Overview Xinyu Feng Acknowledgments: some slides taken or adapted from lecture notes of Stanford CS242
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Computer Architecture Computational Models Ola Flygt V ä xj ö University
Imperative Programming
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Lambda Calculus History and Syntax. History The lambda calculus is a formal system designed to investigate function definition, function application and.
1 Programming Language History and Evolution In Text: Chapter 2.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
1 Functional Programming & Standard ML Hossein Hojjat et al.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter Fifteen: Functional Programming Languages Lesson 12.
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05.
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
Overview.  Explores the theoretical foundations of computing  What can and cannot be done by an algorithm  Most of the material predates computers!
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler.
CS5205Introduction1 CS5205: Foundation in Programming Languages Lecture 0 : Overview Lecturer : Chin Wei Ngan Office : COM2.
1-1 An Introduction to Functional Programming Sept
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
Functional Programming Lecture 1 - Introduction Professor Muffy Calder.
Functional Programming
Programming Language History and Evolution
Programming Languages 2nd edition Tucker and Noonan
Functional Programming
CS 3723 Programming Languages
COSC 5V90 Functional Programming and Interactive Theorem Proving
Functional Programming
CS 3304 Comparative Languages
Concepts of Programming Languages
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Why study programming languages?
CS 341 : Programming Languages
PROGRAMMING LANGUAGES
Programming Language Design Concepts
CS 326 Programming Languages, Concepts and Implementation
CS 326 Programming Languages, Concepts and Implementation
More Functional Programming
OBJECT ORIENTED PROGRAMMING overview
Programming Language History and Evolution
Introduction to Functional Programming in Racket
Chap. 6 :: Control Flow Michael L. Scott.
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Foundations of Programming Languages – Course Overview
Programming Languages
Foundations of Programming Languages – Course Overview
Programming Language Design
FP Foundations, Scheme In Text: Chapter 14.
Chap. 6 :: Control Flow Michael L. Scott.
Programming Languages 2nd edition Tucker and Noonan
Programming Paradigms and Languages
Von Neumann Architecture
Introduction to Functional Programming in Racket
CSE 3302 Programming Languages
Overview of Programming Paradigms
Functional Programming and Haskell
Chapter 15 Functional Programming 6/1/2019.
Programming Paradigms and Languages
Functional Programming and Haskell
Presentation transcript:

Functional Programming in a Nutshell with Haskell and F# Giordano Tamburrelli, PhD Academic Developer Evangelist giotam@microsoft.com DPE – Microsoft Italia 18-Sep-18

Giordano Tamburrelli, Phd Agenda Intro Course Overview Topics and evaluation Functional Languages One upon a time What, why and how …. 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd One slide about me PhD in Software Engineering @ Politecnico di Milano Service Oriented Architectures Software Performance and Reliability Cloud Computing (recently) Academic Developer Evangelist at Microsoft Italia Dreamspark MSDN Academic Alliance Imagine Cup … 18-Sep-18 Giordano Tamburrelli, Phd

One slide about Microsoft’s initiatives DreamSpark and MSDN AA For this course you’ll need: Visual Studio 2010 F# XNA 4.0 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Course Overview 1/3 Introduction to Functional Languages Haskell in a nutshell With a focus on concurrency F# in a nutshell Hands on session F# + XNA 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Course Overview 2/3 Goal: Understand peculiarities, pros and cons associated to functional languages Evaluation: Mini-paper (2 pages max) in which you describe how and why functional languages might be useful in your research area. At most 2 people per paper. 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Course Overview 3/3 What to expect from this presentation: A brief history of Functional Languages Functional Languages fundamental concepts Why Functional Language Applications of Functional Languages 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Once Upon a time…. First Functional language was ILP (Information Processing Language) by RAND corporation and Carnegie Mellon in 1955 (vs Fortran, 1956) Lisp was developed John McCarthy at MIT in 1958 (vs Cobol, 1959) Imperative languages became the dominant paradigm in the 1970s Mainly academic applications until recently… 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Lambda Calculus Alonzo Church and Stephen Cole Kleene, in 1936 introduced Lambda Calculus as part of an investigation into the foundation of mathematics Lambda calculus is a language with three syntactic forms and one reduction rule Mathematical abstraction, a sort of idealized and minimalistic programming language The basis of almost all functional programming languages today 18-Sep-18 Giordano Tamburrelli, Phd

Some interesting readings… “Can Programming Be Liberated From the von Neumann Style? A Functional Style and its Algebra of Programs”. John Backus, Turing Award lecture, 1977 (available in PDF on-line). “History of Lisp”. John McCarthy, ACM SIGPLAN History of Programming Languages Conference, 1978. … 18-Sep-18 Giordano Tamburrelli, Phd

Imperative vs Declarative 18-Sep-18 Giordano Tamburrelli, Phd

Imperative Programming Procedural and OO Languages Variables, assignment and sequencing Variables = memory locations Assignments modify variables Sequencing = extensive use of loops Imperative Programming as: State Based Assignment Oriented 18-Sep-18 Giordano Tamburrelli, Phd

Functional Programming Functional Programming (FP) is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data (no side effects!) Variables bound to values! Recursion in place of iteration Function composition Functional Programming as: Value Based Applicative 18-Sep-18 Giordano Tamburrelli, Phd

Functional Programming These expression are not equal: //F# let a = 42 //C# int a = 42 //F# let a = 42 //C# static int a() { return 42; } Conceptually are more like: 18-Sep-18 Giordano Tamburrelli, Phd

Functional Programming Ask don’t tell Usually we tell the computer how we want things done rather then what we want to achieve (a.k.a. Imperative thinking) The Espresso example: If the computer were a coffee maker, we tell the computer to grind the coffee, then get the water and warm it. At the same time prepare the milk, in parallel! With FP (theoretically), you simply tell (or define) you want an expresso 18-Sep-18 Giordano Tamburrelli, Phd

Functional Programming Logical syntax x = x + 1; We understand this syntax because we are used to tell the computer what to do and we rely on its internal architecture But this eqaution does not make no sense at all 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Succinct Syntax //C# using System namespace ConsoleApplication1 { class Program static int a() return 2; } 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Succinct Syntax //F# open System let a = 2 Console.Writeline a 18-Sep-18 Giordano Tamburrelli, Phd

Some Fundamental concepts Recursion High-order functions Map, Filter, Reduce Eager/lazy evaluation Pattern matching (forget your switch statements!) Currying 18-Sep-18 Giordano Tamburrelli, Phd

Functional Languages: Why Recently a lot of hype on Functional Languages F# initially developed by Don Syme at Microsoft Research. Fully supported language in the .NET Framework and Visual Studio as part of Visual Studio 2010 Clojure introduced in 2007 runs on a JVM Haskell, Erlang and Scala recently gained relevant popularity 18-Sep-18 Giordano Tamburrelli, Phd

Functional Languages: Why 18-Sep-18 Giordano Tamburrelli, Phd

Functional Languages: Why Concurrency/Parallelism without tears Moore’s law starting to reach its limits Programmers need to go parallel No side effects nature Succinct, concise, understandable syntax Maintainability More accessible (e.g., new IDE and tools) 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Applications of FP Financial Analysis Insurance Analysis Advertising Analysis Image Digital Analysis (Game dev) Data Mining 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Applications of FP Erlang Developed and heavily used by Ericsson for developing large scale real-time systems F# Xbox Halo 3 player rankings (lot less code then C#) Lisp Autocad Emacs editor … 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Questions? A very special thank to: The speakers The organizer Enjoy the course... 18-Sep-18 Giordano Tamburrelli, Phd

Giordano Tamburrelli, Phd Some References… Web web web.... http://channel9.msdn.com/Blogs/pdc2008/TL11 http://johnnycoder.com/blog/2009/05/01/functional-programming-part-10/ .... 18-Sep-18 Giordano Tamburrelli, Phd