Safety as a Software Metric Matthias Felleisen and Robert Corky Cartwright Rice University.

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
CS 355 – Programming Languages
1 8. Safe Query Languages Safe program – its semantics can be at least partially computed on any valid database input. Safety is tied to program verification,
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
SchemeCOP Introduction to Scheme. SchemeCOP Scheme Meta-language for coding interpreters –“ clean ” semantics Scheme = LISP + ALGOL –simple.
Building “Real World” Software in Academia Matthias Felleisen PLT, Rice University.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Programming Language Concepts
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Language Evaluation Criteria
1 EECS 231 ADVANCED PROGRAMMING. 2 Staff Instructor Vana Doufexi Ford Building, 2133 Sheridan, #2-229 Teaching Assistant.
High-Level Programming Languages: C++
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
MrFlow: Why MrSpidey Failed Philippe Meunier Paul Steckler.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Chapter 1. Introduction.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
4 Dec 2001Kestrel1 From Patterns to Programming Languages Matthias Felleisen Northeastern University.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
CSE 341 Programming Languages Racket Datatype Style Programming Zach Tatlock Spring 2014.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
Programming Languages
1-1 An Introduction to Functional Programming Sept
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
1 CS 211 Computer Programming II. 2 Staff Instructor Vana Doufexi Ford Building, 2133 Sheridan, #2-229 Teaching Assistant.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
C H A P T E R T H R E E Type Systems and Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Copyright © 2009 Elsevier Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
Chapter 1. Introduction.
Functional Programming
Types for Programs and Proofs
课程名 编译原理 Compiling Techniques
Introduction to programming languages, Algorithms & flowcharts
Chap. 6 :: Control Flow Michael L. Scott.
Control Flow.
CSE401 Introduction to Compiler Construction
FP Foundations, Scheme In Text: Chapter 14.
Midterm Review In Text: Chapters 1-3, 5-9, 15.
Chap. 6 :: Control Flow Michael L. Scott.
Organization of Programming Languages
CSCE 314: Programming Languages Dr. Dylan Shell
Midterm Review In Text: Chapters 1-3, 5-9, 15.
Programming Languages, Preliminaries, History & Evolution
Presentation transcript:

Safety as a Software Metric Matthias Felleisen and Robert Corky Cartwright Rice University

Why Safety as a Metric? Measuring Software: Syntax versus Semantics What is Programming Language Safety ? What Makes an Individual Program Safe ? How about Teaching Program Safety?

Why Measure Software? correct and efficient software maintainable software extensible software

What do Metrics Measure? lines of code number of procedures, gotos, loops, modules, statements versus expressions, … in short: Syntactic Attributes of software

What should Metrics Measure? correctness extensibility maintainability in short: semantic and organizational attributes

Measuring Correctness is Difficult … goal: measure certain aspects of correctness specifically: assume the programming language is safe, what kind of problems can we predict?

Safe Programming Languages

Safety -- A High-Level View (1) “Close the valve by 10 degrees!” “Turned the valve by 10 degrees!”

Safety -- A High-Level View (2) “Close the valve by 10 degrees!” “Turned the valve by 15 degrees!”

Safety -- A High-Level View (3) “Close the valve by 10 degrees!” “OUCH!”

Safety -- A High-Level View (4)

Safety -- A High-Level View (5) ERROR!

C and C++ are NOT Safe! int f(int n, int m) { int r = n % m; if (0 == r) return m; else return f(m,r); } main() { char a = 'a'; char b = 'b'; int mn[2] = {24,6}; char c = 'c'; char d = 'd'; printf("%d\n",f(mn[0],mn[1])); printf("%d\n",f(mn[0],c)); printf("%d\n",f(mn[0],mn[2])); }

Safety in Programming Languages a safe language protects every computational primitive, e.g., +, *, if, vector-lookup, record dereference, … protection is implemented with a mixture of compile- time and run-time checks safety guarantees errors are caught safety greatly increases effectiveness of debugging

Safety … is NOT just TYPE checking!

Examples Fortran C C++ Perl ML Eiffel Java Scheme (untyped, but safe) UNSAFE Languages SAFE Languages

Safe Programs and Measuring Safety

Measuring the Safety of Programs programs in safe languages signal errors programs should not signal errors determine whether any computational primitive might signal an error make programmers explain potential faults

MrSpidey: Measuring the Safety of Scheme Programs Scheme is a dialect of Algol and LISP lexical scope, first-class functions (“mini-objects”) LISP’s syntax (parentheses) and primitives (cons, car, and cdr)

some function call, somewhere in the program

SYMBOLS are bad for +

general input shapes

Measuring Safety is More than Checking Types check general “data shapes” lists with at least N items vector references …

list with at least one NUMBER

NIL is not okay

An Elaborate Example from the Scheme Front-end S-expression (let ( ) ) (( lambda ( ) ) )

weak invariant … yields many checks

stronger invariant yields stronger results

Teaching with Safety Metrics

Program Construction: Rice University, Fall 1998 course on program safety understanding measuring based on Scheme and Java

On Safety of Languages and Programs programming language safety program safety theory and tools for “measuring” program safety –logics that conservatively approximate semantics –logics that extend the logic of type checking

The Pragmatics of MrSpidey using MrSpidey: –checking –understanding potential fault sites: data set data flow –is it a problem with the program? –is it a problem with the theory/tool? –if the latter, can a re-organization help?

Hands-on Work homework assignments –sets of problems for each bullet –increasing complexity –theory and practice project: implement sequential subset of Java –modules and data invariants that cross boundaries –exploring large pieces of code

Evaluation (1) course evaluation: excellent targeted questions: –understanding of language safety –understanding of program safety –understanding of measuring safety with theorem provers –effectiveness of homeworks versus project

Evaluation (2) Positives: –appreciate safety –appreciate tools –appreciate theory –understand the above based on homework Negatives –project too large

Summary new, semantics-based thinking about “metrics” extensions: measuring stronger invariants (numeric constraints, polyvariant); measuring organization (patterns?) teaching: a good approach to have students understand partial correctness

Thank You Matthew Flatt Shriram Krishnamurthi Robby Findler Mike Fagan (92) Andrew Wright (94) Cormac Flanagan (96)