Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT, www.cs.njit.edu/~elsa/635 www.cs.njit.edu/~elsa/635.

Slides:



Advertisements
Similar presentations
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
Advertisements

Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
Overview of Programming Paradigms
The Analytical Engine Module 6 Program Translation.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Programming Languages Structure
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Programming Languages and Compilers (CS 421)
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
PZ01A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01A -- Introduction Programming Language Design and.
CS 355 – Programming Languages
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
High-Level Programming Languages: C++
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
9/18/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
COP4020 Programming Languages
Chapter 1. Introduction.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
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.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 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.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Programming Languages
Introduction to Language Programming Hierarchy of programming lang. Based on machine independences: 1. Machine language 2. Assembly language 3. Higher.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Chapter 1 An Overview of Computers and Programming Languages.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Advanced Computer Systems
Chapter 1 Introduction.
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
Lecture 1: Introduction to JAVA
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Construction
Compiler Construction
CSCE Fall 2013 Prof. Jennifer L. Welch.
CSCE Fall 2012 Prof. Jennifer L. Welch.
Principles of Programming Languages
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Computer Systems An Introducton.
Programming Languages and Compilers (CS 421)
Presentation transcript:

Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,

Copyright 2002 Elsa L. Gunter Language Paradigms – Imperative Languages Main focus: machine state – the set of values stored in memory locations Command-driven: Each statement uses current state to compute a new state Syntax: S1; S2; S3;... Example languages: C, Pascal, FORTRAN, COBOL

Copyright 2002 Elsa L. Gunter Language Paradigms – Object-oriented Languages Classes are complex data types grouped with operations (methods) for creating, examining, and modifying elements (objects); subclasses include (inherit) the objects and methods from superclasses

Copyright 2002 Elsa L. Gunter Language Paradigms – Object-oriented Languages Computation is based on objects sending messages (methods applied to arguments) to other objects Syntax: Varies, object <-method(args) Example languages: Java, C++, Smalltalk

Copyright 2002 Elsa L. Gunter Language Paradigms – Applicative Languages Applicative (functional) languages –Programs as functions that take arguments and return values; arguments and returned values may be functions –Programming consists of building the function that computes the answer; function application and composition main method of computation –Syntax: P1(P2(P3 X)) –Example languages: ML, LISP, Scheme

Copyright 2002 Elsa L. Gunter Language Paradigms – Logic Programming Rule-based languages –Programs as sets of basic rules for decomposing problem –Computation by deduction: search, unification and backtracking main components –Syntax: Answer :- specification rule –Example languages: (Prolog, Datalog,BNF Parsing)

Copyright 2002 Elsa L. Gunter Programming Language Implementation Develop layers of machines, each more primitive than the previous Translate between successive layers End at basic layer Ultimately hardware machine at bottom

Copyright 2002 Elsa L. Gunter Basic Machine Components Data: basic data types and elements of those types Primitive operations: for examining, altering, and combining data Sequence control: order of execution of primitive operations

Copyright 2002 Elsa L. Gunter Basic Machine Components Data access: control of supply of data to operations Storage management: storage and update of program and data External I/O: access to data and programs from external sources, and output results

Copyright 2002 Elsa L. Gunter Basic Computer Architecture External files Cache memory Main memory Program counter Data registers Interpreter Arithmetic/Logic Unit CPU

Copyright 2002 Elsa L. Gunter Virtual (Software) Machines At first, programs written in assembly language (or at very first, machine language) Hand-coded to be very efficient Now, no longer write in native assembly language Use layers of software (eg operating system) Each layer makes a virtual machine in which the next layer is defined

Copyright 2002 Elsa L. Gunter Example Layers of Virtual Computers for a C Program Virtual computer built by programmer C virtual computer Windows 98 OS virtual computer Micro-code virtual computer Actual Hardware Computer Input dataOutput results

Copyright 2002 Elsa L. Gunter Virtual Machines Within Compilers Compilers often define layers of virtual machines –Functional languages: Untyped lambda calculus -> continuations -> generic pseudo-assembly -> machine specific code –May compile to intermediate language that is interpreted or compiled separately Java virtual machine, CAML byte code

Copyright 2002 Elsa L. Gunter To Class Name some examples of virtual machines Name some examples of things that aren’t virtual machines

Copyright 2002 Elsa L. Gunter Interpretation Versus Compilation A compiler from language L1 to language L2 is a program that takes an L1 program and for each piece of code in L1 generates a piece of code in L2 of same meaning An interpreter of L1 in L2 is an L2 program that executes the meaning of a given L1 program Compiler would examine the body of a loop once; an interpreter would examine it every time the loop was executed

Copyright 2002 Elsa L. Gunter Program Aspects Syntax: what valid programs look like Semantics: what valid programs mean; what they should compute Compiler must contain both information

Copyright 2002 Elsa L. Gunter Major Phases of a Compiler Lex –Break the source into separate tokens Parse –Analyze phrase structure and apply semantic actions, usually to build an abstract syntax tree

Copyright 2002 Elsa L. Gunter Major Phases of a Compiler Semantic analysis –Determine what each phrase means, connect variable name to definition (typically with symbol tables), check types

Copyright 2002 Elsa L. Gunter Major Phases of a Compiler Translate to intermediate representation Instruction selection Optimize Emit final machine code JavaSML C++ Pascal C IR SparcMIPSPentiumAlpha

Copyright 2002 Elsa L. Gunter Major Phases of a Compiler Source Program Lex Tokens Parse Abstract Syntax Semantic Analysis Symbol Table Translate Intermediate Representation Modified from “Modern Compiler Implementation in ML”, by Andrew Appel Instruction Selection Optimized Machine-Specific Assembly Language Optimize Unoptimized Machine- Specific Assembly Language Emit code Assembler Relocatable Object Code Assembly Langague Linker Machine Code

Copyright 2002 Elsa L. Gunter Example of Intermediate Representation Program code: X = Y + Z + W –tmp = Y + Z –X = tmp + W –Simpler language with non compound arithmetic expressions

Copyright 2002 Elsa L. Gunter Example of Optimization Load reg1 with Y Load reg2 with Z Add reg1 and reg2, saving to reg1 Store reg1 to tmp ** Load reg1 with tmp ** Load reg2 with W Add reg1 and reg2, saving to reg1 Store reg1 to X Program code: X = Y + Z + W Eliminate two steps marked **

Copyright 2002 Elsa L. Gunter Next Lecture: SML Compiler is on the AFS system at /usr/local/sml/bin/sml To run the compiler under MS Windows, install: smlnj.exe orhttp:// smlnj.exe ftp://ftp.research.bell- labs.com/dist/smlnj/release/110/110- smlnj.exeftp://ftp.research.bell- labs.com/dist/smlnj/release/110/110- smlnj.exe

Copyright 2002 Elsa L. Gunter WWW Addresses for SML labs.com/cm/cs/what/smlnj/index.htmlhttp://cm.bell- labs.com/cm/cs/what/smlnj/index.html labs.com/cm/cs/what/smlnj/doc/basis/pages/s ml-std-basis.htmlhttp://cm.bell- labs.com/cm/cs/what/smlnj/doc/basis/pages/s ml-std-basis.html

Copyright 2002 Elsa L. Gunter Books on SML Supplemental texts (not required) –Elements of ML Programming, by Jeffrey D. Ullman, on Prentice Hall –ML for the Working Programmer, by Lawrence C. Paulson, on Cambridge University Press

Copyright 2002 Elsa L. Gunter