Compiled vs Interpreted A tradeoff of flexibility vs efficiency.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Chapter FourModern Programming Languages1 Language Systems.
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 WHY MORE? Wasn’t ONE ENOUGH? Introduction to CS260.
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
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.
T-diagrams “Mommy, where do compilers come from?” Adapted from:
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Tannenbaum Machine. Key Features Simple architecture Simple instruction set Focus on –Input -> Higher Level Language –Output -> Machine Language Addressing.
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Concepts of Programming Languages Chapter 1.
COP4020 Programming Languages
CS 331, Principles of Programming Languages Introduction.
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Computer Science 101 Introduction to Programming.
1 Chapter-01 Introduction to Computers and C++ Programming.
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
CS 355 – Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
High-Level Programming Languages: C++
High-level Languages.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
CS1Q Computer Systems Lecture 14 Simon Gay. Lecture 14CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
ISBN CS 354 Preliminaries. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Course Topics What is a programming language? What features.
Levels of Abstraction Computer Organization. Level of Abstraction u Provides users with concepts/tools to solve problem at that level u Implementation.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
CS 331, Principles of Programming Languages Chapter 1.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
CPS120: Introduction to Computer Science Variables and Constants.
Getting Started With Java September 22, Java Bytecode  Bytecode : is a highly optimized set of instructions designed to be executed by the Java.
Compilers and Interpreters
Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,
小型系統 心情 vs. 古典樂 心情 vs. 古典樂 浪漫求籤系統 美食導航系統 季潔亭雅鈺熒岱芸 美食導航系統 楊氏音樂模擬大會考人瑋 若維 芷萱 伽倩 楊氏音樂模擬大會考 麥當勞熱量計算系統 火星文困擾你嗎 ? 火星文困擾你嗎 ? 歌詞知多少 - 挑戰你的腦容量英琪 日馨 青雪 鈺娟.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
CSCE 343 – Programming Language Concepts Welcome!.
Programming Language Basics. What is a Programming Language? “A computer, human-created language used to write instructions for a computer.” “An artificial.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
CIS 234: Object-Oriented Programming with Java
CMIT100 Chapter 14 - Programming.
Computer Organization
Language Translation Compilation vs. interpretation.
PROGRAMMING LANGUAGES
Programming Language Hierarchy, Phases of a Java Program
C# and the .NET Framework
1.1 Reasons to study concepts of PLs
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Chapter 11 Introduction to Programming in C
CMP 131 Introduction to Computer Programming
High Level Programming Languages
Programming Languages
Programming Language Basics
School of Computer & Information Engineering,
Reasons To Study Programming Languages
Computer Programming (CS101) Lecture-02
Presentation transcript:

Compiled vs Interpreted A tradeoff of flexibility vs efficiency

Similarity The function of a compiler or interpreter is to translate a Higher Level Language (HLL) and execute it. HLL Compiler or Interpreter Output

Major Difference Timing Amount of code translated before executing Oversimplified example –Translate a book -> Then read the book –Translate a statement -> Read statement (REPEAT) –Statement(word) at a time or do entire translation first.

Environments (extremes) Compiled –translate into object code –link –execute g++ is a script which hides steps –g++ -c HelloW.C creates HelloW.o –g++ -o HelloW HelloW.o links/creates HelloW

Environments (continued) Interpreted –Read line, translate, execute –Repeat unix basic calculator (bc) program America>bc a = a 16 b = a + 2 b 18 quit America>

Other languages Lots of languages are interpreted –Basic –Smalltalk –APL –java –Our Tannenbaum machine language

Target code Compilers –HLL -> Machine language of the executing machine Interpreters –HLL -> intermediate code –program reads those codes, translates by executing lots of machine language instructions

Example (Tannenbaum) A compiler would translate the pascal program directly into ML. If there was a real machine, what you see in ML would be the result of compilation. Target is native ML. –A := 4; -> LOCO 4 STOD A Instead, this is a virtual machine. The resulting ML requires us to execute hundreds of c++ instructions in our simulator and each of those c++ instructions requires multiple real ML instructions on the Sun. E.g. –A;=4 -> 2 ML (tann) -> 30 c++ -> 100 ML (sun)

Binding Times Compilers –Make decisions as early as possible –Results are more efficiently implemented Interpreters –make decisions late –Results less efficient –PROGRAMMERS more FLEXIBILITY

XML – delaying decisions cs260 Prof. Game Announcement Test on Wednesday! cs260 Prof. Game Announcement Test on Wednesday! versus

Binding Time example Compiler: a:=4; Decide where to store the variable and simple translation like what we saw in the Tannenbaum example. A few ML instructions. Interpreter: a:=4; a:=“Hello”; Requires a RUN-TIME DESCRIPTOR. (see next slide). Code must check: if (numeric) … else if (string) … else...

Descriptor A B C int45 float string5 Hello type lengthvalue Managed during execution. Examined at each reference!

Now do B:=‘xyz’ A B C int45 string5 Hello type lengthvalue B had it’s value changed, so descriptor also changed. Not as simple as STOD B. string3 xyz

Most languages are a combination Pascal/Tannenbaum example –A:=4; -> direct translation in ML –writeln(A); -> must interpret with a procedure. Java –byte codes for virtual machine –JIT (just in time) compiler to translate parts of it for the purpose of efficiency Grey areas

How do we use this categorization? Think of it more in terms of features rather than the entire language. Tradeoff is Efficiency vs Flexibility This gives us a sense of whether the feature or language executes to provide optimal performance or perhaps optimizes other factors such as flexibility of target/platform such as in java.