proglan session 02 ronald l. ramos programming languages

Post on 29-Dec-2015

224 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

P R O G L A N S E S S I O N 0 2R O N A L D L . R A M O S

PROGRAMMING LANGUAGES

PROGRAMMING LANGUAGES CONCEPTS

OUTLINE

• Why Study Programming Languages?• Language Design Criteria• Effects of Environments on Languages• Programming Paradigms• History of Programming Languages

WHY STUDY PROGRAMMING LANGUAGES?

LANGUAGE DESIGN CRITERIA

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 computers

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 pianos

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)

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 language

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

INTRODUCTION

• Why Study Programming Languages?• Language Design Criteria• Effects of Environments on Languages• Programming Paradigms• History of Programming Languages

EFFECTS OF ENVIRONMENTS ON LANGUAGESPROGRAMMING PARADIGMS

LANGUAGE EVALUATION AND DESIGN CRITERIA

• Readability• Overall Simplicity

• Feature multiplicityThere are 4 ways to increment a variable called count in C++:

++count; count++;count += 1; count = count + 1;

LANGUAGE EVALUATION AND DESIGN CRITERIA

• Operator overloading

The + operator has 4 meanings in Visual Basic:5 + 10 ‘ integer addition5.5 + 10 ‘ floating point addition5.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 file2bmp1 + bmp2 ‘ overlaying bitmapsarray1 + array2 ‘ adding parallel

arrays

LANGUAGE EVALUATION AND DESIGN CRITERIA

• Readability• Orthogonality

// IBM instructions for adding two 32-bit integersA 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 instructionADDL 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 rules

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?

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 ifend end for

end end sub

• Reserved words vs Keywords

Are the following allowed as identifier names?

dim true as integerdim false as double

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 + 1loop

LANGUAGE EVALUATION AND DESIGN CRITERIA

• Reliability• Type checking• Exception handling• Aliasing• Readability and Writability

• Portability• Generality• Well-definedness

LANGUAGE EVALUATION AND DESIGN CRITERIA

• Cost • Training programmers• Writing programs• Validation and Verifying programs• Compiling programs• Executing programs• Maintaining programs• Reliability

LANGUAGE DESIGN TRADE-OFFS

• Reliability vs. Cost of Execution• Readability vs. Writability• Flexibility vs. Safety

INTRODUCTION

• Why Study Programming Languages?• Language Design Criteria• Effects of Environments on Languages• Programming Paradigms• History of Programming Languages ®

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 debugged

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.

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 termination

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 subprograms

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 applications

INTERACTIVE ENVIRONMENTS

• Effects on language design:• Input-output features

• scanf, printf• println

• Error- and exception-handling features• Input validation• Error message

INTERACTIVE ENVIRONMENTS

• Timing facilities• User response time (ATM, video game)• System response time

• Program structure• Consists of a set of subprograms

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.

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 extensive

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.

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 generators

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 needed

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;

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 program

INTRODUCTION

• Why Study Programming Languages?• Language Design Criteria• Effects of Environments on Languages• Programming Paradigms• History of Programming Languages ®

PROGRAMMING PARADIGMS

• Paradigms are ways for expressing algorithms that appeal especially well in a particular application area.

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

Statement1;Statement2;

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)))…)

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: PrologEnabling conditon1 Action1

Enabling conditon2 Action2

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++, Eiffel

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, Javamain (){ while getmessage()

….. Check Charles Petzold

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.

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.

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 apps

APPLICATION DOMAINS

• Artificial intelligence • Systems

• Imperative (Assembly, C)• Parallel programming• Event-driven programming

• Web-centric• Event-driven programming • Object-oriented design

END OF PRESENTATION

top related