Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Similar documents
Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

CS 3304 Comparative Languages. Lecture 1: Introduction

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Programming Languages

Why are there so many programming languages?

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Concepts in Programming Languages

Introduction to Programming Languages. CSE 307 Principles of Programming Languages Stony Brook University

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

Principles of Programming Languages. Lecture Outline

Chapter 1. Preliminaries

Chapter 1. Preliminaries

Chapter 1 Preliminaries

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

CSCI 3136 Principles of Programming Languages

Programming Languages, Summary CSC419; Odelia Schwartz

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

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Concepts of Programming Languages

NOTE: Answer ANY FOUR of the following 6 sections:

Why study Programming Language Concepts? Chapter One. Language Evaluation Criteria. Programming Domains. Readability Writability Reliability Cost

Introduction. A. Bellaachia Page: 1

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

Types. What is a type?

Programming Languages 2nd edition Tucker and Noonan"

What is a programming language?

Programming Paradigms

Logic Programming II & Revision

CS508-Modern Programming Solved MCQ(S) From Midterm Papers (1 TO 22 Lectures) BY Arslan

22c:111 Programming Language Concepts. Fall Types I

Chapter 11 :: Functional Languages

COSC 2P90 Programming Languages & Object-Orientation

Control Flow February 9, Lecture 7

Com S 541. Programming Languages I

INSTITUTE OF AERONAUTICAL ENGINEERING

Chapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes

LECTURE 1. Overview and History

Programmiersprachen (Programming Languages)

Chapter 6 Control Flow. June 9, 2015

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

! Broaden your language horizons. ! Study how languages are implemented. ! Study how languages are described / specified

Chapter 5 Names, Binding, Type Checking and Scopes

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

Chapter 3:: Names, Scopes, and Bindings (cont.)

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Imperative Programming

Thanks! Review. Course Goals. General Themes in this Course. There are many programming languages. Teaching Assistants. John Mitchell.

Programming Language Pragmatics

CSc 372 Comparative Programming Languages

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 3:: Names, Scopes, and Bindings (cont.)

Low-Level Languages. Computer Programs and Programming Languages

G Programming Languages - Fall 2012

Course outline. CSE 341: Programming Languages. Why study programming languages? Course motivation and objectives. 1 lecture: Concepts

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

Concepts of Programming Languages

Chapter 5. Names, Bindings, and Scopes

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011

Page # Expression Evaluation: Outline. CSCI: 4500/6500 Programming Languages. Expression Evaluation: Precedence

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Informatica 3 Syntax and Semantics

CS Exam #1-100 points Spring 2011

Compilation I. Hwansoo Han

LECTURE 18. Control Flow

MIDTERM EXAMINATION - CS130 - Spring 2005

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

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

Programming Languages

Chapter 8 :: Composite Types

Language Evaluation P L COS 301. Fall School of Computing and Information Science University of Maine. Language Evaluation COS 301.

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Chapter 5. Variables. Topics. Imperative Paradigm. Von Neumann Architecture

A Tour of Language Implementation


Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Discovering Computers 2008

Programming Languages Third Edition. Chapter 7 Basic Semantics

Types and Type Inference

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

Types and Type Inference

CSC 533: Organization of Programming Languages. Spring 2005

Example: Haskell algebraic data types (1)

CS 113: Introduction to

Principles in Programming: Orientation & Lecture 1. SWE2004: Principles in Programming Spring 2014 Euiseong Seo

CS558 Programming Languages

Introduction to Engineering Using Robotics Experiments. Dr. Yinong Chen

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

2/20/2018. Chapter 6:: Control Flow. control flow or ordering. basic categories for control flow (cont.): basic categories for control flow:

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

Data Types (cont.) Administrative Issues. Academic Dishonesty. How do we detect plagiarism? Strongly Typed Languages. Type System

Introduction to Computer Science I

CSCI312 Principles of Programming Languages!

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

CS 415 Midterm Exam Spring 2002

Haskell Review COMP360

LECTURE 3. Compiler Phases

CMSC 331 Final Exam Section 0201 December 18, 2000

CS 314 Principles of Programming Languages

CS383 PROGRAMMING LANGUAGES. Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

Transcription:

Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic factors: Proprietary interests, Commercial advantage orientation toward special purposes Orientation toward special hardware Diverse ideas about what is pleasant to use 2 What makes a language successful? Ease of use: Easy to learn (BASIC, Pascal, LOGO, Scheme) Easy to express things Easy to use once fluent -- "powerful" (C++, Common Lisp, APL, Algol-68, perl) Easy to implement (BASIC, Forth) possible to compile to very good (fast/small) code (ForTran) Cost factors: Backing of a powerful sponsor (COBOL, PL/1, Ada, Visual Basic) Wide dissemination at minimal cost (Pascal, Turing, Java) 3 1

Why do we have programming languages? Programmer s perspective: way of thinking way of expressing algorithms languages from the user's point of view Abstraction of virtual machine way of specifying what you want the hardware to do without getting down into the bits languages from the implementor's point of view Course Objective: balance coverage of two angles. Commonalities and differences among languages Implementations of languages 4 History of Programming Languages http://www.webopedia.com/term/p/programming_language.html 5 Major Influences to Programming Languages Computer Architecture Von Neumann Architecture Programming methodologies Programming paradigms 6 2

Von Neumann Architecture 7 Influence of Computer Architecture Computer Architecture Memory cells? Programming Language Variables Pipelined execution of instructions? Computation is viewed as a sequence of actions 8 Programming Paradigms Imperative Procedural (von Neumann) Object-Oriented Declarative Functional Logical ForTran, C, Basic, Pascal, Algol60 Simula67, C++, Smalltalk, Java, C# LISP, Scheme, ML, Haskell Prolog, VisiCalc, RPG, spreadsheets 9 3

Desirable Qualities of Software 1. Software must be reliable Program performs to its specification under all conditions 2. Software must be maintainable It is no longer feasible to always build software from scratch Must be able to easily modify existing software 3. Software must execute efficiently Although hardware getting cheaper and has better performance, need for efficient execution remains due to increasingly demanding applications 10 Why study programming languages? Help you choose a language. C v Modula-3 v C++ for systems programming Fortran v APL v Ada for numerical computations C v Ada vs Modula-2 for embedded systems Common Lisp v Scheme v ML for symbolic data manipulation Java v. C/CORBA for networked PC programs 11 Why study programming languages? Make it easier to learn new languages (by analogy) some languages are similar; easy to walk down family tree (e.g., ForTran 77, ForTran90) Identify common concepts : E.g.: iteration, recursion, abstraction Think of an analogy to human languages: good grasp of grammar makes it easier to pick up new languages (at least romance languages). 12 4

Make better use of language Understand obscure features: In C, help you understand unions, arrays & pointers, separate compilation, varargs, In Common Lisp, help you understand first-class functions/closures, streams, catch and throw, symbol internals 13 Make better use of language Understand implementation costs: choose between alternative ways of doing things, based on knowledge of what will be done underneath: Use simple arithmetic equalities (use x*x instead of x**2) Use C pointers or Pascal "with" statement to factor address calculations avoid call by value with large data items in Pascal avoid the use of call by name in Algol 60 choose between computation and table lookup 14 Make better use of given language Figure out how to do things in languages that don't support them explicitly: Lack of suitable control structures in Fortran IV use comments and programmer discipline for control structures Lack of recursion in Fortran 77, CSP, etc. write a recursive algorithm then use mechanical recursion elimination (even for things that aren't quite tail recursive) lack of named constants and enumerations in Fortran use variables that are initialized once, then never changed lack of modules in C and Pascal use comments and programmer discipline lack of iterators in just about everything fake them with (member?) functions 15 5

Language Design Criteria Simplicity Simpler language is easier to master Achieved by having a small number of features Feature multiplicity: more than one way to accomplish the same task E.g.: count++; count = count + 1; count += 1 Operator overloading: same operator has more than one meaning Overload + operator for Summing integers in two arrays Concatenating two arrays 16 Language Design Criteria Orthogonality Every possible combination of primitive constructs of the language is legal and meaningful Lack of orthogonality means lots of exceptions in the language rules Assembly language for IBM mainframe: A Reg1, memory cell Two different rules for addition AR Reg1, Reg2 Cannot use A for adding 2 registers Too much orthogonality makes language becomes overly complex (Algol 68) 17 Language Design Criteria-Syntax Identifier forms Fortran77 restricts identifiers to =6 characters Special words Pascal requires begin-end pairs to form groups for all control constructs Ada uses end if or end loop to distinguish closing syntax for each type of control statement Fortran 90 allows special words such as DO and END to be legal variable names 18 6

Language Design Criteria Safety Language should not provide features that make it possible to write harmful programs E.g., goto statements and pointer variables Type checking testing for type errors in a given program, during compilation or program execution Aliasing Having two or more distinct referencing methods, or names, for the same memory cell (e.g., union members and pointers in C) Robustness Provides the ability to deal with undesired events (arithmetic overflows, invalid input, etc) E.g., Exception handling facility in Java and C++ 19 Language Design Criteria Portability: Programs can be compiled and run on different machines without rewriting the source code Uniformity: Similar notations should look and behave in the same way (e.g., every end must be preceded by a matching begin ) Support for abstraction Ability to define and then use complicated structures or operations in ways that allow many details to be ignored Process abstraction vs Data abstraction 20 Design Trade-offs Reliability vs Efficiency Ada demands all references to array to be checked to ensure that indices are within their legal ranges C does not require index range checking, and thus executes faster Buffer overflow problem void function (char *str) { char buffer[16]; strcpy (buffer, str); } int main () { char *str = "I am greater than 16 bytes"; function (str); } 21 7

Design Trade-offs Flexibility vs Safety Pascal variant records allow a memory cell to contain either a pointer or an integer This allows a program to do arithmetic on pointers, which is sometimes convenient, but is a dangerous practice. 22 Course Organization Lectures material supplement textbook material (i.e., come to class) Homework assignments reinforce key concepts Programming assignments give hands-on experience Exams provide a way for you to demonstrate what you ve learned (and I need something to use for calculating grades) 23 Course Organization Homework Programming Assignments Exams (2) Exam 1: 10/14/04 Exam 2: 12/17/04 15% 30% 50% In-class participation 5% 24 8

Course Textbook Best programming language textbook (based on student and faculty reviews) 2nd edition due out in 2005 MSU participate in evaluation of draft of 2 nd edition (Programming Language Pragmatics, M. Scott) Cheap textbook (Purchase course pack at Anthony Hall copy center) Perform evaluations of each chapter (part of in-class participation grade) 25 9