Programming Languages

Slides:



Advertisements
Similar presentations
Type Systems and Object- Oriented Programming (III) John C. Mitchell Stanford University.
Advertisements

Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
8/25/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 1 Theory of Computation Course information Overview of the area Finite Automata Sofya.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
1 Module 9 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
CS 330 Programming Languages 09 / 07 / 2006 Instructor: Michael Eckmann.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Computability (Chapter 2) ICS 535 Design and Implementation.
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
A Quick Overview of Languages. FORTRAN Designed in 1955 First release of the compiler in 1957 Algebraic in nature Scientific (numeric not string oriented)
Abstract Data Types (ADT)
CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Slide 1 Vitaly Shmatikov CS 345 Programming Paradigms.
Data Structures and Programming.  John Edgar2.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
CS 331, Principles of Programming Languages Introduction.
1 Programming Languages Marjan Sirjani 2 1- The Study of Programming Languages The purpose of language is simply that it must convey meaning. (Confucius)
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Programming Languages and Design Lecture 1 Introduction to Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern University,
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
1 CSC 533: Organization of Programming Languages Spring 2010 See online syllabus at: Course goals:  understand issues in designing,
1 Programming Languages Marjan Sirjani Course web site:
1 Programming Language History and Evolution In Text: Chapter 2.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
INF 212 ANALYSIS OF PROG. LANGS LECTURE 1 Instructors: Crista Lopes Copyright © Instructors.
Chapter 3 - Language Design Principles
CS 331, Principles of Programming Languages Chapter 1.
Programming Languages John Mitchell CS 242 Course web site:
Engr. Isabelo Jun D. Paat, ME-CoE Lecturer 1 Programming Languages.
CSCD 330 Network Programming Winter 2015 Lecture 1 - Course Details.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Computable Functions John Mitchell CS 242 Reading: Chapter 2.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
Introduction to NP-Completeness Tahir Azim. The Downside of Computers Many problems can be solved in linear time or polynomial time But there are also.
A Short History of PL's (MacLennan 1999) “Zeroth Generation” (1940's-50's): machine language / assembly: if/then, read/write, store, goto
Programming Languages John Mitchell CS 242 Course web site:
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Programming Languages John Mitchell CS 242 Course web site:
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Functional Programming Lecture 1 - Introduction Professor Muffy Calder.
Programming Language History and Evolution
Programming Languages 2nd edition Tucker and Noonan
Programming Languages
CSC 222: Computer Programming II
INF 212 Analysis of Prog. Langs Final Lecture
Types for Programs and Proofs
Introduction to programming languages, Algorithms & flowcharts
Programming Language Design Concepts
Programming Language History and Evolution
Introduction to programming languages, Algorithms & flowcharts
Foundations of Programming Languages – Course Overview
Programming Languages
Programming Language Design
Organization of Programming Languages
Programming Languages 2nd edition Tucker and Noonan
CSE 341 Programming Languages Autumn 2001
CSE 341 Programming Languages Autumn 2003
Conference on the History of Programming Languages III
CSE 341 Programming Languages Autumn 2002
CSE 341 Programming Languages Spring 2003
Principles of Programming Languages
CSE 341 Programming Languages Autumn 2003
Programming Languages
Presentation transcript:

Programming Languages CS 242 Programming Languages John Mitchell Course web site: http://www.stanford.edu/class/cs242/

A little about myself … How I spend my time John C. Mitchell Professor of Computer Science Research Interests: Computer security: access control, cryptographic protocols and mobile code security. Programming languages, type systems, object systems, and formal methods. Applications of logic to CS. B.S. Stanford University; M.S., Ph.D. MIT.    How I spend my time Working with graduate students Writing papers, going to conferences, giving talks Departmental committees (hiring, curriculum, …) Teaching classes Conferences, journals, consulting, companies, …

Course Goals Programming Language Culture Critical thought A language is a “conceptual universe” (Perlis) Learn what is important about various languages Understand the ideas and programming methods Understand the languages you use (C, C++, Java) by comparison with other languages Appreciate history, diversity of ideas in programming Be prepared for new problem-solving paradigms Critical thought Properties of language, not documentation Language and implementation Every convenience has its cost Recognize the cost of presenting an abstract view of machine Understand trade-offs in programming language design

Transference of Lang. Concepts Parable I started programming in 1970’s Dominant language was Fortran; no recursive functions My algorithms and data structure instructor said: Recursion is a good idea even though inefficient You can use idea in Fortran by storing stack in array Today: recursive functions everywhere Moral World changes; useful to understand many ideas More current example: function passing Pass functions in C by building your own closures, as in STL “function objects”

Alternate Course Organizations Language-based organization Algol 60, Algol 68, Pascal Modula, Clu, Ada Additional languages grouped by paradigm Lisp/Scheme/ML for functional languages Prolog and Logic Programming C++, Smalltalk and OOP Concurrency via Ada rendez-vous My opinion: Algol/Pascal/Modula superseded by ML Lisp/Scheme ideas also in ML OOP deserves greater emphasis For comparison, see Sethi’s book ...

Alternate Course II Concept-based organization Advantages: Use single language like Lisp/Scheme Present PL concepts by showing how to define them Advantages: uniform syntax, easy to compare features Disadvantages Miss a lot of the culture associated with languages Some features hard to add Type systems, program-structuring mechanisms Works best for “local” features, not global structure Examples: Abelson/Sussman, Friedman et al.

Organization of this course Programming in the small Cover traditional Algol, Pascal constructs in ML Block structure, activation records Types and type systems, ... Lisp/Scheme concepts in ML too higher-order functions and closures, tail recursion exceptions, continuations Programming in the large Modularity and program structure Specific emphasis on OOP Smalltalk vs C++ vs Java Language design and implementation

Course Organization (cont’d) Concurrent and distributed programming General issues in concurrent programming Actor languages: an attempt at idealization Concurrent ML Java threads But what about C? Important, practical language We discuss other languages, you compare them to C in your head as we go (and in homework) Should we cover more? “Intro to C for Java programmers”? We do cover the ++ part of C++ in detail

Programming language toolsets C Other languages If all you have is a hammer, then everything looks like a nail.

Aside Current view from carpenters “A hammer is more than just a hammer. It's a personal tool that you get used to and you form a loyalty with. It becomes an extension of yourself." http://www.hammernet.com/romance.htm

General suggestions Read ahead Some details are only in HW and reading There is something difficult about this course May be hard to understand homework questions Thought questions: cannot run and debug May sound like there is no right answer, but some answers are better than others Many of you may be used to overlooking language problems, so it takes a few weeks to see the issues

Foundations: Partial,Total Functions Value of an expression may be undefined Undefined operation, e.g., division by zero 3/0 has no value implementation may halt with error condition Nontermination f(x) = if x=0 then 1 else f(x-2) this is a partial function: not defined on all arguments cannot be detected at compile-time; this is halting problem These two cases are “Mathematically” equivalent Operationally different

Partial and Total Functions f(x) g(x) x Total function: f(x) has a value for every x Partial function: g(x) does not have a value for every x

Functions and Graphs f(x) g(x) x Graph of f = { x,y | y = f(x) } Graph of g = { x,y | y = g(x) } Mathematics: a function is a set of ordered pairs (graph of function)

Partial and Total Functions Total function f:AB is a subset f  AB with For every xA, there is some yB with x,y  f (total) If x,y  f and x,z  f then y=z (single-valued) Partial function f:AB is a subset f  AB with If x,y  f and x,z  f then y=z (single-valued) Programs define partial functions for two reasons partial operations (like division) nontermination f(x) = if x=0 then 1 else f(x-2)

Halting Problem Entore Buggati: "I build cars to go, not to stop." Self-Portrait in the Green Buggati (1925) Tamara DeLempicka

Computability Definition Terminology Function f is computable if some program P computes it: For any input x, the computation P(x) halts with output f(x) Terminology Partial recursive functions = partial functions (int to int) that are computable

Halting function Decide whether program halts on input Given program P and input x to P, Halt (P,x) = Fact: There is no program for Halt yes if P(x) halts no otherwise Clarifications Assume program P requires one string input x Write P(x) for output of P when run in input x Program P is string input to Halt

Unsolvability of the halting problem Suppose P solves variant of halting problem On input Q, assume P(Q) = Build program D D(Q) = Does this make sense? What can D(D) do? If D(D) halts, then D(D) runs forever. If D(D) runs forever, then D(D) halts. CONTRADICTION: program P must not exist. yes if Q(Q) halts no otherwise run forever if Q(Q) halts halt if Q(Q) runs forever

Main points about computability Some functions are computable, some are not Halting problem Programming language implementation Can report error if program result is undefined due to division by zero, other undefined basic operation Cannot report error if program will not terminate

Announcements Topics you’d like to see? Homework grader? Send email to cs242@cs email addr (operational shortly) Something for fun Nominate theme song for each programming language or course topic Questions???