csci 3136 principles of programming languagesweb.cs.dal.ca/~islam/3136/slides/ppl01.pdf · csci...
TRANSCRIPT
CSCI 3136Principles of Programming Languages
Summer 2013
Aminul Islam
Faculty of Computer ScienceDalhousie University
1 / 100
CSCI 3136Principles of Programming Languages
Summer 2013
Aminul IslamFaculty of Computer Science
Dalhousie University
2 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
3 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
4 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
5 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
6 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
7 / 100
Basic Course Information
� Web: http://web.cs.dal.ca/~islam/3136/
� Class: Mon & Wed 12:05-13:25 at CS 127
� Lab: Fri 12:05-13:25 at CS Lab 3
� Instructor: Aminul Islam ([email protected])Office: Room # 437, The Goldberg CS Building
� Office Hour: Fri 11:00-12:00
8 / 100
Textbooks and Other Material
� Class slides are available online
� Recommended text: Michael L. Scott. ProgrammingLanguage Pragmatics, 3rd edition 2009
� More relevant books listed on the course web site (some ofthem are available on-line)
� Other links can be found at course web site
9 / 100
Textbooks and Other Material
� Class slides are available online
� Recommended text: Michael L. Scott. ProgrammingLanguage Pragmatics, 3rd edition 2009
� More relevant books listed on the course web site (some ofthem are available on-line)
� Other links can be found at course web site
10 / 100
Textbooks and Other Material
� Class slides are available online
� Recommended text: Michael L. Scott. ProgrammingLanguage Pragmatics, 3rd edition 2009
� More relevant books listed on the course web site (some ofthem are available on-line)
� Other links can be found at course web site
11 / 100
Textbooks and Other Material
� Class slides are available online
� Recommended text: Michael L. Scott. ProgrammingLanguage Pragmatics, 3rd edition 2009
� More relevant books listed on the course web site (some ofthem are available on-line)
� Other links can be found at course web site
12 / 100
Textbooks and Other Material
� Class slides are available online
� Recommended text: Michael L. Scott. ProgrammingLanguage Pragmatics, 3rd edition 2009
� More relevant books listed on the course web site (some ofthem are available on-line)
� Other links can be found at course web site
13 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
14 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
15 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
16 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
17 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
18 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
19 / 100
Evaluation and Plagiarism Policy
Evaluation
• 40% assignments (Five)
• 20% midterm exam
• 40% final exam
Plagiarism policy
• Assignments and exams must be done individually
• Any use of reference material (book, web, ... ) must beacknowledged
• According to Faculty policy, any suspected case of plagiarismis referred to the Academic Integrity Officer and may beforwarded to the Senate Discipline Committee. Details athttp:
//www.cs.dal.ca/graduate/studentinfo/plagiarism
20 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
21 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
22 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
23 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
24 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
25 / 100
Course Outline
Contents
• Introduction
• Programming language, History, Paradigms• Implementation
• Lexical analysis and automata theory
• Syntactic Analysis and Context-Free Grammars
• Semantic analysis
• Names, scopes, and binding
• Control flow
• Data types and object-oriented programming
• Specialized topics
Tutorials
• Perl
• Scheme/Lisp
• Prolog
26 / 100
Course Outline
Contents
• Introduction• Programming language, History, Paradigms• Implementation
• Lexical analysis and automata theory
• Syntactic Analysis and Context-Free Grammars
• Semantic analysis
• Names, scopes, and binding
• Control flow
• Data types and object-oriented programming
• Specialized topics
Tutorials
• Perl
• Scheme/Lisp
• Prolog
27 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
28 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
29 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
30 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
31 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
32 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
33 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
34 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
35 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
36 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
37 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
38 / 100
We know Something in Common
• C
• C++
• C#
• Java
• JavaScript
• Perl
• PHP
• Python
• Ruby
• SQL
According to langpop.com, 10 most cited programming languages
39 / 100
Principles of Programming Language
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
40 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
41 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
42 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
43 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
44 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
45 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
46 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
47 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
48 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
49 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
50 / 100
Principles of Programming Language?
Human Language
• Vocabulary
• Grammar
• Proper Name/Noun (e.g.,Gosling is the ...)
• ...
Programming Language
• Key words
• Grammar
• Variable Name (e.g., int x
= 3;)
• ...
51 / 100
Difference between Human Language andProgramming Language
“Colorless green ideas sleep furiously.”“John is a married bachelor.”
52 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
53 / 100
Brief history of Programming Languages
• Machine language
• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
54 / 100
Brief history of Programming Languages
• Machine language
• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
“Hello world” example in Machinelanguage
110011100111000001111100000001000011111000011111100000000010 \\
000011001111100001100010000010011111000100000000000001001111 \\
100000111110001000000000000000001000111110010000001100001111 \\ 100011000000000100111110011100111000111000001000111000001111
55 / 100
Brief history of Programming Languages
• Machine language
• Assembly language
• FORTRAN (1957), COBOL(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
56 / 100
Brief history of Programming Languages
• Machine language
• Assembly language
• FORTRAN (1957), COBOL(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
“Hello world” example in Assemblylanguage for the IBM-PC (i386)
dosseg
.model small
.stack 100h
.data
hello_message db ’Hello, World!’,0dh,0ah,’$’
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx,offset hello_message
int 21h
mov ax,4C00h
int 21h
main endp
end main57 / 100
Brief history of Programming Languages
• Machine language• Assembly language
• FORTRAN (1957), COBOL(1959), BASIC (1964), C(1972)
• LISP (1959)→ Scheme (1975),Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
58 / 100
Brief history of Programming Languages
• Machine language• Assembly language
• FORTRAN (1957), COBOL(1959), BASIC (1964), C(1972)
• LISP (1959)→ Scheme (1975),Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
“Hello world” example in FORTRAN
program helloworld
write (*,*) ‘‘Hello, world.’’
end program helloworld
59 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)
• LISP (1959)→ Scheme (1975),Common Lisp (1984)
• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
60 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)
• LISP (1959)→ Scheme (1975),Common Lisp (1984)
• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
“Hello world” example in LISP
(DEFUN HELLO-WORLD ()
(PRINT (LIST ’HELLO ’WORLD)))
61 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)
• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
62 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)
• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)• Perl (1987), Python (1990s),
JavaScript (1995), PHP (1995),
“Hello world” example in Prolog
?- write(’Hello world.’), nl.
Hello world.
true.
?-
63 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)
• Perl (1987), Python (1990s),JavaScript (1995), PHP (1995),
64 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)
• Perl (1987), Python (1990s),JavaScript (1995), PHP (1995),
“Hello world” example in Java
class HelloWorldApp {
public static void main(String[] args){
System.out.println("Hello World!");
}
}
65 / 100
Brief history of Programming Languages
• Machine language• Assembly language• FORTRAN (1957), COBOL
(1959), BASIC (1964), C(1972)• LISP (1959)→ Scheme (1975),
Common Lisp (1984)• Prolog (1973)
• Simula (1967), Smalltalk(1980), C++ (1985), Java(1995), C# (2002)
• Perl (1987), Python (1990s),JavaScript (1995), PHP (1995),
66 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
67 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
68 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
69 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
70 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
71 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
72 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
73 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
74 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
75 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
76 / 100
Programming Paradigms
Imperative programming
• assemblers, FORTRAN, BASIC, COBOL
• Structured programming (ALGOL, Pascal, C)
Object-oriented programming
• Smalltalk, C++, Java
Functional programming
• Lisp, Scheme, ML, Haskell
Logic programming
• Prolog, VisiCalc
77 / 100
78 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
79 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
80 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
81 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
82 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
83 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
84 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
85 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
86 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
87 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
88 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
89 / 100
Why So Many Programming Languages?
• Evolution
• Special purpose
• Personal preference
What makes a programming language successful?
• Expressive power
• Easy to learn
• Easy to implement
• Open-source
• Good compilers (e.g., FORTRAN)
• Economics, patronage, inertia
90 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
91 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
92 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
93 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
94 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
95 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end.
Implementation
96 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end. Implementation
97 / 100
Compiler/Interpreter
{calculate greatest common divisor}program gcd(input, output);
var i, j : integer;
begin
read(i, j);
while i <> j do
if i > j then i := i - j
else j := j - i;
writeln(i);
end. Implementation
98 / 100
99 / 100
How is This Course Useful?
� Help choose the most appropriate language for the job,evaluate trade-offs
� Make it easier to learn new languages
� Learn to simulate useful features in languages that lack them
� ?
100 / 100