CSCI 3136 Principles of Programming Languages Summer 2013 Faculty of Computer Science Dalhousie University 1 / 100
CSCI 3136 Principles of Programming Languages Summer 2013 Aminul Islam Faculty of Computer Science Dalhousie University 2 / 100
Basic Course Information 3 / 100
Basic Course Information Web: http://web.cs.dal.ca/~islam/3136/ 4 / 100
Basic Course Information Web: http://web.cs.dal.ca/~islam/3136/ Class: Mon & Wed 12:05-13:25 at CS 127 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 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 (islam@cs.dal.ca) Office: Room # 437, The Goldberg CS Building 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 (islam@cs.dal.ca) Office: Room # 437, The Goldberg CS Building Office Hour: Fri 11:00-12:00 8 / 100
Textbooks and Other Material 9 / 100
Textbooks and Other Material Class slides are available online 10 / 100
Textbooks and Other Material Class slides are available online Recommended text: Michael L. Scott. Programming Language Pragmatics, 3rd edition 2009 11 / 100
Textbooks and Other Material Class slides are available online Recommended text: Michael L. Scott. Programming Language Pragmatics, 3rd edition 2009 More relevant books listed on the course web site (some of them are available on-line) 12 / 100
Textbooks and Other Material Class slides are available online Recommended text: Michael L. Scott. Programming Language Pragmatics, 3rd edition 2009 More relevant books listed on the course web site (some of them are available on-line) Other links can be found at course web site 13 / 100
Evaluation and Plagiarism Policy Evaluation Plagiarism policy 14 / 100
Evaluation Evaluation and Plagiarism Policy 40% assignments (Five) Plagiarism policy 15 / 100
Evaluation and Plagiarism Policy Evaluation 40% assignments (Five) 20% midterm exam Plagiarism policy 16 / 100
Evaluation and Plagiarism Policy Evaluation 40% assignments (Five) 20% midterm exam 40% final exam Plagiarism policy 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 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 be acknowledged 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 be acknowledged According to Faculty policy, any suspected case of plagiarism is referred to the Academic Integrity Officer and may be forwarded to the Senate Discipline Committee. Details at http: //www.cs.dal.ca/graduate/studentinfo/plagiarism 20 / 100
How is This Course Useful? 21 / 100
How is This Course Useful? Help choose the most appropriate language for the job, evaluate trade-offs 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 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 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 28 / 100
We know Something in Common C 29 / 100
We know Something in Common C C++ 30 / 100
We know Something in Common C C++ C# 31 / 100
We know Something in Common C C++ C# Java 32 / 100
We know Something in Common C C++ C# Java JavaScript 33 / 100
We know Something in Common C C++ C# Java JavaScript Perl 34 / 100
We know Something in Common C C++ C# Java JavaScript Perl PHP 35 / 100
We know Something in Common C C++ C# Java JavaScript Perl PHP Python 36 / 100
We know Something in Common C C++ C# Java JavaScript Perl PHP Python Ruby 37 / 100
We know Something in Common C C++ C# Java JavaScript Perl PHP Python Ruby SQL 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 40 / 100
Principles of Programming Language? 41 / 100
Principles of Programming Language? Human Language Programming Language 42 / 100
Principles of Programming Language? Human Language Vocabulary Programming Language 43 / 100
Principles of Programming Language? Human Language Vocabulary Programming Language Key words 44 / 100
Principles of Programming Language? Human Language Programming Language Grammar 45 / 100
Principles of Programming Language? Human Language Programming Language Grammar Grammar 46 / 100
Principles of Programming Language? Human Language Programming Language Proper Name/Noun (e.g., Gosling is the...) 47 / 100
Principles of Programming Language? Human Language Programming Language Proper Name/Noun (e.g., Gosling is the...) Variable Name (e.g., int x = 3;) 48 / 100
Principles of Programming Language? Human Language Programming Language... 49 / 100
Principles of Programming Language? Human Language Programming Language...... 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 and Programming Language Colorless green ideas sleep furiously. John is a married bachelor. 52 / 100
Brief history of Programming Languages 53 / 100
Machine language Brief history of Programming Languages 54 / 100
Machine language Brief history of Programming Languages Hello world example in Machine language 1100111001110000011111000000010000111110000111 0000110011111000011000100000100111110001000000 1000001111100010000000000000000010001111100100 55 / 100
Assembly language Brief history of Programming Languages 56 / 100
Brief history of Programming Languages Assembly language Hello world example in Assembly language 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 57 end / 100 main
Brief history of Programming Languages FORTRAN (1957), COBOL (1959), BASIC (1964), C (1972) 58 / 100
Brief history of Programming Languages FORTRAN (1957), COBOL (1959), BASIC (1964), C (1972) Hello world example in FORTRAN program helloworld write (*,*) Hello, world. end program helloworld 59 / 100
Brief history of Programming Languages LISP (1959) Scheme (1975), Common Lisp (1984) 60 / 100
Brief history of Programming Languages Hello world example in LISP LISP (1959) Scheme (1975), Common Lisp (1984) (DEFUN HELLO-WORLD () (PRINT (LIST HELLO WORLD))) 61 / 100
Brief history of Programming Languages Prolog (1973) 62 / 100
Prolog (1973) Brief history of Programming Languages Hello world example in Prolog?- write( Hello world. ), nl. Hello world. true.?- 63 / 100
Brief history of Programming Languages Simula (1967), Smalltalk (1980), C++ (1985), Java (1995), C# (2002) 64 / 100
Brief history of Programming Languages Hello world example in Java class HelloWorldApp { public static void main(string[] args){ System.out.println("Hello World!"); } } Simula (1967), Smalltalk (1980), C++ (1985), Java (1995), C# (2002) 65 / 100
Brief history of Programming Languages Perl (1987), Python (1990s), JavaScript (1995), PHP (1995), 66 / 100
Programming Paradigms 67 / 100
Programming Paradigms Imperative programming 68 / 100
Programming Paradigms Imperative programming assemblers, FORTRAN, BASIC, COBOL 69 / 100
Programming Paradigms Imperative programming assemblers, FORTRAN, BASIC, COBOL Structured programming (ALGOL, Pascal, C) 70 / 100
Programming Paradigms Imperative programming assemblers, FORTRAN, BASIC, COBOL Structured programming (ALGOL, Pascal, C) Object-oriented programming 71 / 100
Programming Paradigms Imperative programming assemblers, FORTRAN, BASIC, COBOL Structured programming (ALGOL, Pascal, C) Object-oriented programming Smalltalk, C++, Java 72 / 100
Programming Paradigms Imperative programming assemblers, FORTRAN, BASIC, COBOL Structured programming (ALGOL, Pascal, C) Object-oriented programming Smalltalk, C++, Java Functional programming 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 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 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? 79 / 100
Why So Many Programming Languages? Evolution 80 / 100
Why So Many Programming Languages? Evolution Special purpose 81 / 100
Why So Many Programming Languages? Evolution Special purpose Personal preference 82 / 100
Why So Many Programming Languages? Evolution Special purpose Personal preference What makes a programming language successful? 83 / 100
Why So Many Programming Languages? Evolution Special purpose Personal preference What makes a programming language successful? Expressive power 84 / 100
Why So Many Programming Languages? Evolution Special purpose Personal preference What makes a programming language successful? Expressive power Easy to learn 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 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 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) 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
{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.
{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.
{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.
{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.
{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.
{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.
{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
{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. Compiler/ Interpreter 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