Compiled and Interpreted Languages CS 480/680 – Comparative 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

Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Refer to Ivor Horton’s Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. About the book Ivor Horton, Beginning ANSI C++: The Complete.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Software Language Levels Machine Language (Binary) Assembly Language –Assembler converts Assembly into machine High Level Languages (C, Perl, Shell)
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
1 Programming Languages b Each type of CPU has its own specific machine language b But, writing programs in machine languages is cumbersome (too detailed)
CMPT 120 Introduction to Computer Science and Programming I Chris Schmidt.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Source Code Basics. Code For a computer to execute instructions, it needs to be in binary Each instruction is given a number Known as “operation code”
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
CS 331, Principles of Programming Languages Introduction.
History of Programming Languages
Introduction and Overview of the Course CS 480/680 – Comparative Languages.
Intro. to Game Programming Want to program a game?
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.
Hello World 2 What does all that mean?.
Chapter 1. Introduction.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
Programming History. Who was the first programmer?
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Introduction to Computer Programming in c
2-1 Hardware CPU Memory - 2 kinds Network Graphics Input and Output Devices.
PROGRAMMING LANGUAGES
Introduction to Computer Programming in c
CS 331, Principles of Programming Languages Chapter 1.
CS-303 Introduction to Programming
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 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Software Engineering Algorithms, Compilers, & Lifecycle.
High-level language programming paradigms. Programming languages come in many forms or 'paradigms'. Each form of language offers advantages over other.
CSCE 343 – Programming Language Concepts Welcome!.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Chapter 1. Introduction.
Evolution and History of Programming Languages
Programming Languages 2nd edition Tucker and Noonan
Basic Concepts: computer, program, programming …
The language focusses on ease of use
Introduction to programming languages, Algorithms & flowcharts
Why study programming languages?
Introduction to programming languages, Algorithms & flowcharts
PROGRAMMING LANGUAGES
Programming Language Hierarchy, Phases of a Java Program
CSCI-235 Micro-Computer Applications
Programming Basics Web Programming.
Application Development Theory
Teaching Computing to GCSE
Introduction to programming languages, Algorithms & flowcharts
Teaching Computing to GCSE
Hello World 2 What does all that mean?.
High Level Programming Languages
CMP 131 Introduction to Computer Programming
Principles of Programming Languages
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Programming language translators
Presentation transcript:

Compiled and Interpreted Languages CS 480/680 – Comparative Languages

Compiling and Interpreting2 Compiling High Level Languages Source Code (text) Compiler Assembly (text) Assembler Relocatable Object Code (machine code without addresses) Linker/Loader Executable Code (machine code)

Compiling and Interpreting3 The Compilation Process (1) C++ int var1, var2; void main() { var1 = 5; var2 = 37; var2 /= var1; cout << var2 << endl; } Assembly SECTION MAIN,CODE XREFPRINTINT _MAINMOVE.W#5,VAR1 MOVE.W#7,VAR2 MOVE.WVAR1,D1 MOVE.WVAR2,D2 EXT.LD2 DIVS.WD1,D2 MOVE.WD2,VAR2 MOVE.WVAR2,-(SP) JSRPRINTINT MOVE.W#228,D7 TRAP#14 VAR1DS.L1 VAR2DS.L1 END

Compiling and Interpreting4 The Compilation Process (2) 1SECTION MAIN,CODE 2 XREFPRINTINT FC _MAINMOVE.W#5,VAR FC C 4 MOVE.W#7,VAR MOVE.WVAR1,D C 6 MOVE.WVAR2,D C 48C2 7 EXT.LD E 85C1 8 DIVS.WD1,D C C 9 MOVE.WD2,VAR F C 10 MOVE.WVAR2,-(SP) C 4EB JSRPRINTINT E3C 00E4 12 MOVE.W#228,D E4E 13 TRAP# VAR1DS.L C 15 VAR2DS.L END

Compiling and Interpreting5 The Compilation Process (3) #SECTION_CODE MAIN FC FC C C48C285C C C3F C4EB E3C00E44E4E #LOCAL C #XREF_32 PRINTINT E MOVE.W#5,VAR1 = loader = linker

Compiling and Interpreting6 Advantages of Compiled Higher Languages  Abstraction of hardware details  Allow a program to more easily be ported to other hardware platforms  Can be tailored for specific types of applications Web programming Logic programming

Compiling and Interpreting7 Interpreted Languages  Interpreted languages are not compiled  The source code is run directly Often compiled into a more efficient pseudo- language just before running Only machine code can run on the CPU, so how does an interpreted language run? The interpreter is an executable program which interprets the source code and runs the appropriate machine code.

Compiling and Interpreting8 Compiled and Interpreted Languages Compilation Executable Input Output Interpreter ProgramInput Output Source Compiled Interpreted

Compiling and Interpreting9 Example of Interpreted Code #!/usr/bin/perl $var1 = 7; $var2 = ”008”; $var3 = $var1 * $var2; print ”Result: $var3\n”; $string = ’print ”program ending now\n”’; eval $string; exit; $> perl myscript Result: 56 program ending now

Compiling and Interpreting10 Eval()  A key advantage of interpreted languages is that they can build and execute code on-the-fly Essentially, the “compiler” is built into the interpreter program  How hard would this be for a compiled language?

Compiling and Interpreting11 Pros and Cons of Interpreted Languages  Advantages of interpreted languages Fast (program development) and messy  Untyped variables  On-the-fly variable creation  Eval() Extremely portable code Powerful Lean (only the interpreter is fat)

Compiling and Interpreting12 Pros and Cons of Interpreted Languages  Disadvantages of interpreted languages Much slower to execute Can be very hard to debug: Linking is an issue – may not be appropriate for large-scale software development $count = 0; while ($counnt < 100) { … $count++; }

Compiling and Interpreting13 Programming Tradeoffs Efficiency Abstraction (Ease of use, specialization, paradigm enforcing, etc.) Assembly C C++ Java, Lisp Perl, Python, Ruby, etc. Fortran, Pascal

Compiling and Interpreting14 Some High Level Languages InterpretedCompiled Object-oriented Ruby, Python, Java C++ ImperativePerl C, C++, FORTRAN, Pascal FunctionalLISP, SchemeLISP, ML

Compiling and Interpreting15 A Brief History of Programming Languages