Principles 990128; P.F. Reynolds CS655.

Slides:



Advertisements
Similar presentations
Models of Concurrency Manna, Pnueli.
Advertisements

Programming Languages and Paradigms
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
CS 415: Programming Languages Algol Aaron Bloomfield Fall 2005.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
G. Levine Chapter 6 Chapter 6 Encapsulation –Why do we want encapsulation? Programmer friendliness- programmer need not know about these details –Easier.
Chapter 8 . Sequence Control
Chapter 9: Subprogram Control
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Language Evaluation Criteria
MT311 Java Programming and Programming Languages Li Tak Sing ( 李德成 )
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
COP4020 Programming Languages
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001.
CS 2104 Prog. Lang. Concepts Subprograms
1 Programming Languages B.J. Maclennan 2. Fortran: Emphasis on Efficiency.
1 Names, Scopes and Bindings Aaron Bloomfield CS 415 Fall
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Basic Semantics Associating meaning with language entities.
1 Scope Scope describes the region where an identifier is known, and semantic rules for this.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
The Evolution of Programming Languages Day 2 Lecturer: Xiao Jia The Evolution of PLs1.
Implementing Subprograms What actions must take place when subprograms are called and when they terminate? –calling a subprogram has several associated.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Chapter 3 - Language Design Principles
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Programming Language Design Issues Programming Languages – Principles and Practice by Kenneth C Louden.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
CSE3302 Programming Languages (notes continued)
CSC 533: Programming Languages Spring 2016
CSC 533: Programming Languages Spring 2015
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Names and Attributes Names are a key programming language feature
CS 3304 Comparative Languages
Abstract Data Types and Encapsulation Concepts
Chapter - 8 Implementation.
CS 326 Programming Languages, Concepts and Implementation
CS 326 Programming Languages, Concepts and Implementation
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
Dr. Vamsi Paruchuri University of Central Arkansas
Statement-Level Control Structures
11.1 The Concept of Abstraction
CS212: Object Oriented Analysis and Design
Chapter 8: Control Structures
FORTRAN 04 February 1999; CS655.
Chap. 6 :: Control Flow Michael L. Scott.
Names, Binding, and Scope
Abstract Data Types and Encapsulation Concepts
CMPE 152: Compiler Design October 4 Class Meeting
Chap. 6 :: Control Flow Michael L. Scott.
Names and Binding In Text: Chapter 5.
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Programming Languages, Preliminaries, History & Evolution
Types and Related Issues
Presentation transcript:

Principles 990128; P.F. Reynolds CS655

MacLennan’s Principles Abstraction Avoid requiring something to be stated more than once; factor out the recurring pattern. Subprograms, user defined types, inheritance Automation Automate mechanical, tedious, or error-prone activities. Garbage collection; looping structures 990128; P.F. Reynolds CS655

MacLennan’s Principles (2) Defense in Depth Have a series of defenses so that if an error isn't caught by one, it will probably be caught by another. Array bound being part of type; definite loops. Information Hiding The language should permit modules to be designed so that (1) the user has all of the information needed to use the module correctly, and nothing more; and (2) the implementor has all of the information needed to implement the module correctly, and nothing more. Modules, packages, objects 990128; P.F. Reynolds CS655

MacLennan’s Principles (3) Labeling Avoid arbitrary sequences more than a few items long. Do not require the user to know the absolute position of an item in a list. Instead, associate a meaningful label with each item and allow the items to occur in any order. Case statement, position-independent parameters. Localized Cost Users should only pay for what they use; avoid distributed costs. Violations: Algol60 loops, dynamic type binding. 990128; P.F. Reynolds CS655

MacLennan’s Principles (4) Manifest Interface All interfaces should be apparent (manifest) in the syntax. Module specifications; function prototypes Orthogonality Independent functions should be controlled by independent mechanisms. Algol68 types; Ada parameter passing 990128; P.F. Reynolds CS655

MacLennan’s Principles (5) Portability Avoid features or facilities that are dependent on a particular machine or a small class of machines. Ada prohibition of aliasing; C/Algol60 I/O Preservation of Information The language should allow the representation of information that the user might know and that the compiler might need. Definite looping structures 990128; P.F. Reynolds CS655

MacLennan’s Principles (6) Regularity Regular rules, without exception, are easier to learn, use describe and implement. Violations: strings in most langs; Pascal functions. Security No program that violates the definition of the language, or its own intended structure, should escape detection. Strong typing in Algol60, Pascal, Ada, C++ 990128; P.F. Reynolds CS655

MacLennan’s Principles (7) Simplicity A language should be as simple as possible. There should be a minimum number of concepts, with simple rules for their combination. Pascal; Ada name equivalence Structure The static structure of the program should correspond in a simple way to the dynamic structure of the corresponding computations. Single entry / single exit; violation: Pascal’s upside- down procedures first form. 990128; P.F. Reynolds CS655

MacLennan’s Principles (8) Syntactic Consistency Similar things should look similar; different things different. Violations: ,/; in Algol68; blocks vs compound statements; Ada private / limited private Zero-One-Infinity The only reasonable numbers are zero, one, and infinity. Array dimensions; identifier sizes; function nesting 990128; P.F. Reynolds CS655

More Principles (Ghezzi & Jazayeri) Efficiency translation & execution Readability Writability Reliability rigorous semantics; clear distinction between static and dynamic checks; modularity 990128; P.F. Reynolds CS655

More Principles Predictability Learnability Maintainability Verifiability ??? Must it end in “ility”? 990128; P.F. Reynolds CS655

More Principles (Yemini & Berry) Wide horizon: Whenever the semantics of a construct, C, in a language for concurrent programming implies the delay of a process (task) executing in C, C should be able to have other alternatives, and all such constructs should be able to serve as alternatives to each other. Not satisfied by semaphores, monitor calls or Ada select statement. 990128; P.F. Reynolds CS655

More Principles (Yemini & Berry) (2) Closure under binding: For every concurrent program, there exists a sequential, possibly non-deterministic, program with an equivalent semantics. No unitask program in Ada can simulate: declare task t1 is s1.e1() end t1; task t2 is s2.e2() end t2; begin end; -- s1 and s2 are called in arbitrary order. 990128; P.F. Reynolds CS655

What’s this violate? COMMON a, b, lab . . . 3 WRITE(6,5) 5 FORMAT( . . .) ASSIGN 3 TO lab CALL sub2 END SUBROUTINE sub2 COMMON c, d, lab GOTO lab 3 i = 1/0 RETURN 990128; P.F. Reynolds CS655

What’s this violate? 10 i=0 call doThing(... i ...) i=i+1 IF i <= n THEN GOTO 10 990128; P.F. Reynolds CS655

What’s this violate? i = 10; s = 10; . . . s = "this is a string"; IF i != 10 THEN someFunc(i); s = 3.14159; IF s = pi THEN . . . 990128; P.F. Reynolds CS655

What’s this violate? val = -7 a= val >> 2 val = 15 990128; P.F. Reynolds CS655

What’s this violate? GOTO i-- branch to i-th statement . . . <statement i> <statement n> 990128; P.F. Reynolds CS655

What’s this violate? 990128; P.F. Reynolds CS655

What’s this violate? DIMENSION a(20) CALL subr(a) . . . END SUBROUTINE subr (n) DIMENSION n(25); IF n(22) = ... 990128; P.F. Reynolds CS655

What’s this violate? i:= 1; WHILE i < n DO BEGIN WRITE ( exp(i)); i:= i+1 END; REPEAT UNTIL i = n FOR i:= 1 TO n-1 DO WRITE ( exp(i)) 990128; P.F. Reynolds CS655

What’s this violate? FOR (; curr != NULL ; curr = temp) { temp = curr->next; FREE ((char *) curr); } 990128; P.F. Reynolds CS655

What’s this violate? IF ( I = 0 ) … IF ( I == 0 ) ... 990128; P.F. Reynolds CS655

What’s this violate? 10 IF (n > 0) THEN GOTO 20 n = 0 GOTO 22 IF (m > 0) Then GOTO 25 n = infinity GOTO 40 25 n = m/2 30 IF (n < 1000) THEN GOTO 40 n = n - 1729 GOTO 10 40 CONTINUE 990128; P.F. Reynolds CS655

What’s this violate? GOTO 10 . . . ASSIGN 20 to n GOTO n, (10,20,30,40) -- assigned GOTO n = 3 GOTO (10,20,30,40), n -- computed GOTO 990128; P.F. Reynolds CS655

What’s this violate? WHILE inch = ' ' DO READ(infile, inch); i:= 1; BEGIN READ(infile, inch); scannedText[i]:= inch; i:= i+1 END 990128; P.F. Reynolds CS655

What’s this violate? I++ ++I I+=1 I=I+1 990128; P.F. Reynolds CS655

What’s this violate? TYPE stackType = array[1..100] of INTEGER; VAR stack: stackType; top: integer = 0; PROCEDURE PUSH (object: INTEGER); . . . END; {PUSH} PROCEDURE POP (VAR object: INETGER); END; {POP} BEGIN {main} push(10); IF stack[1] = . . . END. {main} 990128; P.F. Reynolds CS655

What’s this violate? PRINTF("Address of x: %d\n", &x); -- Fails sometimes PRINTF("Address of x: %ld\n", (long) &x); -- Succeeds 990128; P.F. Reynolds CS655

What’s this violate? VAR i: INTEGER; PROCEDURE ref (VAR j: INETGER); VAR x: INTEGER; BEGIN j:= 2; x:= j+i; WRITELN (x) END; {ref} i:= 1; ref(i); . . . END. 990128; P.F. Reynolds CS655

What’s this violate? TYPE stackType=ARRAY[0..100] OF INTEGER; stptr=^stackType; . . . FUNCTION f0 (x: INTEGER; y:BOOLEAN): stptr; -- OK! FUNCTION f1 (x: INTEGER; y: BOOLEAN): stackType -- ERROR! 990128; P.F. Reynolds CS655

What’s this violate? TYPE PiType = (tenn, others); PiRec = RECORD CASE PiType OF tenn: (intPi: integer); others: (realPi: real); VAR wholePi: Pirec; BEGIN wholePi.intPi:= 3; . . . WRITELN(wholePi.realPi . . .) END. 990128; P.F. Reynolds CS655

What’s this violate? print("n is not zero") GOTO 30 IF n = 0 THEN GOTO 20 print("n is not zero") GOTO 30 20 print("n is zero") 30 CONTINUE 990128; P.F. Reynolds CS655