Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf ·...

53
Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 1 / 46

Transcript of Concepts of Programming Languages - KSUfac.ksu.edu.sa/sites/default/files/01-introduction.pdf ·...

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

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

OUAHID
Text Box
OUAHID
Text Box
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

Textbook

Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014 2 / 46

OUAHID
Text Box
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

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

OUAHID
Text Box
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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