Programming Language Theory Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI.

Slides:



Advertisements
Similar presentations
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Standard ML- Part I Compiler Baojian Hua
MATHEMATICAL FOUNDATIONS SUPPLEMENTAL MATERIAL – NOT ON EXAM.
CSE 3302 Programming Languages Chengkai Li Fall 2007 Functional Programming Language (Introduction and Scheme) Lecture 17 – Functional Programming, Spring.
0 PROGRAMMING IN HASKELL Chapter 1 - Introduction.
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
Dec Formal Semantics1 Programming Language Theory Formal Semantics Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
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.
Gary MarsdenSlide 1University of Cape Town Functional programming in Clean Gary Marsden Semester 2 – 2000.
0 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Imperative Programming
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
1 Programming Language History and Evolution In Text: Chapter 2.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
ISBN Chapter 15 Functional Programming Languages.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
1 Programming Languages and Paradigms Functional Programming.
CSC 580 – Theory of Programming Languages, Spring, 2009 Week 9: Functional Languages ML and Haskell, Dr. Dale E. Parson.
Chapter Fifteen: Functional Programming Languages Lesson 12.
CS 363 Comparative Programming Languages Functional Languages: Scheme.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Haskell 101 Dr. Hyunyoung Lee.
1-1 An Introduction to Functional Programming Sept
Lisp "List Processing". Lisp history John McCarthy developed the basics behind Lisp during the 1956 Dartmouth Summer Research Project on Artificial Intelligence.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Functional Programming Part 1. Organization of Programming Languages-Cheng Big Picture u What we’ve learned so far: Imperative Programming Languages 
Copyright © 2009 Elsevier Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott.
Haskell Introduction CSCE 314 Spring CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
Erik Meijer FP101x - Functional Programming Programming in Haskell - Introduction.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
1 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Language Paradigms CS655.
Functional Programming
Programming Languages winter term 2010/11
Programming Language History and Evolution
Programming Languages Third Edition
Functional Programming
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
What is a Functional Language?
Functional Programming
Midterm recap Total was 80 points Distribution range
More Functional Programming
Closures and Streams cs784(Prasad) L11Clos
Introduction to Functional Programming Course Summary and Future
Programming Language History and Evolution
Chap. 6 :: Control Flow Michael L. Scott.
Functional Programming
Programming Languages
FP Foundations, Scheme In Text: Chapter 14.
Chap. 6 :: Control Flow Michael L. Scott.
CSE 3302 Programming Languages
PROGRAMMING IN HASKELL
Closures and Streams cs7100(Prasad) L11Clos
CSE S. Tanimoto Lambda Calculus
Functional Programming and Haskell
PROGRAMMING IN HASKELL
Chapter 15 Functional Programming 6/1/2019.
Functional Programming and Haskell
Presentation transcript:

Programming Language Theory Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI

Contents Leif’s three parts of the course: Functional programming Logical programming Similar ways of thinking, but different from the imperative way Formal semantics

Your background Quite good at programming(?) Not familiar to functional/logical programming(?) Which languages do you use?

Functional programming Why? –We want to make programming easier and more effective Some important features/drawbacks compared to imperative programming –Programs are functions –Functions may be data –Modularity, using higher order functions –No side effects

Functional pr. cont. Features/drawbacks –Automatic memory management (Java has it too, but not C/C++) –Not widely used in the industry – still true but for example Erlang is used professionally at Ericsson. Look at Joe Armstrong’s webcasted lecture about Erlang –Inefficiency in execution. Les and less important: Computers get more and more powerful

Performance The compilers are getting better:

The languages C - gcc 3.0, Imperative C++ - g++ 3.0, Imperative and oo Java - Java(TM) 2 Runtime Environment, Standard Edition (build b24), Imperative and oo Mercury - Mercury , Logic SML - MLton , Functional Ocaml - The Objective Caml, v 3.04, Functional and oo GHC - The Glorious Glasgow Haskell Compilation System, version , Purely functional and lazy

The tests Acker - A call to the Ackermann function with arguments 3, 8 Sieve - Calculate primes with Sieve of Eratosthene Hash - Insert and retrieve some values using a hash table Array - Do some array access FileReverse - Reverse i file HeapSort - Sort a list using heap sort NestLoop - Nested loops Rank - Average ranking for all tests

History The first, and most spread, functional language is Lisp (late 50’s) List = LISt Processor Not strongly typed A popular newer dialect is Scheme Many functional enthusiasts do not agree that Lisp is functional, due to things like assignment and other imperative constructions We will not talk more about Lisp/Scheme Take a look at it in the book if you want

Lambda Calculus Published by Alonzo Church 1930 Mathematical formalism expressing computing by functions Same power as a Turing Machine The idea behind the functional languages

Syntax expression -> constant |variable |(expression expression)application | (λ variable. expression)lambda abstraction (λx. + 1 x) 2 -> (+ 1 2) -> 3

Problems (λ x. x x) (λ x. x x) -> … Will not terminate, but (λy.2) ((λ x. x x) (λ x. x x)) will terminate if we use so called ”normal order evaluation” (lazy evaluation) If we use ”applicative evaluation order” it will not terminate

Basic principles Functional programming style possible in many languages In a purely functional language you think functional all the time: –A program is a black box, a function f: X->Y where X is the domain and Y the range –No side effects –Recursion is the only way to make iteration and loops –Strong typing: passing functions as argument is easier and more flexible than in C for example –Higher order functions give modularity Many functional languages look similar, we will use Haskell from now

Haskell First version in the en of the 80’s at Yale and Glasgow Standardized in 1998 Some new things compared to the older Miranda and ML –Monads (solves I/O handling) –Function overloading Purely functional Fully Curried Lazy (gives lazy infinite lists!)

Some small examples fact 0 = 1 fact n = n * fact (n-1) square x = x * x gcd u 0 = u gcd u v = gcd v (u `mod` v) reverse [] = [] reverse (h:t) = reverse t ++ [h]