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

Similar documents
Chapter 1. Preliminaries

Chapter 1 Preliminaries

Chapter 1. Preliminaries

Concepts of Programming Languages

Principles of Programming Languages. Lecture Outline

Concepts of Programming Languages

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

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

Programming Languages, Introduction CSC419; Odelia Schwartz

Programming Languages, Summary CSC419; Odelia Schwartz

What is a programming language?

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

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Design & Implementation Overview

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

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

Introduction. A. Bellaachia Page: 1

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

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

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

Compilation I. Hwansoo Han

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Programming Languages 2nd edition Tucker and Noonan"

Chapter 5. Names, Bindings, and Scopes

Chapter 2 Preview. Preview. History of Programming Languages. History of Programming Languages. History of Programming Languages

8/23/18. Programming Language Genealogy The Evolution of Programming Languages. Zuse s Plankalkül. Plankalkül Syntax. Machine Code

Why are there so many programming languages?

Programming Languages

Programmiersprachen (Programming Languages)

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Chapter 2. Evolution of the Major Programming Languages

The Stored Program Computer

Low-Level Languages. Computer Programs and Programming Languages

Crafting a Compiler with C (II) Compiler V. S. Interpreter

CHAPTER 1 Introduction to Computers and Java

Language Translation, History. CS152. Chris Pollett. Sep. 3, 2008.

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

Introduction to Java Programming

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Introduction to Programming

AS/A Level Computing Syllabus 2011

An Introduction to Software Engineering. David Greenstein Monta Vista High School

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Why learn Computer Programming? Computer-based problem solving in Science and Engineering. Why learn Fortran? Elementary Computer Organization

CST-402(T): Language Processors

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

CS 3304 Comparative Languages. Lecture 1: Introduction

Evolution of the Major Programming Languages

Introduction to Engineering Using Robotics Experiments. Dr. Yinong Chen

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

Chapter 2. Pseudocodes: Speedcoding. 2.2 Minimal Hardware Programming: Pseudocodes. Evolution of the Major Programming Languages

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

Chapter 11 Program Development and Programming Languages

Chapter 2. Evolution of the Major Programming Languages ISBN

Introduction. Compilers and Interpreters

Programming Paradigms

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

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

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

Memory General R0 Registers R1 R2. Input Register 1. Input Register 2. Program Counter. Instruction Register

Discovering Computers 2008

History of Compilers The term

Concepts in Programming Languages

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

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

Chapter 1: Introduction to Computers and Programming

PLAGIARISM. Administrivia. Course home page: Introduction to Programming Languages and Compilers

Introduction to Programming Languages and Compilers. CS164 11:00-12:00 MWF 306 Soda

Com S 541. Programming Languages I

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

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

1DL321: Kompilatorteknik I (Compiler Design 1)

2c. Content of Computer systems (Component 01)

Chapter 2 Evolution of the Major Programming Languages Chapter 2 Topics

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

Högnivåspråk och översättning

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

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

Working of the Compilers

Compilers. Prerequisites

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

Computer Software: Introduction

Chapter 2. Evolution of the Major Programming Languages

Objective: To learn meaning and concepts of programming. Outcome: By the end of this students should be able to describe the meaning of programming

1. Fundamental Concepts

Imperative Programming

CS 3360 Design and Implementation of Programming Languages. Exam 1

Discovering Computers Chapter 13 Programming Languages and Program Development

COMPUTER SYSTEM. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U

Software II: Principles of Programming Languages. Why Expressions?

CS321 Languages and Compiler Design I. Winter 2012 Lecture 1

Chapter 7. Expressions and Assignment Statements ISBN

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

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

CS 242. Fundamentals. Reading: See last slide

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Transcription:

Chapter 1. Preview Reason for Studying OPL Reason for Studying OPL? Programming Domains Language Evaluation Criteria Language Categories Language Design Trade-Offs Implementation Methods Programming Environments Increased ability to express ideas Improved background for choosing appropriate languages Increased ability to learn new languages Better understanding of significance of implementation Better use of languages that are already known Overall advancement of computing 1 2 Programming Domains Scientific applications Large numbers of floating point computations; use of arrays Ex) Fortran Business applications Produce reports, use decimal numbers and characters Ex) COBOL Artificial intelligence Symbols rather than numbers manipulated; use of linked lists Ex) LISP, Prolog (logic programming) Systems programming Need efficiency because of continuous use Ex) C Web Software Eclectic collection of languages: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) 3 Language Evaluation Criteria Readability: once a software was written by a programmer, it must be easy to read and understand by others for maintenance. Writability: How easily a language can be used to create a program for a selected problem. (simple syntax, data abstraction support, Reliability: performs to its specification under all conditions (i.e., type checking, Exceptional handling, Aliasing, ) Cost: training programmers, writing a program, compiling a programs, execution programs, the language implementation system, maintain Portability: Need standardization of language 4 Computer Architecture Languages are developed around the prevalent computer architecture, known as the Von Neumann architecture. These Languages are called imperative languages (PASCAL, C, ) Program Design Methodologies New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages (Computer Architecture: Von Newmann) ALU Control Unit CPU R 1 R 2 R 3 I PC Registers Result of operations Instructions & Data Input / Output Devices Output RAM Input 5 6 1

(Computer Architecture: Von Newmann) Imperative languages, most dominant, because of von Neumann computers architecture Data and programs stored in memory Memory is separate from CPU Instructions and data are piped from memory to CPU. The calculation result must back to RAM Basis for imperative languages Variables model memory cells Assignment statements model piping Iteration is efficient The execution of a code on a von Neumann architecture computer occurs in a process called the instruction cycle (fetch-execute cycle). 7 (Von Newmann : Instruction Cycle) The microprocessor s (CPU) main task is to execute instructions. The instruction cycle is therefore at the heart of understanding the function and operation of the microprocessor. Fetch Cycle Instruction Cycle Execute Cycle 8 (Von Newmann : Instruction Cycle) (Von Newmann : Instruction Cycle: Fetch Cycle) initialize the program counter repeat forever fetch the instruction pointed by the counter increment the counter decode the instruction execute the instruction end repeat Fetch cycle 1. Reading the address of the instruction in (PC) to be executed from the memory and 2. Loading it into the Instruction register (IR). 3. Program Counter register (PC) is modified to point at the next valid instruction. 9 10 (Von Newmann : Instruction Cycle: Fetch Cycle) (7) PC=PC+1 PC (1) 0020 0020 IR Load Accumulator with M(A) (6) MAR MDR Load Accumulator with M(A) (2) (5) Address Bus 0020 Data Bus Load Accumulator with M(A) (3) 0020 (4) Load Accumulator with M(A) (Von Newmann : Instruction Cycle: Execute Cycle) Execute cycle The contents of the IR are decoded and executed. The execution may result in a variety of actions depending on the type of instruction. It may be a self contained instruction, or it can involve interaction with memory and ALU. 11 12 2

(Programming Methodologies) 1950s and early 1960s: Simple applications; main consideration was machine efficiency Late 1960s: People efficiency became important; readability, better control structures change in the major cost of computing from hardware to software. structured programming top-down design and step-wise refinement Late 1970s: Process-oriented to data-oriented data abstraction Middle 1980s: Object-oriented programming Data abstraction + inheritance + polymorphism The procedure-oriented programming is used in the area of concurrency. Language Categories Programming languages are often categorized into four paradigms: imperative, functional, logic, and object oriented. But, some object-oriented languages extended from imperative language. C++ is superset of C. C++ support both imperative and object-oriented paradigm. The visual language is a subcategory of the imperative languages (ex..net)-called the forth generation Drag-and drop generation of code segment. Provide simple way to generate GUI to programs. The Script languages can be categorized as imperative languages 13 14 Language Categories Imperative + object-oriented +visual + script Central features are variables, assignment statements, and iteration Include languages that support object-oriented programming Include scripting languages Include the visual languages Examples: C, Java, Perl, JavaScript, Visual BASIC.NET, C++ Functional Main means of making computations is by applying functions to given parameters Examples: LISP, Scheme, ML, F# Logic Rule-based (rules are specified in no particular order) Example: Prolog Markup/programming hybrid Markup languages extended to support some programming Examples: HTML, XML, JSTL, XSLT 15 Language Design Trade-Offs Reliability vs. cost of execution Java vs. C or C++ Java: cost of execution is high but reliable C or C++: cost of execution is low but not reliable Readability vs. writability Example: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readability Writability (flexibility) vs. reliability Example: C++ pointers are powerful and very flexible but are unreliable 16 The machine language of a computer is its set of instructions. If there is no system software such as operating system, compiler, interpreter, only the machine language is only way to communicate with the computer. Theoretically a computer could be designed with a particular high-level language as it machine language- not flexible, expensive Implement hardware with a low-level language not portable Programming languages can be implemented by a=one of three general methods. Compilation Interpretation Hybrid between Compilation and Interpretation Software Banking System Compiler Interpreter Music Player Device Driver Airline Reservation GUI Interface Operating System Machine Language Micro-Architecture Physical Devices Web Browser Commend Interpreter(shell) Application Software System Software Hardware 17 18 3

Compilation Programs are translated into machine language; includes JIT systems analyzer->parser->intermediate code generator -> code generator Use: Large commercial applications C, C++ COBOL, Ada,.. Pure Interpretation Programs are interpreted by another program known as an interpreter Use: Small programs or when efficiency is not an issue Hybrid Implementation Systems A compromise between compilers and pure interpreters Use: Small and medium systems when efficiency is not the first concern Translate high-level program (source language) into machine code (machine language) Slow translation, fast execution Compilation process has several phases: lexical analysis: converts characters in the source program into lexical units syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program Semantics analysis: generate intermediate code code generation: machine code is generated 19 20 Source Code units Symbol Table intermediate Code Syntax Intermediate Code Generator Code & Semantic (parser) Parse Generator analyzer trees Optimization (optional) The compilation process Machine Code The machine language generated by a compiler might be executable, but it usually be executable along with some other code. Before the machine language programs produced by a compiler can be executed, libraries from the operating system must be linked to the user program. The linking operation connects the user program to the libraries by placing the addresses of the entry points of the libraries in the calls to them in the user program. 21 22 Von Neumann Bottleneck C++ or C environment Source code Object code Text editor Preprocessor Compiler Modified Source code Linker Executable Code Fetch cycle between a RAM and CPU determines the speed of a computer Program instructions often can be executed much faster than the speed of fetch cycle ; the fetch cycle speed thus results in a bottleneck Known as the von Neumann bottleneck; it is the primary limiting factor in the speed of computers 23 24 4

(Pure Interpretation) (Pure Interpretation) No translation Easier implementation of programs (run-time errors can easily and immediately be displayed) Slower execution (10 to 100 times slower than compiled programs)- decoding each high-level statement are more complex than machine language instructions. Often requires more space for decoding processe Now rare for traditional high-level languages Significant comeback with some Web scripting languages (e.g., JavaScript, PHP) Source Program Input data Interpreter Results 25 26 (Hybrid Implementation) A compromise between compilers and pure interpreters A high-level language program is translated to an intermediate language that allows easy interpretation Faster than pure interpretation Examples Perl programs are partially compiled to detect errors before interpretation Initial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has a byte code interpreter and a run-time system (together, these are called Java Virtual Machine) (Hybrid Implementation) Source Code units Syntax (parser) Parse trees Intermediate Code Generator & Semantic analyzer intermediate Code Interpreter Result COSC422 Org. of Programming Languages Dr. Sang-Eon Park 27 28 (Just-in-Time Implementation) Preprocessor A Just-in-Time ( JIT) implementation system initially translates programs to an intermediate language. Then, during execution, it compiles intermediate language methods into machine code when they are called. The machine code version is kept for subsequent calls. JIT systems are widely used for Java programs.net languages are implemented with a JIT system In essence, JIT systems are delayed compilers A preprocessor is a program that processes a program immediately before the program is compiled. Preprocessor instructions are commonly used to specify that the code from another file is to be included. Preprocessor create a modified source code by including header before compile. COSC422 Org. of Programming Languages Dr. Sang-Eon Park 29 30 5

Programming Environment A collection of tools used in software development UNIX An older operating system and tool collection Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME) that runs on top of UNIX Microsoft Visual Studio.NET A large, complex visual environment Used to build Web applications and non-web applications in any.net language NetBeans Related to Visual Studio.NET, except for applications in Java 31 6