Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Names and Bindings.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Chapter Four Data Types Pratt 2 Data Objects A run-time grouping of one or more pieces of data in a virtual machine a container for data it can be –system.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Type Checking Strong Typing Type Compatibility.
High-Level Programming Languages
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Chapter 10 Storage Management Implementation details beyond programmer’s control Storage/CPU time trade-off Binding times to storage.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 9: Subprogram Control
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Computer Science 101 Introduction to Programming.
Computer Architecture and Organization
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
CS 355 – Programming Languages
High-Level Programming Languages: C++
CS 403: Programming Languages Lecture 2 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Chapter 1. Introduction.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Computer Science 101 Introduction to Programming.
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.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Basic Semantics Associating meaning with language entities.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Variables reference, coding, visibility. Rules for making names  permitted character set  maximum length, significant length  case sensitivity  special.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
1 Overview of Programming Principles of Computers.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Constructs for Data Organization and Program Control, Scope, Binding, and Parameter Passing. Expression Evaluation.
Names, Scope, and Bindings Programming Languages and Paradigms.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Hello world !!! ASCII representation of hello.c.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
Operating Systems A Biswas, Dept. of Information Technology.
Software Engineering Algorithms, Compilers, & Lifecycle.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Computer Organization and Architecture Lecture 1 : Introduction
Languages and Compilers (SProg og Oversættere)
Chapter 1 Introduction.
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Ch. 7 Programming Languages
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
High Level Programming Languages
Low Level Programming Languages
Principles of Programming Languages
Names and Binding In Text: Chapter 5.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
point when a program element is bound to a characteristic or property
Presentation transcript:

Programming Languages Marjan Sirjani

2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages Data typing features in ML Class of C++ Package of Ada

3 Major influences on designing a language The underlying computer which programs execute upon; The execution model, or virtual computer that supports the language on the actual hardware; The computational model that the language implements.

The Structure And Operation Of A Computer A computer is an integrated set of algorithms and data structures capable of storing and executing programs. Hardware computer or virtual computer

5 Major Components of a Computer (From a Programming Language Designers View) Data Various kinds of elementary and structured data. Primitive operations Sequence control Controlling the sequence of primitive operations execution.

6 Major Components of a Computer (From a Programming Language Designers View) Data access Controlling the data supplied to each execution of an operation. Storage management Controlling the allocation of storage for programs and data. Operating environment Providing mechanisms for communication with an external environment containing programs and data.

7 Data Main memory High-speed register High-speed cache memory External files Data and Program

8 operations A set of build-in primitive operations Arithmetic operations on each built-in numeric data (+,-,*,/) Testing various properties of data items (test for zero, positive, and negative numbers) Accessing and modifying various parts of a data item Controlling input-output devices Sequence control (jumps)

9 Sequence Control There is an interpreter : Fetch the instruction Decode instruction Fetch designated operands Branch to designated operation Execute primitive operations 1 to n Using an address register

10 Data Access Access to operands of the operation

11 Storage Management Keeping all resources of the computer operating as much as possible Memory Central processor External data devices Multiprogramming Cache memory

12 Operating Environment The outside world of computer; a set of peripherals and input-output devices

13 Computer States We saw the static organization of the computer, We also must see the dynamic operation of it during program execution.

14 Language Implementation Translation (compilation) Accept programs in some source language as input and produce functionally equivalent programs in another object language as output.  Assembler : assembly to machine language.  Compiler : a high level language to assembly or machine code.  Loader,linker editor : machine code in relocatable form to machine code really executable.  Preprocessor : a high level language to a high level language in a standard form.

15 Language Implementation Software simulation (interpretation) the simulator executes the input program directly.

16 Differences Between Software Implementations Translation versus Interpretation Physical input sequence – Logical flow of control Process each program statement exactly once – might process some statements repeatedly

17 Differences Between Software Implementations Faster program execution – slow program execution Loss of information about program – leaving statements in their original form Object program much larger then the source program – no space is needed for object program

18 Firmware Computers A common alternative to the strict hardware realization of a computer is the firmware computer, simulated by a micro-program running on a special micro- programmable hardware computer. (emulation)

Virtual Computers Hardware realization Physical devices Firmware realization microprogramming Software simulation Some other programming language Combination of these techniques

20 Syntax and Semantics Syntax: what the program looks like. Semantics: the meaning given to the various syntactic constructs. Example: V: array [0..9] of integer; int V[10];

21 Hierarchies of Computers Virtual computer developed by programmer The language virtual computer Operating system virtual computer Firmware virtual computer Actual hardware computer

22 Binding and Binding Times Binding of a program element to a particular characteristic or property : the choice of the property from a set of possible properties. Binding time of the property for that element: the time during program formulation or processing when this choice is made.

23 Examples Of Binding Setting the value of an attribute A variable: name, type, storage area A routine: name formal parameters of a certain type, certain parameter-passing conventions, A statement: associated actions.

24 Classes of Binding Times 1. Execution time (run time) (dynamic binding) 2. Translation time (compile time) 3. Language implementation time 4. Language definition time

25 1. Execution time : On entry to subprogram or block. Binding of formal to actual parameters in C. At arbitrary points during execution. Binding of variables to values by assignments. (can be modified repeatedly during execution)

26 2. Translation time (compile time) Bindings chosen by the programmer Variable names and types Bindings chosen by the translator Relative locations of a data object in the storage allocated for a procedure Bindings chosen by the loader Actual addresses

27 3. Language implementation time The details associated with the representation of numbers and of arithmetic operations. (integer type memory representation) 4. Language definition time Possible statement forms, data structure types, program structures. (integer type definition)

28 Programming languages differ in The number of entities with which they can deal, The number of attributes to be bound to attributes, The time at which such bindings occur (binding time), The stability of the binding (fixed or modifiable)

29 Importance of Binding Times Many of the most important differences among languages involve differences in binding times. Early binding : efficiency. (FORTRAN types, arithmetic operations) Late binding : flexibility. (ML types, string manipulations)

30 Binding Time: An Example X := X + 10 Set of possible types for variable X. Type of variable X. Set of possible values for variable X. Value of the variable. Representation of the constant 10. Properties of the operator +.

31 Attributes of a variable: Name Scope Type L-value R-value

32 Name and Scope Static scope binding: defines the scope in terms of the lexical structure of a program. (C, Pascal) Dynamic scope binding: defines the scope of a variable’s name in term of program execution. (same dcl until new dcl) (APL, LISP, SNOBOL)

33 Name and Scope (dynamic binding) { /* block A*/ int x; … } { /* block B*/ int x; … } { /* block C*/ … x:= …; … }

34 Type Static typing: bind variables to their type at compile time, and the binding can not be changed during execution. Static type checking Dynamic typing: run-time binding between variables and their types. (according to the value assigned)

Language Paradigms How does the program execute? What sort of constructs does the language provide?

36 Four basic computational models: Imperative languages Applicative language Rule-based language Object-oriented programming

37 Imperative Languages Imperative or procedural languages are command-driven or statement-oriented languages. Basic concept : machine state. The syntax has the form like: statement1; statement2; …

38 Applicative Languages Applicative or functional languages look at the function that program represents rather than just to the state changes as the program executes, statement by statement. The syntax has the form like: function n (…function 2 (function 1 (data))…)

39 Rule-based Languages Rule-based or logical languages execute by checking for the presence of a certain condition and when it is satisfied, they execute an appropriate action. The syntax has the form like: enabling condition 1 action 1 enabling condition 2 action 2 … enabling condition n action n

40 Object-Oriented Languages Object-oriented languages can be viewed as combining imperative and functional paradigms. Abstract data types inheritance  efficiency of imperative languages  flexibility and reliability of functional languages.

41 Generality of Computational Model How one uses a programming language depends on the programmer.