Semester Review. CSC 301, Fall 2015

Similar documents
CSCI 3136 Principles of Programming Languages

Lecture 1: Introduction

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Programming Languages

CSE 307: Principles of Programming Languages

Chapter 6: Programming Languages

CSC Software II: Principles of Programming Languages

1/20/2016 INTRODUCTION

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Stack Allocation. Run-Time Data Structures. Static Structures

Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Lecture 9. Semantic Analysis Scoping and Symbol Table

Programming Language Pragmatics

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Chapter 5 Names, Bindings, Type Checking, and Scopes

Moving from CS 61A Scheme to CS 61B Java

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

The C Programming Language course syllabus associate level

CA Compiler Construction

Ed. v1.0 PROGRAMMING LANGUAGES WORKING PAPER DRAFT PROGRAMMING LANGUAGES. Ed. v1.0

Division of Mathematical Sciences

Programming and Software Development CTAG Alignments

CS 106 Introduction to Computer Science I

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Computer Science/Software Engineering

Semantic Analysis: Types and Type Checking

McGraw-Hill The McGraw-Hill Companies, Inc.,

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

1.1 WHAT IS A PROGRAMMING LANGUAGE?

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.

Chapter 7: Functional Programming Languages

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Computer Programming I

Introduction to formal semantics -

CSE 130 Programming Language Principles & Paradigms

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Image credits:

Basic Programming and PC Skills: Basic Programming and PC Skills:

Fundamentals of Java Programming

Functional Programming

Departamento de Investigación. LaST: Language Study Tool. Nº 143 Edgard Lindner y Enrique Molinari Coordinación: Graciela Matich

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

C Compiler Targeting the Java Virtual Machine

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

Programming Language Concepts for Software Developers

Compiler Construction

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Language Processing Systems

Chapter 15 Functional Programming Languages

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.

Android Application Development Course Program

Course Goal CMSC 330: Organization of Programming Languages. Studying Programming Languages. All Languages Are (Kind of) Equivalent.

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Object-Oriented Software Specification in Programming Language Design and Implementation

Fundamentals of Programming Languages

Levels of Programming Languages. Gerald Penn CSC 324

Java (12 Weeks) Introduction to Java Programming Language

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Concepts of Programming Languages: A Unified Approach. Karl Abrahamson

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Programming Languages

Programming Languages in Artificial Intelligence

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Department of Computer Science

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

The previous chapter provided a definition of the semantics of a programming

Chapter 12 Programming Concepts and Languages

What is a programming language?

ML for the Working Programmer

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

UNIT-I Preliminaries

Embedded Software Development with MPS

Computer Science/Mathematics Curriculum Pepperdine University

Computer Science. Requirements for the Major (updated 11/13/03)

CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler

Pluggable Type Systems. Gilad Bracha

The programming language C. sws1 1

Habanero Extreme Scale Software Research Project

Introducing Formal Methods. Software Engineering and Formal Methods

Introducing Tetra: An Educational Parallel Programming System

Structure of Presentation. The Role of Programming in Informatics Curricula. Concepts of Informatics 2. Concepts of Informatics 1

Scanning and parsing. Topics. Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Fall 2012 Q530. Programming for Cognitive Science

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Compiler I: Syntax Analysis Human Thought

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value

Transcription:

Semester Review CSC 301, Fall 2015

Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration! Functional Languages! recursion and single valued variables! Logic/Rule Based Languages! programs consist of rules that specify the problem solution - axiomatization! Object-Oriented Languages! bundle data with the allowed operations " Objects

Formal Language Specification Language Specifications consist of two parts:! The syntax of a programming language is the part of the language definition that says what programs look like; their form and structure.! The semantics of a programming language is the part of the language definition that says what programs do; their behavior and meaning.

Formal Language Specification In order to insure conciseness of language specifications we need tools:! Grammars are used to define the syntax.! Mathematical constructs (such as predicates and sets) are used to define the semantics.

Grammars Example: a grammar for simple English sentences. Start Symbol Production <Sentence>* ::= <Noun-Phrase> <Verb> <Noun-Phrase> <Noun-Phrase> ::= <Article> <Noun> <Verb> ::= loves hates eats <Article> ::= a the <Noun> ::= dog cat rat Non-terminal Terminal " Grammars capture the structure of a language.

How do Grammars work? We can view grammars as rules for building parse trees or derivation trees for sentences in the language defined by the grammar. In these parse or derivation trees the start symbol will always be at the root of the tree. <Sentence>* ::= <Noun-Phrase> <Verb> <Noun-Phrase> <Noun-Phrase> ::= <Article> <Noun> <Verb> ::= loves hates eats <Article> ::= a the L(G) = { s s can be derived from G } <Noun> ::= dog cat rat <Sentence>* Derivation: <Noun-Phrase> <Verb> <Noun-Phrase> <Article> <Noun> loves <Article> <Noun> Derived String the dog the cat

Grammars and Semantics Given grammar G, consider the sentence a+b+c; here we have two possible parse trees: G: <AddExp> ::= <AddExp> + <AddExp> <MulExp> <MulExp> ::= <MulExpr> * <MulExp> a b c A grammar is ambiguous if there exists more than one parse tree for a string of terminals. <AddExp>* <AddExp> + <AddExp> <AddExp> + <AddExp> <MulExp> <MulExp> a <MulExp> b c <AddExp>* <AddExp> + <AddExp> <MulExp> <AddExp> + <AddExp> a <MulExp> b <MulExp> c

Language Systems What actually happens in your IDE? IDE Integrated Development Environment Classical Sequence: C++, C, Fortran IDE Library Code Assembly Source Language Object Executable File File Code Code Editor Compiler Assembler Linker Loader NOTE: The IDE is not a compiler, it contains a compiler. NOTE: Many different IDE structures possible, depending on the language.

Compilers vs. Interpreters! Compilers translate high-level languages (Java, C, C+ +) into low-level languages (Java Byte Code, assembly language).! Interpreters execute high-level languages directly (Lisp). Observation: Virtual machines can be considered interpreters for low-level languages; they directly execute a low-level language without first translating it. Observation: Compilers can generate very efficient code and, consequently, compiled programs run faster than interpreted programs.

The Anatomy of a Compiler Source Program Parse Trees (ASTs) Syntax Analysis Semantic Analysis Optimization Code Generation Recognize the structure of a source program, generate parse tree Recognize/validate the meaning of a source program Reorganize the parse tree/ast to make computations more efficient Translate parse tree/ast into low-level language Recognition Phases Code Generation Phases Translated Program Observations: - Language definitions have two parts: syntax and semantics - Compilers have two phases which deal with each of these language definition components: syntax analysis, semantic analysis.

ML ML is a functional programming language, typical statements in this language are: - fun reverse ([ ]) = [ ] reverse (x :: xs) = reverse(xs) @ [x]; - map (fn x => x + 2) [1,2,3];

Polymorphism polymorphism comes from Greek meaning many forms In programming: Def: A function or operator is polymorphic if it has at least two possible types.

Polymorphism i) Overloading Def: An overloaded function name or operator is one that has at least two definitions, all of different types. ii) Parameter Coercion Def: An implicit type conversion is called a coercion. iii) Parametric Polymorphism Def: A function exhibits parametric polymorphism if it has a type that contains one or more type variables. iv) Subtype Polymorphism Def: A function or operator exhibits subtype polymorphism if one or more of its constructed types have subtypes. Note: one way to think about this is that this is type coercion on constructed types.

Scope & Namespaces Def: A definition is anything that establishes a possible binding to a name. Def: Scope is a programming language tool to limit the visibility of definitions. Def: A namespace is a zone in a programming language which is populated by names. In a namespace, each name must be unique. The most common namespace in programming languages is the block.

Scoping with Blocks Def: A block is any language construct that contains definitions and delineates the region of the program where those definitions apply. Example: Java Example: ML def. q def. r if (cond) { int q =...; } else { int r =...; block def. q let val q =...; in... end block }

Primitive Namespaces Def: A primitive namespace is a language construct that contains definitions and delineates a region of the program where those definitions apply; but the region was defined at language design time (similar to primitive data types, you can use them but not define them). Most modern programming languages define two primitive namespaces one for user defined variable names and one for type names (both primitive and constructed). primitive namespace for variable names primitive namespace for type names q,... int, float,... int q =...; namespace (e.g. block, implicit block, labeled namespace, etc)

Activation Records & Runtime Stack The second activation is about to return. int fact(int n) { int result; if (n<2) result = 1; else result = n * fact(n-1); return result; } current activation record n: 1 return address previous activation record result: 1 n: 2 return address previous activation record result: 2 n: 3 return address previous activation record result:?

Memory Management 0 Compiled code, RTS, Library code A typical memory layout for languages such as C and Java static Heap Manager Global data Stack Pointer Runtime stack NOTES: (1) if the runtime stack and the heap meet out of memory (2) Also: memory leaks, dangling pointers and garbage collection dynamic Heap FF..FF

Parameter Passing! How is the correspondence between acutal and formal parameters established?! Most often positional correspondence! How is the value of an actual parameter transmitted to a formal parameter?! Most popular techniques: by-value, byreference

Prolog! Programming language based on firstorder logic! Predicates! Quantification! Modus-ponens! Can be made executable using Hornclause logic! Deduction is computation!

Prolog Typical Programs: last([a],a). last([a L],E) :- last(l,e). append([ ], List, List). append([h T], List, [H Result]) :- append(t, List, Result). length([ ], 0). length(l, N) :- L = [H T], length(t,nt), N is NT + 1.

Formal Semantics Grammars define the structure of a language, but what defines semantics or meaning? Behavior! The most straight forward way to define semantics is to provide a simple interpreter for the programming language that highlights the behavior of the language, Operational Semantics We used Prolog to define abstract interpreters for our languages, I.e., operational semantics for these languages.