principles of programming languages lecture 1:...
TRANSCRIPT
![Page 1: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/1.jpg)
Principles of Programming LanguagesLecture 1: Introduction
Andrei Arusoaie1
1Department of Computer Science
October 3, 2019
![Page 2: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/2.jpg)
Outline
General course information
Preliminary discussion
History
Main Paradigms
![Page 3: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/3.jpg)
Principles of Programming Languages - Motivation
I Learning a new PL is nowadays a requirementI “Programmers need to move from one PL to another with
naturalness and speed” [Gabbrielli2010]I PLs have their similarities, analogies, inherited
characteristics
GOAL:
understand the basic mechanisms behind the creation of a PL
![Page 4: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/4.jpg)
Principles of Programming Languages - Motivation
I Learning a new PL is nowadays a requirementI “Programmers need to move from one PL to another with
naturalness and speed” [Gabbrielli2010]I PLs have their similarities, analogies, inherited
characteristics
GOAL:
understand the basic mechanisms behind the creation of a PL
![Page 5: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/5.jpg)
Principles of Programming Languages - Motivation
I Learning a new PL is nowadays a requirementI “Programmers need to move from one PL to another with
naturalness and speed” [Gabbrielli2010]I PLs have their similarities, analogies, inherited
characteristics
GOAL:
understand the basic mechanisms behind the creation of a PL
![Page 6: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/6.jpg)
Principles of Programming Languages - Motivation
I Learning a new PL is nowadays a requirementI “Programmers need to move from one PL to another with
naturalness and speed” [Gabbrielli2010]I PLs have their similarities, analogies, inherited
characteristics
GOAL:
understand the basic mechanisms behind the creation of a PL
![Page 7: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/7.jpg)
Skills to develop
I The definition of a programming language:
Syntax + Semantics
I Have a better understanding of the PLs you already knowI Ability to learn a new PL fastI Get familiar with a framework for defining languages
![Page 8: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/8.jpg)
Skills to develop
I The definition of a programming language:
Syntax + Semantics
I Have a better understanding of the PLs you already knowI Ability to learn a new PL fastI Get familiar with a framework for defining languages
![Page 9: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/9.jpg)
Skills to develop
I The definition of a programming language:
Syntax + Semantics
I Have a better understanding of the PLs you already knowI Ability to learn a new PL fastI Get familiar with a framework for defining languages
![Page 10: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/10.jpg)
Skills to develop
I The definition of a programming language:
Syntax + Semantics
I Have a better understanding of the PLs you already knowI Ability to learn a new PL fastI Get familiar with a framework for defining languages
![Page 11: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/11.jpg)
Principles of Programming Languages - Organisation
I People: Andrei Arusoaie and Andreea ButerchiI Period: 1st semester (Fall 2019), 2nd yearI http://www.uaic.ro/wp-content/uploads/2019/05/
structura-an-universitar.pdf
I 14 (full activity) weeksI Final grade = 40 (midterm) + 40 (final exam) + 20 (lab)I Midterm: 40 points, week 8 - written testI Project: 40 points, week 14 - written testI Lab: 10 points for attending the labI Lab: 10 points for lab activity + bonuses (!max 20 points)I Bonuses: presentations/interesting projects/etc.I Criteria: min 40 points exam + min 10 points lab
![Page 12: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/12.jpg)
Principles of Programming Languages - Organisation
I People: Andrei Arusoaie and Andreea ButerchiI Period: 1st semester (Fall 2019), 2nd yearI http://www.uaic.ro/wp-content/uploads/2019/05/
structura-an-universitar.pdf
I 14 (full activity) weeksI Final grade = 40 (midterm) + 40 (final exam) + 20 (lab)I Midterm: 40 points, week 8 - written testI Project: 40 points, week 14 - written testI Lab: 10 points for attending the labI Lab: 10 points for lab activity + bonuses (!max 20 points)I Bonuses: presentations/interesting projects/etc.I Criteria: min 40 points exam + min 10 points lab
![Page 13: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/13.jpg)
Principles of Programming Languages - Organisation
I People: Andrei Arusoaie and Andreea ButerchiI Period: 1st semester (Fall 2019), 2nd yearI http://www.uaic.ro/wp-content/uploads/2019/05/
structura-an-universitar.pdf
I 14 (full activity) weeksI Final grade = 40 (midterm) + 40 (final exam) + 20 (lab)I Midterm: 40 points, week 8 - written testI Project: 40 points, week 14 - written testI Lab: 10 points for attending the labI Lab: 10 points for lab activity + bonuses (!max 20 points)I Bonuses: presentations/interesting projects/etc.I Criteria: min 40 points exam + min 10 points lab
![Page 14: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/14.jpg)
Principles of Programming Languages
Course description:I RO:
https://profs.info.uaic.ro/~arusoaie.andrei/
lectures/PLP/2019/fisa_disciplinei_plp.pdf
I EN: https://profs.info.uaic.ro/~arusoaie.andrei/lectures/PLP/2019/course_description_plp_en.pdf
Website:I https://profs.info.uaic.ro/~arusoaie.andrei/
lectures/PLP/2019/plp.html
![Page 15: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/15.jpg)
Bibliography
I Bibliography:
1. Practical Foundations of Programming Languages, RobertHarperhttps://www.cs.cmu.edu/~rwh/pfpl/2nded.pdf
2. Software Foundations - Volume 2, Benjamin C. Pierce,Arthur Azevedo de Amorim, Chris Casinghino, MarcoGaboardi, Michael Greenberg, Catalin Hritcu, VilhelmSjöberg, Andrew Tolmach, Brent Yorgeyhttps://softwarefoundations.cis.upenn.edu/plf-current/index.html
3. Programming Languages: Principles and Paradigms,Maurizio Gabbrielli, Simone Martinihttp://websrv.dthu.edu.vn/attachments/newsevents/content2415/Programming_Languages_-_Principles_and_Paradigms_thereds1106.pdf
![Page 16: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/16.jpg)
Labs
I Lab: Coq
I Web: https://coq.inria.fr/
I Software Foundations - Volume 2, Benjamin C. Pierce,Arthur Azevedo de Amorim, Chris Casinghino, MarcoGaboardi, Michael Greenberg, Catalin Hritcu, VilhelmSjöberg, Andrew Tolmach, Brent Yorgeyhttps://softwarefoundations.cis.upenn.edu/
plf-current/index.html
![Page 17: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/17.jpg)
Labs
I Lab: Coq
I Web: https://coq.inria.fr/
I Software Foundations - Volume 2, Benjamin C. Pierce,Arthur Azevedo de Amorim, Chris Casinghino, MarcoGaboardi, Michael Greenberg, Catalin Hritcu, VilhelmSjöberg, Andrew Tolmach, Brent Yorgeyhttps://softwarefoundations.cis.upenn.edu/
plf-current/index.html
![Page 18: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/18.jpg)
Principles of Programming Languages -Communication
I Course page:https:
//profs.info.uaic.ro/~arusoaie.andrei/lectures/PLP/2019/plp.html
I Email: [email protected]
![Page 19: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/19.jpg)
Today’s lecture
1. Preliminary discussion2. History3. Programming paradigms4. Debate & preparing lab
![Page 20: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/20.jpg)
Today’s lecture
1. Preliminary discussion2. History3. Programming paradigms4. Debate & preparing lab
![Page 21: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/21.jpg)
Today’s lecture
1. Preliminary discussion2. History3. Programming paradigms4. Debate & preparing lab
![Page 22: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/22.jpg)
Today’s lecture
1. Preliminary discussion2. History3. Programming paradigms4. Debate & preparing lab
![Page 23: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/23.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 24: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/24.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 25: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/25.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 26: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/26.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 27: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/27.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 28: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/28.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 29: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/29.jpg)
Quick questions, debatable answers
I What is a programming language?I Why do we need programming languages?I Which languages have you heard about?I Have you ever created your own programming language?I How to design a programming language?I What is the best programming language?
![Page 30: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/30.jpg)
History - I
I Programming computersI 1944: ASCC/MARK I
I built by IBM and Harward Univ., H. AikenI programmed using punched tapes and external physical
media (like switches)I 10 m length, 4 tones, very expensive
I 1946: ENIACI J. Mauchly and J.P. Eckert, early (design) J. von NeumannI Orders of magnitude faster than humans at computingI no storageI programmed using external physical media (electrical
cables)I used to calculate ballistic trajectories
![Page 31: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/31.jpg)
History - I
I Programming computersI 1944: ASCC/MARK I
I built by IBM and Harward Univ., H. AikenI programmed using punched tapes and external physical
media (like switches)I 10 m length, 4 tones, very expensive
I 1946: ENIACI J. Mauchly and J.P. Eckert, early (design) J. von NeumannI Orders of magnitude faster than humans at computingI no storageI programmed using external physical media (electrical
cables)I used to calculate ballistic trajectories
![Page 32: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/32.jpg)
History - II
I 1949: EDSAC - the first “computer” in the modern senseI electronic and digitalI able to perform four elementary arithmetic operationsI programableI storage of programs and data
![Page 33: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/33.jpg)
History - III
I 1GL (first generation languages): machine languageI elementary instructions immediately executable by a
processorI coding: completely manualI hard to use, too “machine connected”I people realized that they need something closer to the
user’s natural languageI 2GL: (second generation languages): assembly language
I introduced to ease the developmentI symbolic representation of the machine languageI translated into machine codeI downside: each machine has its own assembly language
![Page 34: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/34.jpg)
History - III
I 1GL (first generation languages): machine languageI elementary instructions immediately executable by a
processorI coding: completely manualI hard to use, too “machine connected”I people realized that they need something closer to the
user’s natural languageI 2GL: (second generation languages): assembly language
I introduced to ease the developmentI symbolic representation of the machine languageI translated into machine codeI downside: each machine has its own assembly language
![Page 35: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/35.jpg)
History - IV
I 1950 – 3GL: high-level languagesI abstract languagesI ignore the physical characteristics of the computerI well suited to express algorithms
I 1950: ALGOL = ALGOrithmic Languages (family oflanguages)
I 1957: FORTRAN = FORmula TRANslationI 1960: LISP = LISt ProcessorI However, the development was still an issueI Lots of human resources required, expensive hardware
![Page 36: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/36.jpg)
History - IV
I 1950 – 3GL: high-level languagesI abstract languagesI ignore the physical characteristics of the computerI well suited to express algorithms
I 1950: ALGOL = ALGOrithmic Languages (family oflanguages)
I 1957: FORTRAN = FORmula TRANslationI 1960: LISP = LISt ProcessorI However, the development was still an issueI Lots of human resources required, expensive hardware
![Page 37: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/37.jpg)
History - IV
I 1950 – 3GL: high-level languagesI abstract languagesI ignore the physical characteristics of the computerI well suited to express algorithms
I 1950: ALGOL = ALGOrithmic Languages (family oflanguages)
I 1957: FORTRAN = FORmula TRANslationI 1960: LISP = LISt ProcessorI However, the development was still an issueI Lots of human resources required, expensive hardware
![Page 38: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/38.jpg)
History - V
I 1970’s: microprocessor; batch processingI Further abstractions pushed PL development to what PL
are todayI New paradigms: object-oriented, declarative programmingI The C language: Dennis Ritchie and Ken Thompson
I Initially designed for the UNIX operating systemI Successor of BI Followed by: Pascal, SmallTalk
I Declarative languages: ML (Meta Language), PROLOG
![Page 39: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/39.jpg)
History - V
I 1970’s: microprocessor; batch processingI Further abstractions pushed PL development to what PL
are todayI New paradigms: object-oriented, declarative programmingI The C language: Dennis Ritchie and Ken Thompson
I Initially designed for the UNIX operating systemI Successor of BI Followed by: Pascal, SmallTalk
I Declarative languages: ML (Meta Language), PROLOG
![Page 40: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/40.jpg)
History - V
I 1970’s: microprocessor; batch processingI Further abstractions pushed PL development to what PL
are todayI New paradigms: object-oriented, declarative programmingI The C language: Dennis Ritchie and Ken Thompson
I Initially designed for the UNIX operating systemI Successor of BI Followed by: Pascal, SmallTalk
I Declarative languages: ML (Meta Language), PROLOG
![Page 41: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/41.jpg)
History - VI
I 1980’s: the PC eraI 1986: C++ - Bjarne StroustrupI 1989: HTML - T. Berners-Lee, Python - Guido van RossumI 1990’s: internet, WWWI 1990-1995: Java - Jim Gosling at SUNI 1994 : PHP - Rasmus LerdorfI 2000 : (Microsoft) C# - Anders HejlsbergI 2004 : Scala - Martin OderskyI 2012 : Go - at Google Inc. (started in 2007 by R.
Griesemer, R. Pike, K. Thompson)I 2014 : Swift - at Apple Inc. (started in 2010 by Chris
Lattner)
![Page 42: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/42.jpg)
History - VI
I 1980’s: the PC eraI 1986: C++ - Bjarne StroustrupI 1989: HTML - T. Berners-Lee, Python - Guido van RossumI 1990’s: internet, WWWI 1990-1995: Java - Jim Gosling at SUNI 1994 : PHP - Rasmus LerdorfI 2000 : (Microsoft) C# - Anders HejlsbergI 2004 : Scala - Martin OderskyI 2012 : Go - at Google Inc. (started in 2007 by R.
Griesemer, R. Pike, K. Thompson)I 2014 : Swift - at Apple Inc. (started in 2010 by Chris
Lattner)
![Page 43: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/43.jpg)
![Page 44: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/44.jpg)
Main programming paradigms
1. Imperative programmingI First do this and then do that
2. Object-oriented programmingI Model the world using objects that exchange messages
3. Functional programming1
I Evaluate an expression and pass the result4. Logic programming1
I Answer questions by searching a solution
1Part of the Declarative programming paradigm
![Page 45: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/45.jpg)
Main programming paradigms
1. Imperative programmingI First do this and then do that
2. Object-oriented programmingI Model the world using objects that exchange messages
3. Functional programming1
I Evaluate an expression and pass the result4. Logic programming1
I Answer questions by searching a solution
1Part of the Declarative programming paradigm
![Page 46: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/46.jpg)
Main programming paradigms
1. Imperative programmingI First do this and then do that
2. Object-oriented programmingI Model the world using objects that exchange messages
3. Functional programming1
I Evaluate an expression and pass the result4. Logic programming1
I Answer questions by searching a solution
1Part of the Declarative programming paradigm
![Page 47: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/47.jpg)
Main programming paradigms
1. Imperative programmingI First do this and then do that
2. Object-oriented programmingI Model the world using objects that exchange messages
3. Functional programming1
I Evaluate an expression and pass the result4. Logic programming1
I Answer questions by searching a solution
1Part of the Declarative programming paradigm
![Page 48: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/48.jpg)
Imperative programming
Example program:
read(n);s = 0;if (n < 0) {
print "error";} else {
while (n > 0) do {s = s + n;n = n - 1;
}}
I Requires a program stateI Execution is (incrementally)
changing the program stateI Instructions: assignment,
decisional, loopsI First class value: variable
![Page 49: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/49.jpg)
Imperative programming
Example program:
read(n);s = 0;if (n < 0) {
print "error";} else {
while (n > 0) do {s = s + n;n = n - 1;
}}
I Requires a program stateI Execution is (incrementally)
changing the program stateI Instructions: assignment,
decisional, loopsI First class value: variable
![Page 50: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/50.jpg)
Imperative programming
Example program:
read(n);s = 0;if (n < 0) {
print "error";} else {
while (n > 0) do {s = s + n;n = n - 1;
}}
I Requires a program stateI Execution is (incrementally)
changing the program stateI Instructions: assignment,
decisional, loopsI First class value: variable
![Page 51: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/51.jpg)
Imperative programming
Example program:
read(n);s = 0;if (n < 0) {
print "error";} else {
while (n > 0) do {s = s + n;n = n - 1;
}}
I Requires a program stateI Execution is (incrementally)
changing the program stateI Instructions: assignment,
decisional, loopsI First class value: variable
![Page 52: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/52.jpg)
Imperative programming
Example program:
read(n);s = 0;if (n < 0) {
print "error";} else {
while (n > 0) do {s = s + n;n = n - 1;
}}
I Requires a program stateI Execution is (incrementally)
changing the program stateI Instructions: assignment,
decisional, loopsI First class value: variable
![Page 53: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/53.jpg)
Object-Oriented Programming
Example (Java):
public class Person {private String name;Person(String name) {this.name = name;
}public String getName() {return name;
}}
// in the main functionDriver john = new Driver("John");john.startDriving();boolean status = john.getStatus();
public class Driver extends Person{private boolean isDriving;Driver(String name) {super(name);isDriving = false;
}public void startDriving() {isDriving = true;
}public boolean getStatus() {return isDriving;
}}
![Page 54: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/54.jpg)
Object-Oriented Programming
I Model using objects and classesI Objects exchange messages (dispatch/message passing)I Abstraction, EncapsulationI Inheritance, Polymorphism, Overriding, Overloading
![Page 55: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/55.jpg)
Functional programming
Example:(Haskell)
mysum :: Integer -> Integermysum n = if (n < 0)
then 0else n + mysum (n - 1)
Run:
> mysum 1055> mysum 00> mysum (-3)0
I Computations = evaluation of mathematical functionsI No state!I Non-mutable valuesI First class value: function
![Page 56: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/56.jpg)
Functional programming
Example:(Haskell)
mysum :: Integer -> Integermysum n = if (n < 0)
then 0else n + mysum (n - 1)
Run:
> mysum 1055> mysum 00> mysum (-3)0
I Computations = evaluation of mathematical functionsI No state!I Non-mutable valuesI First class value: function
![Page 57: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/57.jpg)
Functional programming
Example:(Haskell)
mysum :: Integer -> Integermysum n = if (n < 0)
then 0else n + mysum (n - 1)
Run:
> mysum 1055> mysum 00> mysum (-3)0
I Computations = evaluation of mathematical functionsI No state!I Non-mutable valuesI First class value: function
![Page 58: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/58.jpg)
Logic Programming
Example (Prolog):
man(john).man(dan).man(mark).father(john, mark).father(mark, dan).
grandfather(X,Y) :- man(X),man(Y),father(X,Z),father(Z,Y).
Search solution:
1 ?- father(mark, dan).true.2 ?- grandfather(mark, dan).false.3 ?- grandfather(john, dan).true.4 ?- grandfather(X, dan).X = john .
I Algorithm = Logic + ControlI Programmer provides a logical specificationI An interpreter searches for the solution using resolution
![Page 59: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/59.jpg)
Logic Programming
Example (Prolog):
man(john).man(dan).man(mark).father(john, mark).father(mark, dan).
grandfather(X,Y) :- man(X),man(Y),father(X,Z),father(Z,Y).
Search solution:
1 ?- father(mark, dan).true.2 ?- grandfather(mark, dan).false.3 ?- grandfather(john, dan).true.4 ?- grandfather(X, dan).X = john .
I Algorithm = Logic + ControlI Programmer provides a logical specificationI An interpreter searches for the solution using resolution
![Page 60: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/60.jpg)
Logic Programming
Example (Prolog):
man(john).man(dan).man(mark).father(john, mark).father(mark, dan).
grandfather(X,Y) :- man(X),man(Y),father(X,Z),father(Z,Y).
Search solution:
1 ?- father(mark, dan).true.2 ?- grandfather(mark, dan).false.3 ?- grandfather(john, dan).true.4 ?- grandfather(X, dan).X = john .
I Algorithm = Logic + ControlI Programmer provides a logical specificationI An interpreter searches for the solution using resolution
![Page 61: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/61.jpg)
Domain Specific Languages
I Web: HTML, CSS, scripting (e.g., Javascript, PHP)I Databases: SQLI Algebraic: Maude, CafeOBJI Modelling: UMLI WSC: BPELI Regex text processing: PerlI Programming languages: Rascal, Spoofax, Coq, Racket,
K, ...I ...
![Page 62: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/62.jpg)
Debate
Which paradigm is better?
Indeed, this question is stupid...
![Page 63: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/63.jpg)
Debate
Which paradigm is better?
Indeed, this question is stupid...
![Page 64: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/64.jpg)
What’s next?
I PL = Syntax + SemanticsI Syntax:
I how can we combine symbols to create correct programs?I Grammars (BNF = Backus-Naur Form)
I Semantics: what programs mean?I Other things related to PLs: pragmatics, compilers, etc.
![Page 65: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/65.jpg)
What’s next?
I PL = Syntax + SemanticsI Syntax:
I how can we combine symbols to create correct programs?I Grammars (BNF = Backus-Naur Form)
I Semantics: what programs mean?I Other things related to PLs: pragmatics, compilers, etc.
![Page 66: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/66.jpg)
What’s next?
I PL = Syntax + SemanticsI Syntax:
I how can we combine symbols to create correct programs?I Grammars (BNF = Backus-Naur Form)
I Semantics: what programs mean?I Other things related to PLs: pragmatics, compilers, etc.
![Page 67: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/67.jpg)
What’s next?
I PL = Syntax + SemanticsI Syntax:
I how can we combine symbols to create correct programs?I Grammars (BNF = Backus-Naur Form)
I Semantics: what programs mean?I Other things related to PLs: pragmatics, compilers, etc.
![Page 68: Principles of Programming Languages Lecture 1: Introductionarusoaie.andrei/lectures/PLP/2019/week1/lecture1.pdf · processor I coding: completely manual I hard to use, too “machine](https://reader034.vdocuments.us/reader034/viewer/2022042106/5e8473c0c3369046cf69ed89/html5/thumbnails/68.jpg)
Questions?
Bibliography:I Chapter 13 from Programming Languages: Principles and
Paradigms, Maurizio Gabbrielli, Simone Martini, Online:http://websrv.dthu.edu.vn/attachments/newsevents/content2415/Programming_Languages_-_Principles_and_Paradigms_thereds1106.pdf