Professional Documents
Culture Documents
Principles of Programming Languages
Principles of Programming Languages
Languages
Introduction
General information
2
Lecturers
● Class hours:
○ Nguyễn Thị Minh Huyền (huyenntm@hus.edu.vn)
● Lab hours:
○ Nguyễn Thị Tâm (nguyenthitam@hus.edu.vn)
○ Nguyễn Thị Minh Huyền
3
Course Objectives
● Help students to understand the concepts behind language design, i.e. to
think about languages in terms of
○ Naming and binding
○ Data types and abstraction mechanisms
○ Control flow
○ Subroutine closures
○ Concurrency
○ ...
4
Topics
● Programming languages and compilation
○ Formal specifications (lexical, syntax, semantics)
● Names, bindings, and scopes
● Control flow
● Subroutines
● Data types
● Data abstraction and object orientation
● Functional programming
● Logic programming
● Scripting
● Concurrency (optional)
5
References
● Michael L. Scott (2016), Programming Language Pragmatics, 4th edition, Morgan Kaufmann.
● Robert W. Sebesta (2019), Concepts of Programming Languages, 12th Edition, Addison Wesley.
6
Requirements
● Textbook reading before class hours
○ Q&A at the beginning and at the end of each class
● Homeworks submitted before lab hours
7
Evaluation
● Quizzes and assignments (40%)
● Final exam (60%)
8
How to study effectively?
● Always take notes (that helps you to memorize better and to identify what
you don’t understand yet)
● Identify and revise all new concepts after each class, read further
documents if needed
● Do yourself all assignments as much as possible
● Improve your English reading comprehension skills by reading and
reading again
● Self-studying is very important
9
● Why study PPL?
● Programming domains
● Language evaluation criteria
11
● Why study PLP?
● Programming domains
● Language evaluation criteria
13
● Why study PPL?
● Programming domains
● Language evaluation criteria
15
● Why study PPL?
● Programming domains
● Language evaluation criteria
17
The von Neumann Architecture
● Well-known computer
architecture: von Neumann
○ Data and programs stored in
memory
○ Memory is separate from CPU
(Central Processing Unit)
○ Instructions and data are piped
from memory to CPU
19
Programming methodologies
● 1950s and early 1960s: Simple applications, worry about machine
efficiency
● Late 1960s: People efficiency became important; readability, better
control structures
○ Structured programming
○ Top-down design and stepwise refinement
● Late 1970s: Process-oriented to data-oriented
○ Data abstraction
● Middle 1980s: Object-oriented programming
○ Data abstraction + inheritance + polymorphism
20
● Why study PPL?
● Programming domains
● Language evaluation criteria
22
● Why study PPL?
● Programming domains
● Language evaluation criteria
● Pure Interpretation
○ Interpreter stays around for the execution of the program, being the locus of control
during execution
24
Compilation vs. Interpretation
● Compilation vs. Interpretation
○ Interpretation: greater flexibility, better diagnostics (error messages)
○ Compilation: better performance (10 to 100 times faster, less space)
● Common case is compilation or simple pre-processing, followed by
interpretation
○ Most language implementations include a mixture of both compilation and interpretation
25
Layered view of computer
● The operating system and
language implementation are
layered over machine interface
of a computer
26
Additional terminologies
● Additional components for compilation
○ Load module
○ Linking and loading: collecting system program units and linking them to a user program
● Von Neumann bottleneck
○ Program instructions often can be executed much faster than the speed of the connection (between a
computer’s memory and its processor); the connection speed thus results in a bottleneck
● Just-in-Time (JIT) implementation systems: delayed compilers
○ Initially translate programs to an intermediate language
○ Then compile the intermediate language of the subprograms into machine code when they are called.
These machine code versions are kept for subsequent calls
○ Widely used for Java programs, .NET languages
● Preprocessors
○ Processes a program immediately before the program is compiled to expand embedded preprocessor
macros
○ E.g. C preprocessors expands #include, #define and similar macros (preprocessor instructions)
27
● Why study PPL?
● Programming domains
● Language evaluation criteria
29
● What are the most important criteria for evaluating
programming languages?
● What is the difference between machine language
Questions ●
and assembly language?
What distinguishes declarative languages from
imperative languages?
● Explain the distinction between interpretation and
compilation. What are the comparative advantages
and disadvantages of the two approaches?
● What is the difference between a compiler and a
preprocessor?
30
● Write programs to find the
greatest common divisor of
31
● Read the overview of
compilation (Scott book,
section 1.6)
32