Programming Languages

Similar documents
Programming Languages 2nd edition Tucker and Noonan"

CS112 Lecture: Making Choices

5 The Control Structure Diagram (CSD)

Lecture Notes on Programming Languages

System Verilog Tagged Unions and Pattern Matching

Programming Languages Third Edition. Chapter 7 Basic Semantics

Fundamentals of Programming Languages. PL quality factors Lecture 01 sl. dr. ing. Ciprian-Bogdan Chirila

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

What is a programming language?

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Part 5. Verification and Validation

Introduction. A. Bellaachia Page: 1

Lecture 5 Sorting Arrays

Fundamental Concepts and Definitions

Concepts of Programming Languages

Chapter 3. Set Theory. 3.1 What is a Set?

Chapter 8. Statement-Level Control Structures

Types. What is a type?

Current Issues and Future Trends. Architectural Interchange

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Tokens, Expressions and Control Structures

tyuiopasdfghjklzxcvbnmqwertyuiop

This book is licensed under a Creative Commons Attribution 3.0 License

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

IEEE LANGUAGE REFERENCE MANUAL Std P1076a /D3

Domain Specific Search Engine for Students

Chapter 7. - FORTRAN I control statements were based directly on IBM 704 hardware

Control Structures. Outline. In Text: Chapter 8. Control structures Selection. Iteration. Gotos Guarded statements. One-way Two-way Multi-way

A Small Interpreted Language

Programming Languages, Summary CSC419; Odelia Schwartz

Topic IV. Block-structured procedural languages Algol and Pascal. References:

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Language Extensions for Vector loop level parallelism

Reverse Software Engineering Using UML tools Jalak Vora 1 Ravi Zala 2

Chapter 2 Basic Elements of C++

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

Using Arithmetic of Real Numbers to Explore Limits and Continuity

Documentation Nick Parlante, 1996.Free for non-commerical use.

INSTITUTE OF AERONAUTICAL ENGINEERING

Verification and Validation

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

Chapter 5. Names, Bindings, and Scopes

Programming Style. Quick Look. Features of an Effective Style. Naming Conventions

Compiler Design. Subject Code: 6CS63/06IS662. Part A UNIT 1. Chapter Introduction. 1.1 Language Processors

CS 242. Fundamentals. Reading: See last slide

Programming Languages Third Edition

Assistant for Language Theory. SASyLF: An Educational Proof. Corporation. Microsoft. Key Shin. Workshop on Mechanizing Metatheory

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

9. Elementary Algebraic and Transcendental Scalar Functions

A Beginner s Guide to Programming Logic, Introductory. Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Technical Questions. Q 1) What are the key features in C programming language?

FRAC: Language Reference Manual

Guidelines for Coding of SAS Programs Thomas J. Winn, Jr. Texas State Auditor s Office

6.001 Notes: Section 15.1

Scheme of work Cambridge International AS & A Level Computing (9691)

2.2 Syntax Definition

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

The Object Model Overview. Contents. Section Title

Perl Basics. Structure, Style, and Documentation

Chapter 8. Achmad Benny Mutiara

CS112 Lecture: Working with Numbers

Lecture 3 Notes Arrays

CHAPTER 4 HEURISTICS BASED ON OBJECT ORIENTED METRICS

PATH FINDING AND GRAPH TRAVERSAL

Background Operators (1E) Young Won Lim 7/7/18

SPARK-PL: Introduction

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

Introduction to Parsing. Lecture 5

Objectives. Chapter 19. Verification vs. validation. Topics covered. Static and dynamic verification. The V&V process

(From Glenford Myers: The Art of Software Testing)

CSC 533: Organization of Programming Languages. Spring 2005

Software Design and Analysis for Engineers

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

COS 140: Foundations of Computer Science


Principles of Visual Design

Lectures 20, 21: Axiomatic Semantics

(Refer Slide Time: 4:00)

System Verilog Tagged Unions and Pattern Matching

GNAT Pro Innovations for High-Integrity Development

Programmers should write code that is self-documenting and split into small sections.

6.001 Notes: Section 8.1

CS 4349 Lecture August 21st, 2017

JVA-103. Java Programming

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Control Flow February 9, Lecture 7

Chapter 1. Preliminaries

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

Introduction to Assurance

Type Checking and Type Equality

Program Correctness and Efficiency. Chapter 2

EES Program Overview

Transforming Ada Serving Tasks Into Protected Objects

Supplementary Notes on Abstract Syntax

Functional Programming. Big Picture. Design of Programming Languages

Software Testing Fundamentals. Software Testing Techniques. Information Flow in Testing. Testing Objectives

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

Transcription:

Programming Languages As difficult to discuss rationally as religion or politics. Prone to extreme statements devoid of data. Examples: "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration." (Dijkstra) "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence." (Dijkstra) Like anything else, decision making should be a rational process based on the priorities and features of the project.

Some Decision Factors Features of application: Hard real time? Not just efficiency Predictability (need to guarantee deadlines will be met) High assurance? Portability? Maintainability? Others? Features of development environment: Availability of programmers, compilers, development tools? Schedule constraints? Others?

Relationship between PL and Correctness Decreasing emphasis as an explicit design goal and research topic. Masterability Not complex: programmers understand it in its entirety The most important decisions in language design concern what is to be left out." (Wirth) Powerful features OK only if easy to use correctly. Balance against need to keep language simple "Natural" Language should not surprise us in any of its effects. Should correspond to our experience with natural languages, mathematics, and other PLs

Relationship between PL and Correctness (2) Error Proneness Language design should prevent errors. Should be difficult or impossible to write an incorrect program. If not possible, then allow their detection (as early as possible) Need for general principles and hypotheses so can predict error-prone features and improve language design. Some hypotheses and data about: Go to Global variables Pointers Selection by position (long parameter lists) Defaults and implicit type conversion Attempts to interpret intentions or fix errors Meaning of features should be precisely defined (not dependent on compiler.

Relationship between PL and Correctness (3) Understandability "The primary goal of a programming language is accurate communication among humans." Readability more important than writeability. Well "punctuated" (easy to directly determine statement types and major subunits without intermediate inferences) Use of distinct structural words (keywords, reserved words) for distinct concepts (no overloading, e.g., = for equal, assignment) Avoidance of multiple use of symbols unless serve completely analogous functions (e.g., commas as separators, parentheses for grouping). Necessary to be able to see what is being accomplished at a higher level of abstraction. Permit programmers to state their "intentions" along with instructions necessary to carry them out.

Relationship between PL and Correctness (4) Maintainability Locality -- possible to isolate changes. Self-documenting Programming decisions should be recorded in program, independent of external documentation. Good comment convention, freedom to choose meaningful variable names, etc. User-defined types and named constants e.g., type direction=(north, south, east, west) Explicit interfaces Should cater to construction of hierarchies of modules

Relationship between PL and Correctness (5) Checkability Every error should transform a correct program into one whose errors are detectable by the system. All error detection based on redundancy (but some forms can cause errors). Examples of userful redundancy: type declarations and type checking declarative redundancy invariance conditions or assertions Run-time assertions, exception handling checking subscripts vs. array bounds case selector vs. case bounds

Relationship between PL and Correctness (6) General High-level languages take many decisions out of programmer s hands. One reason they are so fiercely resented by experienced programmers. Language should restrict programmer to decisions that really matter. Decisions should be recorded in program independent of external documentation. Simplicity of language less important than ability to write conceptually simple programs.

Can programming language influence correctness? Languages affect the way we think about problems: "The tools we use have a profound (and devious) influence on our thinking habits, and, therefore on our thinking abilities?" Additional experimental evidence: Dijkstra, 1982 C130J software written in a variety of languages by a variety of vendors. All certified to DO 178B standards (FAA). Then subjected to a major IV&V exercise by the MoD Significant, safety related errors found in Level A certified software Residual error rate of Ada code on aircraft was one tenth that of code written in C. Residual error rate of SPARK code (Ada subset) one tenth that of the Ada code.

Green: Design and Use of PLs Copyright c Nancy Leveson, Sept. 1999 "Clarifying the psychological processes of using programming languages will, I believe, clarify the requirements of language design and of environmental support." Some examples of structured programming hypotheses: Control structures should be hierarchical. Thus they should be nested, rather than allowed to have arbitrary branching. In this way, successive layers of detail can be added. The comprehensibility of hierarchically constructed programs will be easier, since they can be understoof by a reverse process -- understand the outer layer, then the inner layers, etc. These programs will be easy to modify because the inter-relations between parts will be simple. Have accepted these hypotheses but have never been validated.

Green: Program Comprehension Copyright c Nancy Leveson, Sept. 1999 Cites experiments ("atheoretical" ) that evaluate only current programming practice. More interesting question: Can we elucidate underlying psychological principles to allow generalization of results to other classes of information structure in programming? Hypothesis 1: If one language is better than another, it is always better, whatever the context. Hypothesis 2: Every notation highlights some type of information at the expense of others; the better notation for a given task is theone that highlights the information that given task needs. More generally, the comprehensibility of a notation may depend on the number and complexity of mental operations required to extract needed information.

Green: Program Comprehension (2) Copyright c Nancy Leveson, Sept. 1999 Cites results supporting second hypothesis better than first. Not predicted by arguments of structured programming, which are based solely on presence or absence of good structure. Programmers were not simply decoding programming structure top down into some undescribed mental representation. Were reworking one structure into another. Difficulty of answering questions depended not only on source structure but also on relation between source and target structures. Observes that result "appears to raise insuperable difficulties for those simple-minded computer scientists who attempt to measure psychological complexity of a program by means of a single number, such as McCabe."

Statement of Problem: Fry: everything that is juicy but not hard Boil: everything that is hard Chop and roast: everything that is neither hard nor juicy if hard go to L1 if hard then if hard: boil if juicy go to L2 begin boil end else begin if juicy then begin fry end chop roast stop L2: fry stop L1: boil stop else begin chop roast end end not hard: if juicy: fry not juicy: chop roast end juicy end hard Using Dijkstra s guarded command: if hard: boil if not hard, juicy: fry if not hard, not juicy: chop roast

Green: Program Creation Copyright c Nancy Leveson, Sept. 1999 Programs as plans. Role expressiveness: Outcome of a programmer s effort is a structure in which each part plays some role vis-a-vis the programmer s original intention. Easy program comprehension and creation requires role expressiveness. Rapid chunking into components Visible or easily inferred purposes for each part Visible or easily inferred relationships between each part and the larger structure. Important to alleviate mismatches between programmer s task and program structure. Hypothesis that role expressiveness tends to detract from reusability of program fragments. "When a program fragment makes its role and purpose very clear, it is probably not easy to transport it unchanged to a new environment, because its role may be slightly but significantly different.

Green: Program Creation (2) Copyright c Nancy Leveson, Sept. 1999 Linguistic consistency Metarules vs. BNF (simplified syntax rules) Not the number of rules that counts but the consistency between the form of the rules. Similar roles should be indicated by similar syntax: syntax should map roles consistently. Significant omissions (defaults) Perceptual cues Humans not good at discerning structure of a string of arbitrary symbols but good at differentiating shapes, spatial positions, and other perceptual cues. Dangling else: use of indentation the best solution Green asks: "Why did it take so long to find the solution?