concepts of programming languages - ksufac.ksu.edu.sa/sites/default/files/01-introduction.pdf ·...
TRANSCRIPT
![Page 1: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/1.jpg)
Concepts of Programming LanguagesLecture 1 - Introduction
Patrick Donnelly
Montana State University
Spring 2014
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 1 / 46
![Page 2: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/2.jpg)
Textbook
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 2 / 46
![Page 3: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/3.jpg)
Administrivia
Website:
http://nisl.cs.montana.edu/~pdonnelly/CSCI305/
Reading:
Chapter 1
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 3 / 46
![Page 4: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/4.jpg)
A good programming language is a conceptual universefor thinking about programming.
A. Perlis
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 4 / 46
![Page 5: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/5.jpg)
Reasons for Studying Programming Languages
Increased ability to express ideas
Improved background for choosing appropriate languages
Increased ability to learn new languages
Better understanding of significance of implementation
Better use of languages that are already known
Overall advancement of computing
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 5 / 46
![Page 6: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/6.jpg)
Principles
Programming languages have four properties:SyntaxNamesTypesSemantics
For any language:Its designers must define these propertiesIts programmers must master these properties
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 6 / 46
![Page 7: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/7.jpg)
Syntax
DefinitionThe syntax of a programming language is a precise description of allits grammatically correct programs.
When studying syntax, we ask questions like:
What is the grammar for the language?
What is the basic vocabulary?
How are syntax errors detected?
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 7 / 46
![Page 8: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/8.jpg)
Names
Various kinds of entities in a program have names:variablestypesfunctionsparametersclassesobjects
Named entities are bound in a running program to:ScopeVisibilityTypeLifetime
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 8 / 46
![Page 9: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/9.jpg)
Names
Various kinds of entities in a program have names:variablestypesfunctionsparametersclassesobjects
Named entities are bound in a running program to:ScopeVisibilityTypeLifetime
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 8 / 46
![Page 10: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/10.jpg)
Types
DefinitionA type is a collection of values and a collection of operations on thosevalues.
Simple types:numberscharactersbooleans, . . . etc.
Structured typesStrings,lists,trees,hash tables, . . . etc..
DefinitionA language’s type system can help to:
Determine legal operationsDetect type errors
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 9 / 46
![Page 11: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/11.jpg)
Semantics
DefinitionThe meaning of a program is called its semantics.
In studying semantics, we ask questions like:
When a program is running, what happens to the values of thevariables?
What does each statement mean?
What underlying model governs run-time behavior, such asfunction call?
How are objects allocated to memory at run-time?
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 10 / 46
![Page 12: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/12.jpg)
Paradigms
DefinitionA programming paradigm is a pattern of problem-solving thought thatunderlies a particular genre of programs and languages.
There are four main programming paradigms:
Imperative
Object-oriented
Functional
Logic
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 11 / 46
![Page 13: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/13.jpg)
Imperative Paradigm
Follows the classic von Neumann-Eckert model:
Program and data are indistinguishable in memory
Program = a sequence of commands
State = values of all variables when program runs
Large programs use procedural abstraction
Example imperative languages:CobolFortranCAdaPerl
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 12 / 46
![Page 14: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/14.jpg)
The von Neumann-Eckert Model
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 13 / 46
![Page 15: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/15.jpg)
Object-oriented (OO) ParadigmAn OO Program is a collection of objects that interact by passingmessages that transform the state.
When studying OO, we learn about:Sending MessagesInheritancePolymorphism
Example OO languages:SmalltalkJavaC++C#Python
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 14 / 46
![Page 16: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/16.jpg)
Functional ParadigmFunctional programming models a computation as a collection ofmathematical functions.
Input = domainOutput = range
Functional languages are characterized by:Functional compositionRecursion
Example functional languages:LispSchemeMLHaskell
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 15 / 46
![Page 17: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/17.jpg)
Logic Paradigm
Logic programming declares what outcome the program shouldaccomplish, rather than how it should be accomplished.
When studying logic programming we see:Programs as sets of constraints on a problemPrograms that achieve all possible solutionsPrograms that are nondeterministic
Example logic programming languages:DatalogProlog
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 16 / 46
![Page 18: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/18.jpg)
Special Topics
Concurrency:
e.g., Client-server programs
Correctness:
How can we prove that a program does what it issupposed to do under all circumstances?
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 17 / 46
![Page 19: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/19.jpg)
On Language Design
Design Constraints:
Computer architecture
Technical setting
Standards
Legacy systems
Outcomes and Goals:
1 How does a programming language emerge and becomesuccessful?
2 What key characteristics make an ideal programming language?
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 18 / 46
![Page 20: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/20.jpg)
On Language Design
Design Constraints:
Computer architecture
Technical setting
Standards
Legacy systems
Outcomes and Goals:
1 How does a programming language emerge and becomesuccessful?
2 What key characteristics make an ideal programming language?
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 18 / 46
![Page 21: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/21.jpg)
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 19 / 46
![Page 22: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/22.jpg)
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 20 / 46
![Page 23: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/23.jpg)
Language Design Trade-Offs
Reliability vs. cost of executionExample: Java demands all references to array elements bechecked for proper indexing, which leads to increased executioncosts
Readability vs. writabilityExample: APL provides many powerful operators (and a largenumber of new symbols), allowing complex computations to bewritten in a compact program but at the cost of poor readability
Writability (flexibility) vs. reliabilityExample: C++ pointers are powerful and very flexible but areunreliable
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 21 / 46
![Page 24: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/24.jpg)
Compilation
Compiler – translate high-level program (source language) intomachine code (machine language)
Programs are translated into machine language; includes JITsystemsSlow translation, fast executionUse: Large commercial applications
Example compiled languages:Fortran, Cobol, C, C++
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 22 / 46
![Page 25: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/25.jpg)
Compilation
Compiler – translate high-level program (source language) intomachine code (machine language)
Programs are translated into machine language; includes JITsystemsSlow translation, fast executionUse: Large commercial applications
Example compiled languages:Fortran, Cobol, C, C++
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 22 / 46
![Page 26: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/26.jpg)
CompilationCompilation process has several phases:
lexical analysis: converts characters in the source program intolexical units
syntax analysis: transforms lexical units into parse trees whichrepresent the syntactic structure of program
semantics analysis: generate intermediate code
code generation: machine code is generated
Load module (executable image): the user and system codetogether
Linking and loading: the process of collecting system program unitsand linking them to a user program
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 23 / 46
![Page 27: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/27.jpg)
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 24 / 46
![Page 28: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/28.jpg)
Von Neumann Bottleneck
Connection speed between a computer’s memory and its processordetermines the speed of a computer
Program instructions often can be executed much faster than thespeed of the connection; the connection speed thus results in abottleneck
Known as the von Neumann bottleneck; it is the primary limitingfactor in the speed of computers
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 25 / 46
![Page 29: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/29.jpg)
Pure InterpretationInterpreter – executes instructions on a virtual machine
Programs are interpreted by another program known as aninterpreter
No translation
Easier implementation of programs (run-time errors can easily andimmediately be displayed)
Slower execution (10 to 100 times slower than compiled programs)
Often requires more space
Now rare for traditional high-level languages but recent comebackwith some Web scripting languages (e.g., JavaScript, PHP)
Use: Small programs or when efficiency is not an issue
Example interpreted languages:Scheme, Haskell, Python
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 26 / 46
![Page 30: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/30.jpg)
Pure InterpretationInterpreter – executes instructions on a virtual machine
Programs are interpreted by another program known as aninterpreter
No translation
Easier implementation of programs (run-time errors can easily andimmediately be displayed)
Slower execution (10 to 100 times slower than compiled programs)
Often requires more space
Now rare for traditional high-level languages but recent comebackwith some Web scripting languages (e.g., JavaScript, PHP)
Use: Small programs or when efficiency is not an issue
Example interpreted languages:Scheme, Haskell, Python
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 26 / 46
![Page 31: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/31.jpg)
The Interpreting Process
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 27 / 46
![Page 32: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/32.jpg)
Hybrid Implementation Systems
A compromise between compilers and pure interpreters
A high-level language program is translated to an intermediatelanguage that allows easy interpretation
Faster than pure interpretation
Use: Small and medium systems when efficiency is not the firstconcern
Example Hybrid compilation/interpretationThe Java Virtual Machine (JVM)Perl programs are partially compiled to detect errors beforeinterpretation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 28 / 46
![Page 33: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/33.jpg)
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 29 / 46
![Page 34: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/34.jpg)
Just-in-Time Implementation Systems
Initially translate programs to an intermediate language
Then compile the intermediate language of the subprograms intomachine code when they are called
Machine code version is kept for subsequent calls
JIT systems are widely used for Java programs
.NET languages are implemented with a JIT system
In essence, JIT systems are delayed compilers
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 30 / 46
![Page 35: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/35.jpg)
Preprocessors
Preprocessor macros (instructions) are commonly used to specify thatcode from another file is to be included
A preprocessor processes a program immediately before the programis compiled to expand embedded preprocessor macros
A well-known example: C preprocessor expands #include,#define, and similar macros
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 31 / 46
![Page 36: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/36.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 32 / 46
![Page 37: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/37.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 33 / 46
![Page 38: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/38.jpg)
Simplicity and Readability
Small instruction set:e.g., Java vs Scheme
Simple syntax:e.g., C/C++/Java vs Python
Benefits:Ease of learningEase of programming
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 34 / 46
![Page 39: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/39.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 35 / 46
![Page 40: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/40.jpg)
Clarity about BindingA language element is bound to a property at the time that property isdefined for it.
DefinitionA binding is the association between an object and a property of thatobject.
Examplesa variable and its typea variable and its value
Early binding takes place at compile-time.
Late binding takes place at run time
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 36 / 46
![Page 41: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/41.jpg)
Clarity about BindingA language element is bound to a property at the time that property isdefined for it.
DefinitionA binding is the association between an object and a property of thatobject.
Examplesa variable and its typea variable and its value
Early binding takes place at compile-time.
Late binding takes place at run time
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 36 / 46
![Page 42: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/42.jpg)
Clarity about BindingA language element is bound to a property at the time that property isdefined for it.
DefinitionA binding is the association between an object and a property of thatobject.
Examplesa variable and its typea variable and its value
Early binding takes place at compile-time.
Late binding takes place at run time
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 36 / 46
![Page 43: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/43.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 37 / 46
![Page 44: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/44.jpg)
ReliabilityA language is reliable if:
Program behavior is the same on different platformse.g., early versions of Fortran
Type errors are detectede.g., C vs Haskell
Semantic errors are properly trappede.g., C vs C++
Memory leaks are preventede.g., C vs Java
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 38 / 46
![Page 45: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/45.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 39 / 46
![Page 46: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/46.jpg)
Language Support
Accessible (public domain) compilers/interpreters
Good texts and tutorials
Wide community of users
Integrated with development environments (IDEs)
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 40 / 46
![Page 47: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/47.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 41 / 46
![Page 48: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/48.jpg)
Abstraction in Programming
Data:
Programmer-defined types/classes
Class libraries
Procedural:
Programmer-defined functions
Standard function libraries
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 42 / 46
![Page 49: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/49.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 43 / 46
![Page 50: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/50.jpg)
Orthogonality
DefinitionA language is orthogonal if its features are built upon a small,mutually independent set of primitive operations.
Fewer exceptional rules = conceptual simplicity
Examplerestricting types of arguments to a function
Tradeoffs with efficiency
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 44 / 46
![Page 51: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/51.jpg)
Orthogonality
DefinitionA language is orthogonal if its features are built upon a small,mutually independent set of primitive operations.
Fewer exceptional rules = conceptual simplicity
Examplerestricting types of arguments to a function
Tradeoffs with efficiency
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 44 / 46
![Page 52: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/52.jpg)
Characteristics of a Successful Language
Simplicity and readability
Clarity about binding
Reliability
Support
Abstraction
Orthogonality
Efficient implementation
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 45 / 46
![Page 53: Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf · Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana](https://reader034.vdocument.in/reader034/viewer/2022052303/5f097e267e708231d427160b/html5/thumbnails/53.jpg)
Efficient Implementation
Embedded systemsReal-time responsiveness (e.g., navigation)Failures of early Ada implementations
Web applicationsResponsiveness to users (e.g., Google search)
Corporate database applicationsEfficient search and updating
AI applicationsModeling human behaviors
Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 46 / 46