Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.

Slides:



Advertisements
Similar presentations
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Advertisements

Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Chapter One Preliminaries, including –Why study PL concepts? –Programming domains –PL evaluation criteria.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 1: Preliminaries
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
ISBN Chapter 1 Preliminaries. Copyright © 2007 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of.
CS 354 Overview. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Course Topics What is a programming language? What features do programming.
Programming Languages Structure
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Concepts of Programming Languages Chapter 1.
Chapter 1 Preliminaries. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of Programming Languages.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
CS 355 – Programming Languages
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Chapter 1. Introduction.
CS 363 Comparative Programming Languages
Chapter 1 Preliminaries CS Concepts of Programming Languages.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
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
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
ICS 313 Fundamentals of Programming Languages Instructor: Abdul Wahid Wali Lecturer, CSSE, UoH
Programming Languages Design Considerations (Qualities) Readability –Simplicity and Clarity –Orthogonality –Control Statements –Data Types and Structures.
ISBN CS 354 Preliminaries. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Course Topics What is a programming language? What features.
ISBN Chapter 1 Preliminaries. Copyright © 2015 Pearson. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of Programming.
ISBN Chapter 1 Preliminaries. Copyright © 2009 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Chapter 1. Introduction.
Programming Languages 2nd edition Tucker and Noonan
Concepts of Programming Languages
Chapter 1 Preliminaries.
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
PROGRAMMING LANGUAGES
1.1 Reasons to study concepts of PLs
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Introduction.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Programming Languages 2nd edition Tucker and Noonan
Chapter 1 Preliminaries.
Principles of Programming Languages
Chapter 1 Preliminaries.
Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Reasons To Study Programming Languages
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Chapter 1 Preliminaries.
Presentation transcript:

Overview

Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about programming. A. Perlis

Copyright © 2006 The McGraw-Hill Companies, Inc. 1.1 Principles 1.2 Paradigms 1.3 Special Topics 1.4 A Brief History 1.5 On Language Design Design Constraints Outcomes and Goals 1.6 Compilers, Interpreters, and Virtual Machines

Copyright © 2006 The McGraw-Hill Companies, Inc.  Programming languages have several properties, including ◦ Syntax ◦ Names & types ◦ Semantics  Language designers define these properties  Language users must understand them

Copyright © 2006 The McGraw-Hill Companies, Inc.  Syntax describes ◦ Legal statements ◦ Legal programs  Syntax defines the form of a correct program – doesn’t say anything about program meaning  Who needs to know PL syntax? ◦ Programmers: how to write a correct program ◦ Translators: how to recognize a correct program

Copyright © 2006 The McGraw-Hill Companies, Inc.  Various kinds of entities in a program have names: variables, functions, parameters, classes, objects, …  Named entities are bound in a running program to: ◦ Scope ◦ Visibility ◦ Type ◦ Lifetime

Copyright © 2006 The McGraw-Hill Companies, Inc. A type is a collection of values and a collection of operations on those values. ◦ Simple types: numbers, characters, booleans, … ◦ Structured types: Strings, lists, arrays, hash tables, … A language’s type system ◦ Defines legal operations ◦ Defines type errors

Copyright © 2006 The McGraw-Hill Companies, Inc. A program’s meaning is defined by its semantics. In studying semantics, we ask questions like: ◦ When a program is running, what happens to the values of the variables? ◦ What does each statement mean? ◦ What underlying model governs the run-time behavior of a function call? ◦ …

Copyright © 2006 The McGraw-Hill Companies, Inc.  A programming paradigm is a pattern or framework for problem-solving  Languages typically identify primarily with one paradigm, but may have aspects of several  Common paradigms can be grouped together according to whether they have imperative characteristics or declarative characteristics.

Copyright © 2006 The McGraw-Hill Companies, Inc.  Imperative languages: ◦ Pure Imperative (von Neumann languages); e.g., C, Pascal, early versions of Fortran & Ada, … ◦ Object-oriented; e.g., C++, Java, Smalltalk ◦ Most of what we’ll study focuses on these languages  Declarative languages ◦ Functional  Lisp, Scheme, ML, Haskell, … ◦ Logic  Prolog, SQL, …

Copyright © 2006 The McGraw-Hill Companies, Inc.  Follows the classic von Neumann-Eckert model of computation: ◦ Program and data are indistinguishable in memory ◦ Program = a sequence of commands ◦ Programs work by changing values of memory variables  Large programs use procedural abstraction as a way to organize individual imperative statements.

Copyright © 2006 The McGraw-Hill Companies, Inc.

 OO languages share many characteristics with the pure imperative languages  Programs consist of a collection of objects that communicate via “messages” that modify object state ◦ Messages are imperative  OO languages are characterized by ◦ Encapsulation ◦ Inheritance ◦ Polymorphism

Copyright © 2006 The McGraw-Hill Companies, Inc. Functional programming models a computation as a function that maps inputs to outputs. ◦ Input = domain ◦ Output = range Functional languages are characterized by: ◦ Functional composition ◦ Recursion Example functional languages: ◦ Lisp, Scheme, ML, Haskell, …

Copyright © 2006 The McGraw-Hill Companies, Inc. Logic programming declares what outcome the program should accomplish, rather than how it should be accomplished. Based on predicate logic Rule-based When studying logic programming we see: ◦ Programs as sets of constraints on a problem ◦ Find values that satisfy all constraints Example logic programming languages: Prolog

Copyright © 2006 The McGraw-Hill Companies, Inc.  Event handling ◦ E.g., GUIs, home security systems, monitoring systems of various kinds  Concurrency ◦ e.g., Client-server programs, rendering (in computer graphics)  Correctness ◦ Can we prove that a program does what it is supposed to do under all circumstances?

Copyright © 2006 The McGraw-Hill Companies, Inc.  How and when did programming languages evolve?  What communities have developed and used them? ◦ Artificial Intelligence ◦ Computer Science Education ◦ Science and Engineering ◦ Information Systems ◦ Systems and Networks ◦ World Wide Web

Copyright © 2006 The McGraw-Hill Companies, Inc.

1.5.1 – Design Constraints ◦ Computer architecture ◦ Technical setting (domain of applications) ◦ Standards ◦ Legacy systems

Copyright © 2006 The McGraw-Hill Companies, Inc. Key characteristics: ◦ Simplicity, readability and writability ◦ Clarity about binding ◦ Reliability ◦ Support ◦ Abstraction ◦ Orthogonality ◦ Efficient implementation

Copyright © 2006 The McGraw-Hill Companies, Inc.  Early languages focused on efficiency ◦ Time ◦ Space  Today, programs that are easy to read and easy to write are most likely to be successful  Promoted by simplicity of the language.

Copyright © 2006 The McGraw-Hill Companies, Inc.  Easy to learn ◦ Don’t include too many features ◦ Don’t make it too complex  Simple conceptual model of semantics.  Uniformity: Similar syntax => similar semantics.  Lexical and syntactic conventions: ◦ descriptive identifier names, blocking of compound statements

Copyright © 2006 The McGraw-Hill Companies, Inc.  A language element is bound to a property at the time that property is defined for it.  So a binding is the association between an object and a property of that object; the binding time should be clearly understood.  Examples: ◦ variable and type: program writing time or execution time? ◦ variable and value: program writing time and execution time ◦ language operator to machine language instruction: ??

Copyright © 2006 The McGraw-Hill Companies, Inc.  Major binding times ◦ Language definition time ◦ Language implementation time ◦ Program writing time ◦ Compile time ◦ Load time ◦ Execution time  In general, ◦ Early binding takes place at or before compile-time ◦ Late binding takes place at load time or run time  Early v late: efficiency versus flexibility

Copyright © 2006 The McGraw-Hill Companies, Inc. A language is reliable if: ◦ Program behavior is the same on different platforms  E.g., early versions of Fortran weren’t ◦ Type errors are detected  E.g., C vs Haskell or ML ◦ Good exception-handling facilities  E.g., C vs Java ◦ Memory leaks are prevented  E.g., C/C++ vs Java

Copyright © 2006 The McGraw-Hill Companies, Inc.  Good texts and tutorials  Wide community of users  Integrated with development environments (IDEs)  Accessible compiler/interpreters (public domain)

Copyright © 2006 The McGraw-Hill Companies, Inc.  Data ◦ Programmer-defined types/classes ◦ Class libraries  Procedural ◦ Programmer-defined functions ◦ Standard function libraries  Supports code reuse; simplifies the programming process.

Copyright © 2006 The McGraw-Hill Companies, Inc.  A language is orthogonal if it is built on a small, mutually independent set of primitive operations. ◦ You can use one feature without worrying about how it affects others ◦ Rules don’t have exceptions; ◦ Context doesn’t affect the behavior of a language feature (e.g., a reserved word doesn’t have different meanings based on where it’s used). ◦ Things that are syntactically similar have similar meaning.

Copyright © 2006 The McGraw-Hill Companies, Inc.  Rule exceptions: ◦ C functions can return a struct, but not an array. Orthogonality => return value can be any type.  Syntactic exceptions ◦ In Fortran, an identifier can indicate the type of the variable; this could be considered non-orthogonal  If A = B; and A = (B); acceptable, should (A) = B; be allowed?

Copyright © 2006 The McGraw-Hill Companies, Inc.  Embedded systems ◦ Real-time responsiveness (e.g., navigation) ◦ Failures of early Ada implementations – real time?  Corporate database applications ◦ Efficient search and updating  Ability to implement the language efficiently ◦ Characteristics of Lisp didn’t match the architectures of early computers ◦ Characteristics of Algol made it difficult to build efficient translators.

Copyright © 2006 The McGraw-Hill Companies, Inc. Compiler – produces machine code Interpreter – executes instructions directly  Example compiled languages: ◦ Fortran, Cobol, C, C++  Example interpreted languages: ◦ Scheme, Haskell, Python  Hybrid compilation/interpretation: Java ◦ The Java Virtual Machine (JVM)  Just-in-time (JIT) compilation: C#, some Java ◦ Compiled to intermediate code, machine code produced just before execution

Copyright © 2006 The McGraw-Hill Companies, Inc. Translation/Execution – Compiler se

Copyright © 2006 The McGraw-Hill Companies, Inc.  Translate source code program into object code (machine language).  Object code is linked to libraries, other modules, to generate an executable object code module  Object code can be executed repeatedly without repeating the compilation process.

Copyright © 2006 The McGraw-Hill Companies, Inc. Translation/Execution – Interpreter

Copyright © 2006 The McGraw-Hill Companies, Inc.  No object code file generated.  Interpretive routines ◦ Examine the program. When an action is recognized, do it (by calling one of the routines).  Slower execution (than with compilation): lexical, syntax, type/semantic analysis must be performed every time it runs  Better interactive development environment.

Copyright © 2006 The McGraw-Hill Companies, Inc.  Some languages (e.g., Java) are compiled to a machine code (byte code) that runs on a virtual machine (the JVM).  To run Java programs install a JVM for your machine that interprets the byte code.  Benefit: “compile once, run anywhere” – as long as “anywhere” has a JVM. Compiled languages need to be compiled for a specific platform  Disdadvantage: slow  Solution: JIT compilers

Copyright © 2006 The McGraw-Hill Companies, Inc.  Programming language principles ◦ Grammars, syntax, semantics  What makes a language successful?  Reliable, readable, writeable  Supported by simplicity, orthogonality, efficiency, support, …  Paradigms ◦ Imperative, object-oriented, functional, logic  Language implementation ◦ Compilers & interpreters & hybrid systems