Session 02 Ronald L Ramos Programming Languages Programming Languages concepts Outline Why Study Programming Languages Language Design Criteria Effects of Environments on Languages Programming Paradigms ID: 383087
Download Presentation The PPT/PDF document "ProgLan" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
ProgLan Session 02Ronald L. Ramos
Programming
LanguagesSlide2
Programming Languages conceptsSlide3
Outline
Why Study Programming Languages?
Language Design Criteria
Effects of Environments on Languages
Programming Paradigms
History of Programming LanguagesSlide4
Why Study Programming Languages?Language Design
CriteriaSlide5
What is a Programming Language?
A notation for instructions to be performed by the computer
Any notation for the description of algorithms and data structures
Used as a means of communicating ideas about algorithms between people and computersSlide6
What is a Programming Language?
The earliest programming languages predate the invention of the computer, and were used to direct the behavior of machines such as Jacquard looms and player pianosSlide7
Why study Programming Language Concepts?
To improve your ability to develop effective algorithms
To improve your use of your existing programming language (
better understanding of the significance of implementation)
To increase your vocabulary of useful programming constructs (
increased capacity to express ideas)Slide8
Why study Programming Languages Concepts?
To allow a better choice of programming language (
improved background for choosing appropriate languages)
To make it easier to learn a new language (
increased ability to learn new languages)
To make it easier to design a new languageSlide9
Why study Programming Languages Concepts?
Overall advancement of computing
Why was Fortran more popular than Algol?
because of industry support
because of the cost of change
because of acceptance by the public sector
because top management failed to understand the concepts of programming languages
Slide10
Introduction
Why Study Programming Languages?
Language Design Criteria
Effects of Environments on Languages
Programming Paradigms
History of
Programming LanguagesSlide11
Effects of Environments on LanguagesProgramming ParadigmsSlide12
Language Evaluation and
Design Criteria
Readability
Overall Simplicity
Feature multiplicity
There are 4 ways to increment a variable called
count
in C++:
++count; count++;
count += 1; count = count + 1;Slide13
Language Evaluation and
Design Criteria
Operator overloading
The + operator has 4 meanings in Visual Basic:
5 + 10 ‘ integer addition
5.5 + 10 ‘ floating point addition
5.5 + 3.5 ‘ floating point addition
“hello” + “world” ‘ string concatenation
In languages that provide facilities for programmers to define their own overloaded operations, we could even have:
file1 + file2 ‘ appending file1 and file2
bmp1 + bmp2 ‘ overlaying bitmaps
array1 + array2 ‘ adding parallel arraysSlide14
Language Evaluation and
Design Criteria
Readability
Orthogonality
// IBM instructions for adding two 32-bit integers
A Reg, Mem
Reg = Reg + Mem
AR Reg1, Reg2 Reg1 = Reg1 + Reg2
// cannot add two memory, or memory and register, and
// storing the result in memory
// VAX instruction
ADDL opd1, opd2
// opd1 and opd2 can be either a memory or a register
// allow any possible combination of operands and all are valid
// few exception and inconsistent rulesSlide15
Language Evaluation and
Design Criteria
Readability
Syntax (Form) Consideration
Identifier forms
What is the maximum length of characters that is significant in an identifier name? Are the following identifier names the same?
ThisIsALongIdentifier ThisIsALong
Is the language case-sensitive? Are the following identifier names the same?
Name NAME name
Are connector characters, such as _, allowed?Slide16
Language Evaluation and
Design Criteria
Special words for compound statements
“end” vs “end if” “end do” “end sub”
sub … sub …
for … for …
if … if …
end end if
end end for
end end sub
Reserved words vs Keywords
Are the following allowed as identifier names?
dim true as integer
dim false as doubleSlide17
Language Evaluation and
Design Criteria
Writability
Simplicity and orthogonality
Support for abstraction
Expressitivity
for I = 1 to 10 I = 1
: while I <= 10
next I :
I = I + 1
loopSlide18
Language Evaluation and
Design Criteria
Reliability
Type checking
Exception handling
Aliasing
Readability and Writability
Portability
Generality
Well-definednessSlide19
Language Evaluation and
Design Criteria
Cost
Training programmers
Writing programs
Validation and Verifying programs
Compiling programs
Executing programs
Maintaining programs
ReliabilitySlide20
Language Design Trade-Offs
Reliability vs. Cost of Execution
Readability vs. Writability
Flexibility vs. SafetySlide21
Introduction
Why Study Programming Languages?
Language Design Criteria
Effects of Environments on Languages
Programming Paradigms
History of Programming Languages ®Slide22
What is an Environment?
Operating or target environment
External environment supporting the execution of a program
Host environment
Environment in which a program is designed, coded, tested, and debuggedSlide23
Batch-Processing Environments
A program takes a set of data files as input, process the data, and produces a set of output data files.
Input data are collected and processed as batch files by the program.Slide24
Batch-Processing Environments
Effects on language design:
Input-output features
File structure
Error- and exception-handling features
The entire run must be stopped, the program corrected, and then re-executed
No external help in immediately addressing the exception is available from the user
Exception-handling must be coded into the program to prevent abnormal terminationSlide25
Batch-Processing Environments
Timing facilities
None
OS (depending on its CPU scheduling algorithm) may allow the program to execute partially, then swap it out to secondary storage for an indefinite period, and later bring it back to continue execution
Program structure
Consists of a main program and a number of subprogramsSlide26
Interactive Environments
Direct interaction between the user and the computer during program execution.
Examples: Office tools, games, database management systems, CAI, transaction processing systems, client/server applicationsSlide27
Interactive Environments
Effects on language design:
Input-output features
scanf, printf
println
Error- and exception-handling features
Input validation
Error messageSlide28
Interactive Environments
Timing facilities
User response time (ATM, video game)
System response time
Program structure
Consists of a set of subprogramsSlide29
Embedded System Environments
An embedded computer system is used to control part of a larger system.
Failure of embedded systems can be life-threatening.
Primary attributes - reliability and correctness.Slide30
Embedded System Environments
Effects on language design:
Input-output features
Special devices, e.g., hardware registers, memory locations, interrupt handlers, or subprograms written in assembly or other low-level languages
Error- and exception-handling features
System-provided and extensiveSlide31
Embedded System Environments
Timing facilities
Real-time
Program structure
An embedded computer system is often a distributed system, consisting of tasks that operate concurrently, each controlling or monitoring one part of the system.Slide32
Programming Environments
The environment in which programs are created and tested.
Support tools:
project management
compiler, debugger
text editor (color coding scheme, automatic code completion, pretty printers)
help
test data generatorsSlide33
Programming Environments
Effects on language design:
Features aiding separate compilation of subprograms
Require the
redeclaration
of needed information
Prescribe a particular
order of compilation
so that specification of all subprograms and shared data are compiled first
Presence of a library containing the relevant specifications during compilation so that the compiler may retrieve them as neededSlide34
Programming Environments
Examples
DLL (Visual Basic)
Declare Function GetPrivateProfileInt Lib “kernel” (ByVal Section As String, ByVal Entry As String, ByVal Entry As Integer, ByVal FileName As String) As Integer
import <package> (Java)
import java.util.*;
uses <unit> (Pascal)
uses crt, graphics;
extern <variable declaration> (C)
extern int i;Slide35
Programming Environments
Features aiding program testing and debugging
Execution trace feature
Break point
Assertion
a conditional expression inserted as a separate statement in a program
states the relations that must hold among the values of the variables at that point in the programSlide36
Introduction
Why Study Programming Languages?
Language Design Criteria
Effects of Environments on Languages
Programming Paradigms
History of Programming Languages ®Slide37
Programming Paradigms
Paradigms are ways for expressing algorithms that appeal especially well in a particular application area.Slide38
Programming Paradigms
Imperative or Procedural languages
Command-driven or statement-oriented languages
Basic concept: machine state
Influenced by the von Neumann architecture
Languages:
Cobol, Fortran, Basic, C/C++, Pascal
Statement
1
;
Statement
2
;
…Slide39
Programming Paradigms
Applicative or Functional languages
What is the function that must be applied to the initial machine state by accessing the initial set of variables and combining them in specific ways in order to get an answer?
Focus: what is the desired result?
Languages: LISP, ML, Scheme
fn(…(f2(f1(data)))…)Slide40
Programming Paradigms
Rule-based or Logic programming languages
Execute by checking for the presence of a certain enabling condition and when it is satisfied, they execute an appropriate action
Languages: Prolog
Enabling conditon
1
Action
1
Enabling conditon
2
Action
2
…Slide41
Programming Paradigms
Object-Oriented programming
Complex data objects are built and a limited set of functions are designed to operate on those data.
Concepts: inheritance, classification, object modeling
Combination of imperative (building concrete data objects) and applicative (building classes of functions that use a restricted set of data objects).
Languages: Smalltalk, Java, C++, EiffelSlide42
Programming Paradigms
Event-driven programming
The program is a continuous loop that responds to events that are generated in an unpredictable order.
Languages: Visual Basic, Java
main ()
{ while getmessage()
….. Check Charles PetzoldSlide43
Programming Paradigms
Declarative programming
The program is a collection of logical declarations about what outcome a function should accomplish rather than how that outcome should be accomplished.
Execution of the program applies these declarations to achieve a series of possible solutions to a problem.Slide44
Programming Paradigms
Concurrent programming
The program is a collection of cooperating processes, sharing information with each other from time to time but generally operating asynchronously.
Parallelism can occur within an individual processes, such as the parallel execution of the different iterations of a loop.
Slide45
Application Domains
Scientific computing
Imperative programming (C) and parallel programming (Ada) paradigms
Management information systems
Imperative (Cobol)
Declarative (SQL) for database retrieval
Event-driven (Java) for client-server appsSlide46
Application Domains
Artificial intelligence
Systems
Imperative (Assembly, C)
Parallel programming
Event-driven programming
Web-centric
Event-driven programming
Object-oriented designSlide47
End of Presentation