1 Introduction Why Study Programming Languages?
|
|
- Vivian Stewart
- 6 years ago
- Views:
Transcription
1 1 Introduction Why Study Programming Languages? Choosing the right language for the job Designing a better language Languages we know determine how we think about programming A language that doesn t affect the way you think about programming is not worth knowing. Alan Perlis 1
2 8 Languages in an hour We look briefly at some of the variety we find in programming languages Just to show variety; don t worry if you don t understand most of the programs Fortran Cobol Lisp APL Forth Eiffel Bison Mercury 2
3 1.1 Fortran (FORmula TRANslator) Designed in the mid 1950s Subroutines, but no recursion or nesting Control flow by goto, conditional, and bounded iteration Commonly used in engineering and science applications Fortran 90 and 95 are much improved versions, compared to the original versions; work is under way on Fortran
4 Fortran example integer I, MX, MN,A(100) real RS read(a(i), I = 1, 100) MX = A(1) MN = A(1) do 10 I = 2, 100 if (A(I).gt.MX) MX = A(I) if (A(I).lt.MN) MN = A(I) 10 continue RS = (MN + MX)/2 write RS end 4
5 1.2 Cobol (COmmon Business Oriented Language) Designed around 1959 For processing large amounts of data Verbose, for readability Powerful notion of file Supports goto, conditional goto, for loop Program consists of 4 divisions: Identification, Environment, Data, and Procedure Still commonly used for business applications 5
6 Cobol example (simplified) data division file section FD STFILE 01 STUDENT 02 STUDENT-NAME picture A(15) 02 COURSE occurs 30 times 03 COURSE-NAME picture AAAA SCORE picture STUDENT-ID picture working-storage section 01 TOTAL picture
7 Cobol example (simplified) (2) procedure division init. open input STFILE. move zero to TOTAL. sum. read STFILE; at end go to fin. perform adding varying J from 1 by 1 until J > 30. go to sum. adding. read COURSE(J). add SCORE to TOTAL. fin. display TOTAL. close STFILE. 7
8 1.3 Lisp (LISt Processing) Designed in the late 1950s, inspired by the lambda calculus. Still in active use, with several dialects surviving Functional, that is, mainly based on function application Functions are first-class objects, even if higher-order and/or recursive Typeless: S-expression is the only type 8
9 Lisp (LISt Processing) (2) S-expression is number, atom (symbol), or list d b c a This binary tree represents the S-expression (((a.nil).(b.c)).(d.nil)) 9
10 Lisp example (defun intersect (m n) (cond ((null m) nil) ((member (car m) n) (cons (car m) (intersect (cdr m) n))) (t (intersect (cdr m) n)))) This function returns the intersection of two lists 10
11 1.4 APL (A Programming Language) Designed in the early 1960s Extremely compact programs Based on multidimensional arrays Powerful array operations, elementwise, cumulative,... Many special symbols, uses a special character set Used in scientific and engineering applications 11
12 APL example A program that generates the first N Fibonacci numbers: F IB N [1] A 1 1 [2] 2 N > ρa A, +/ 2 A 12
13 APL example (2) A program that generates prime numbers up to N: (2 = +/[1]0 = S. S)/S ι N) With experience this becomes readable (?) Some call APL a write-only language Often easier to rewrite than modify a function concise readable! 13
14 1.5 Forth Designed in the early 1970s for use on small computers Stack based: operations take their operands from the (single) stack and place their result(s) on the stack No named parameters or local variables; data is handled by stack manipulation Forth is the basis for the Postscript page description language 14
15 Forth example : sqr dup * ; n => n*n : dosum swap 1 + n, s => s, (n+1) swap over => (n+1), s, (n+1) sqr + ; => (n+1), (s+(n+1)^2) : sumsqr 0 swap n => 0, n 0 swap 0 => 0, 0, n, 0 do dosum loop => sum i=0 to n of i^2 15
16 1.6 Eiffel Designed in the 1980s Object oriented: definitions of operations and data are encapsulated together. Uses inheritance to define new data structures and operations in terms of others Design by contract: operations specify the initial conditions they require and the final conditions they will ensure Polymorphic: can define operations and types that can work on objects of any type 16
17 Eiffel example class STACK[T] export push, pop, empty, full feature implementation: ARRAY[T] max_size: INTEGER nb_elements: INTEGER Create(n: INTEGER) is do if n>0 then max_size := n end; implementation.create(1, max_size) end; 17
18 Eiffel example (2) empty: BOOLEAN is do Result := (nb_elements = 0) end; pop:t is require not empty do Result := implementation.entry(nb_elements); nb_elements := nb_elements - 1; ensure not full; nb_elements = old nb_elements - 1 end;... 18
19 1.7 Bison Originally developed in the 1980s as a free replacement for the older YACC language Special purpose designed for writing parsers Translates input into C source code Usually used with a scanner generator such as FLEX Usually used for only a small part of an application 19
20 Bison example %{ #define YYSTYPE double #include <math.h> %} %token NUM %left - + %left * / %left NEG /* negation--unary minus */ %right ^ /* exponentiation */ %% 20
21 Bison example (2) input: /* empty string */ input line ; line: \n exp \n { printf ("\t%.10g\n", $1); }; exp: NUM { $$ = $1; } exp + exp { $$ = $1 + $3; } exp - exp { $$ = $1 - $3; } exp * exp { $$ = $1 * $3; } exp / exp { $$ = $1 / $3; } - exp %prec NEG { $$ = -$2; } exp ^ exp { $$ = pow ($1, $3); } ( exp ) { $$ = $2; } ; %% 21
22 1.8 Mercury Originated in early 1990s at University of Melbourne Logic/functional programming language A program consists of clauses, that is, facts and rules that allow new facts to be deduced from old Purely declarative A program can be regarded as a knowledge-base (what to compute, rather than how) Strong types and modes Nondeterministic: some queries have multiple solutions Control flow by backtracking as well as invocation Parameter passing by unification (bidirectional) 22
23 Mercury example :- type list(t) ---> [] ; [T list(t)]. :- pred append(list(t), list(t), list(t)). :- mode append(in, in, out) is det. :- mode append(in, out, in) is semidet. :- mode append(out, out, in) is multi. append([], C, C). append([a B], C, [A BC]) :- append(b, C, BC). 23
24 24
25 2 Abstraction We all know that the only mental tool by means of which a very finite piece of reasoning can cover a myriad cases is called abstraction ; as a result the effective exploitation of his powers of abstraction must be regarded as one of the most vital activities of a competent programmer.... The purpose of abstracting is not to be vague, but to create a new semantic level in which one can be absolutely precise. Edsgar Dijkstra 25
26 Abstraction (2) From the ultralingua.net dictionary: 1. The process of formulating general concepts by abstracting common properties of instances; generalization. 2. A general concept formed by extracting common features from specific examples. 26
27 Abstraction (3) Good programmers continually look for better abstractions for what they are doing Often find them in new functions or datatypes Occasionally they can only be found in a different programming language or paradigm, or by using a language preprocessor Once in a while, one must invent a new preprocessor or language or even paradigm 27
28 2.1 Abstraction in programming Some abstractions developed in computer science: assembly language abstracted instruction numbers and formats FORTRAN and other high-level languages abstracted the details of the actual machine Operating Systems abstracted interaction with external entities functions and procedures abstract a sequence of operations 28
29 2.1.1 Machine Language Why do we have programming languages? A (fragment of a) stored executable program ultimately looks like this: and initially, this was what programmers wrote (or toggled into a computer s front panel) Each line is a command; command names, register numbers, etc, are encoded as numbers 29
30 2.1.2 Assembly Language In assembly language the above might be written LOAD I ADD J STORE K Take the value stored in I s cell, add the value stored in J s cell, and put the sum in K s cell I.e., calculate K = I + J Abstracts numeric opcodes to symbols, addresses to names 30
31 2.1.3 More intelligible languages Historic trend towards more abstract, understandable programming notation The language should help us write programs that are easy to read, easy to understand, easy to modify This generally means higher levels of abstraction, and sometimes specialization for certain programming tasks Different languages provide different abstractions; no one-size-fits-all language 31
32 2.1.4 Data and Control Abstraction The two most important kinds of abstractions made in programming languages are data and control abstraction Discussed in detail later Data abstractions abstract the things the program manipulates Control abstractions abstract the operations performed 32
33 2.2 Binding Time Binding time: when a particular decision is made Many possible binding times, but the most interesting are: 1. Run time 2. Compile time (or link time) 3. Coding time (programmer decides) 4. Language implementation time 5. Language definition time 33
34 Binding Time (2) Some issues to consider binding time for: variable type possible variable values variable value data structure deallocation procedure invoked conditional branch taken 34
35 Binding Time (3) Trade-off between flexibility and efficiency Later binding times often mean simpler and more powerful facilities, earlier often mean better performance For example, deciding about storage reclamation at runtime (GC) makes programming easier and more robust; deciding at coding time is more efficient Program analysis may allow some reclamation at compile-time, with the rest done at runtime. This is typical: often some runtime decisions can be made at compile-time by program analysis 35
36 2.3 Issues What are your favourite programming languages? Why? What do you like about them? What language misfeatures do you dislike? What makes a language powerful? Safe? Easy to code? Easy to debug? 36
37 2.4 Syntax Some syntax issues in language design: readability consistency orthogonality simplicity substitutivity familiarity 37
38 2.4.1 Readability The C syntax for declarations aims at being very consistent with the syntax for object use. For example, int *n; makes it clear that *n denotes an integer. However, char (*(*x())[])(); does not exactly make it clear that x is a function, and the type of the function would be a mystery even to seasoned programmers. 38
39 2.4.2 Consistency C syntax deliberately blurs the distinction between pointers and arrays (and strings). Often misleading: pointers and arrays are semantically very different Many (but not all!) operations can be applied equally well to arrays and pointers, leading to errors Can refer to the same object as f[3], *(f+3), or even 3[f]. Is that really what we want? 39
40 2.4.3 Orthogonality Pre 1977 Fortran had a number of strange restrictions on syntax. E.g., 5 * X was allowed, but not X * 5. Also, something like F(100 - X) was illegal. For a subroutine call like that, one would have to do Y = X F(Y) 40
41 2.4.4 Simplicity The syntax of languages like PL/I and Ada are criticized as being too complex. There is much to remember, making it difficult to program without a reference manual at hand Lisp has a very simple syntax: everything is a list, written surrounded with parentheses Many Lisp hackers appreciate the simple syntax, finding that it makes code layout simple Lisp detractors for Lisp programs unreadable, however, insisting that LISP stands for Lots of Incomprehensible Silly Parentheses. Familiarity issue? Visual complexity? 41
42 2.4.5 Substitutivity The old debate about the semicolon: In PL/1: a statement terminator In Pascal: a statement separator In C: a terminator for some statements, not blocks Pascal programmers have a problem editing: begin x := 5; y := 7 end 42
43 Substitutivity (2) In C, macros cause trouble with semicolon. Now #define swap(p,q) \ {t=p; p=q; q=t;} if (x>3) swap(x,y); is fine, but we have a problem with if (x>3) swap(x,y); else x=y; 43
44 Substitutivity (3) It is not easy to see how to avoid this. The expert C hacker will write: #define swap(p,q) \ do {t=p; p=q; q=t} while (0) This doesn t even declare t a bigger problem Even a simple definition like: #define square(x) x*x goes badly wrong 44
45 2.4.6 Familiarity Sometimes language designers break conventions from mathematical notation or other programming languages, making life harder for programmers In C, the assignment operator is =, the usual notation for identity, a symmetric relation Made worse by the fact that an assignment has a value, so that if (x = 3)... is syntactically correct Other operators (e.g., <- or :=) preferable? But now = is familiar from FORTRAN, C, etc! 45
46 Familiarity (2) The Z specification language uses L A T E X to write programs, so Z uses rich notation including symbols such as,,, etc. Prolog has an if then construct, p -> q, which looks like classical implication, but false -> false returns false! A different syntax would be less misleading. (NU-Prolog, differs: the query would yield true.) 46
47 2.4.7 Conclusion These are some broad principles one can apply to programming language syntax. Unfortunately, how to weight these aspects is unclear, and even how to apply these principles is not always clear. Syntax decisions are influenced by: what kinds of problems are targeted background of likely practitioners programming environments available taste 47
48 48
SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017
SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationFunctional Programming. Big Picture. Design of Programming Languages
Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationSummer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define
CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationCS 415 Midterm Exam Fall 2003
CS 415 Midterm Exam Fall 2003 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you can to
More informationFunctional Programming Languages (FPL)
Functional Programming Languages (FPL) 1. Definitions... 2 2. Applications... 2 3. Examples... 3 4. FPL Characteristics:... 3 5. Lambda calculus (LC)... 4 6. Functions in FPLs... 7 7. Modern functional
More informationModern Programming Languages. Lecture LISP Programming Language An Introduction
Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation
More informationCPS 506 Comparative Programming Languages. Programming Language Paradigm
CPS 506 Comparative Programming Languages Functional Programming Language Paradigm Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages The First Functional Programming
More informationFall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives
CS 6A Scheme Fall 207 Discussion 7: October 25, 207 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write
More informationSpring 2018 Discussion 7: March 21, Introduction. 2 Primitives
CS 61A Scheme Spring 2018 Discussion 7: March 21, 2018 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme
More informationMIDTERM EXAMINATION - CS130 - Spring 2005
MIDTERM EAMINATION - CS130 - Spring 2005 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 231 + 25 extra credit This exam counts for 25%
More information8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES
CS-3304 Introduction In Text: Chapter 1 & 2 COURSE DESCRIPTION 2 What will you learn? Survey of programming paradigms, including representative languages Language definition and description methods Overview
More informationLECTURE 18. Control Flow
LECTURE 18 Control Flow CONTROL FLOW Sequencing: the execution of statements and evaluation of expressions is usually in the order in which they appear in a program text. Selection (or alternation): a
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationFunctional Languages. CSE 307 Principles of Programming Languages Stony Brook University
Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work
More informationConcepts of Programming Languages
Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014
More informationCOP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher
COP4020 ming Languages Compilers and Interpreters Robert van Engelen & Chris Lacher Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler
More informationQuestion No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given
MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -
More informationCMSC 331 Final Exam Section 0201 December 18, 2000
CMSC 331 Final Exam Section 0201 December 18, 2000 Name: Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for
More informationChapter 11 :: Functional Languages
Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative
More information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
More informationIntroduction. A. Bellaachia Page: 1
Introduction 1. Objectives... 2 2. Why are there so many programming languages?... 2 3. What makes a language successful?... 2 4. Programming Domains... 3 5. Language and Computer Architecture... 4 6.
More informationCS 360 Programming Languages Interpreters
CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like
More informationLECTURE 17. Expressions and Assignment
LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)
More informationChapter 15. Functional Programming Languages
Chapter 15 Functional Programming Languages Copyright 2009 Addison-Wesley. All rights reserved. 1-2 Chapter 15 Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationFunctional Programming. Pure Functional Programming
Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).
More informationCom S 541. Programming Languages I
Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR
More informationTDDD55 - Compilers and Interpreters Lesson 3
TDDD55 - Compilers and Interpreters Lesson 3 November 22 2011 Kristian Stavåker (kristian.stavaker@liu.se) Department of Computer and Information Science Linköping University LESSON SCHEDULE November 1,
More informationDocumentation for LISP in BASIC
Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have
More informationProgramming Languages Third Edition. Chapter 7 Basic Semantics
Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol
More informationWhy are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?
Chapter 1 :: Introduction Introduction Programming Language Pragmatics Michael L. Scott Why are there so many programming languages? evolution -- we've learned better ways of doing things over time socio-economic
More informationCS450 - Structure of Higher Level Languages
Spring 2018 Streams February 24, 2018 Introduction Streams are abstract sequences. They are potentially infinite we will see that their most interesting and powerful uses come in handling infinite sequences.
More informationOrganization of Programming Languages CS3200/5200N. Lecture 11
Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages
More informationCS 314 Principles of Programming Languages
CS 314 Principles of Programming Languages Lecture 16: Functional Programming Zheng (Eddy Zhang Rutgers University April 2, 2018 Review: Computation Paradigms Functional: Composition of operations on data.
More informationNOTE: Answer ANY FOUR of the following 6 sections:
A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)
More informationChapter 6 Control Flow. June 9, 2015
Chapter 6 Control Flow June 9, 2015 Expression evaluation It s common in programming languages to use the idea of an expression, which might be a simple object function invocation over some number of arguments
More informationPrinciples of Programming Languages. Lecture Outline
Principles of Programming Languages CS 492 Lecture 1 Based on Notes by William Albritton 1 Lecture Outline Reasons for studying concepts of programming languages Programming domains Language evaluation
More informationSemantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End
Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
More informationFunctional Programming
Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used
More informationTypes and Type Inference
CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of
More informationSOFTWARE ARCHITECTURE 6. LISP
1 SOFTWARE ARCHITECTURE 6. LISP Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ 2 Compiler vs Interpreter Compiler Translate programs into machine languages Compilers are
More informationCOMPILERS AND INTERPRETERS Lesson 4 TDDD16
COMPILERS AND INTERPRETERS Lesson 4 TDDD16 Kristian Stavåker (kristian.stavaker@liu.se) Department of Computer and Information Science Linköping University TODAY Introduction to the Bison parser generator
More informationSemantic Analysis. Lecture 9. February 7, 2018
Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average
More informationTopic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.
References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapter 5 of Programming languages: Concepts
More informationUNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division
UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division Fall, 2001 Prof. R. Fateman SUGGESTED S CS 164 Final Examination: December 18, 2001, 8-11AM
More informationOrganization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?
Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic
More informationContinuations provide a novel way to suspend and reexecute
Continuations provide a novel way to suspend and reexecute computations. 2. ML ( Meta Language ) Strong, compile-time type checking. Types are determined by inference rather than declaration. Naturally
More informationThe Structure of a Syntax-Directed Compiler
Source Program (Character Stream) Scanner Tokens Parser Abstract Syntax Tree Type Checker (AST) Decorated AST Translator Intermediate Representation Symbol Tables Optimizer (IR) IR Code Generator Target
More informationCompiler Construction D7011E
Compiler Construction D7011E Lecture 2: Lexical analysis Viktor Leijon Slides largely by Johan Nordlander with material generously provided by Mark P. Jones. 1 Basics of Lexical Analysis: 2 Some definitions:
More informationCST-402(T): Language Processors
CST-402(T): Language Processors Course Outcomes: On successful completion of the course, students will be able to: 1. Exhibit role of various phases of compilation, with understanding of types of grammars
More informationCOMPILER DESIGN LECTURE NOTES
COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:
More informationTest 1 Summer 2014 Multiple Choice. Write your answer to the LEFT of each problem. 5 points each 1. Preprocessor macros are associated with: A. C B.
CSE 3302 Test 1 1. Preprocessor macros are associated with: A. C B. Java C. JavaScript D. Pascal 2. (define x (lambda (y z) (+ y z))) is an example of: A. Applying an anonymous function B. Defining a function
More informationFunctional programming with Common Lisp
Functional programming with Common Lisp Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 81 Expressions and functions
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
More informationChapter 1. Preliminaries
Chapter 1 Preliminaries Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language
More informationProgramming Languages 2nd edition Tucker and Noonan"
Programming Languages 2nd edition Tucker and Noonan" " Chapter 1" Overview" " A good programming language is a conceptual universe for thinking about programming. " " " " " " " " " " " " "A. Perlis" "
More informationThe role of semantic analysis in a compiler
Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
More informationINF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals
INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Common Lisp Fundamentals Stephan Oepen & Murhaf Fares Language Technology Group (LTG) August 30, 2017 Last Week: What is
More informationChapter 1. Preliminaries
Chapter 1 Preliminaries Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language
More informationTypes and Type Inference
Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion
More informationFunctional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More informationFunctional abstraction
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationStating the obvious, people and computers do not speak the same language.
3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what
More informationCompiling and Interpreting Programming. Overview of Compilers and Interpreters
Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Overview of Compilers and Interpreters Common compiler and interpreter configurations Virtual machines Integrated programming environments
More informationEarly computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed
Chapter 1 :: Programming Language Pragmatics Michael L. Scott Early computers (1940s) cost millions of dollars and were programmed in machine language machine s time more valuable than programmer s machine
More informationImplementing Coroutines with call/cc. Producer/Consumer using Coroutines
Implementing Coroutines with call/cc Producer/Consumer using Coroutines Coroutines are a very handy generalization of subroutines. A coroutine may suspend its execution and later resume from the point
More informationCS101 Introduction to Programming Languages and Compilers
CS101 Introduction to Programming Languages and Compilers In this handout we ll examine different types of programming languages and take a brief look at compilers. We ll only hit the major highlights
More informationImperative Programming Languages (IPL)
Imperative Programming Languages (IPL) Definitions: The imperative (or procedural) paradigm is the closest to the structure of actual computers. It is a model that is based on moving bits around and changing
More informationProgramming Language Pragmatics
Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken Alan Turing, Alonzo Church, Stephen
More informationTopic IV. Block-structured procedural languages Algol and Pascal. References:
References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapters 10( 2) and 11( 1) of Programming
More informationFunctional Languages. Hwansoo Han
Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm
More informationDefining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1
Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind
More informationGeneral Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design
General Concepts Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design 1 Abstractions in Programming Languages Abstractions hide details that
More informationPage # Expression Evaluation: Outline. CSCI: 4500/6500 Programming Languages. Expression Evaluation: Precedence
Expression Evaluation: Outline CSCI: 4500/6500 Programming Languages Control Flow Chapter 6 Infix, Prefix or Postfix Precedence and Associativity Side effects Statement versus Expression Oriented Languages
More informationType Systems, Type Inference, and Polymorphism
6 Type Systems, Type Inference, and Polymorphism Programming involves a wide range of computational constructs, such as data structures, functions, objects, communication channels, and threads of control.
More informationGrade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline
Grade Weights Language Design and Overview of COOL CS143 Lecture 2 Project 0% I, II 10% each III, IV 1% each Midterm 1% Final 2% Written Assignments 10% 2.% each Prof. Aiken CS 143 Lecture 2 1 Prof. Aiken
More informationCS 415 Midterm Exam Spring 2002
CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationFall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives
CS 6A Scheme Fall 208 Discussion 8: October 24, 208 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write
More informationFifth Generation CS 4100 LISP. What do we need? Example LISP Program 11/13/13. Chapter 9: List Processing: LISP. Central Idea: Function Application
Fifth Generation CS 4100 LISP From Principles of Programming Languages: Design, Evaluation, and Implementation (Third Edition, by Bruce J. MacLennan, Chapters 9, 10, 11, and based on slides by Istvan Jonyer
More informationScheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7
Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions
More informationCS 342 Lecture 7 Syntax Abstraction By: Hridesh Rajan
CS 342 Lecture 7 Syntax Abstraction By: Hridesh Rajan 1 Reading SICP, page 11-19, Section 1.1.6 Little Schemer, Chapter 2 2 The Idea of Syntax Abstraction Problem. Often programming tasks are repetitive,
More informationWhen do We Run a Compiler?
When do We Run a Compiler? Prior to execution This is standard. We compile a program once, then use it repeatedly. At the start of each execution We can incorporate values known at the start of the run
More informationTopic 1: Introduction
Recommended Exercises and Readings Topic 1: Introduction From Haskell: The craft of functional programming (3 rd Ed.) Readings: Chapter 1 Chapter 2 1 2 What is a Programming Paradigm? Programming Paradigm:
More informationScheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.
Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu
More informationSemantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far
Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Statically vs. Dynamically typed languages
More informationFunctional Programming. Pure Functional Languages
Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure
More informationLambda Calculus see notes on Lambda Calculus
Lambda Calculus see notes on Lambda Calculus Shakil M. Khan adapted from Gunnar Gotshalks recap so far: Lisp data structures basic Lisp programming bound/free variables, scope of variables Lisp symbols,
More informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False
More informationCSE413 Midterm. Question Max Points Total 100
CSE413 Midterm 05 November 2007 Name Student ID Answer all questions; show your work. You may use: 1. The Scheme language definition. 2. One 8.5 * 11 piece of paper with handwritten notes Other items,
More informationWeek 2: The Clojure Language. Background Basic structure A few of the most useful facilities. A modernized Lisp. An insider's opinion
Week 2: The Clojure Language Background Basic structure A few of the most useful facilities A modernized Lisp Review of Lisp's origins and development Why did Lisp need to be modernized? Relationship to
More informationControl in Sequential Languages
CS 242 2012 Control in Sequential Languages Reading: Chapter 8, Sections 8.1 8.3 (only) Section 7.3 of The Haskell 98 Report, Exception Handling in the I/O Monad, http://www.haskell.org/onlinelibrary/io-13.html
More informationMIDTERM EXAMINATION - CS130 - Spring 2003
MIDTERM EXAMINATION - CS130 - Spring 2003 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 120 + 10 extra credit This exam counts for
More informationCompilers. Prerequisites
Compilers Prerequisites Data structures & algorithms Linked lists, dictionaries, trees, hash tables Formal languages & automata Regular expressions, finite automata, context-free grammars Machine organization
More informationMIDTERM EXAM (Solutions)
MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and
More informationUniversity of Massachusetts Lowell
University of Massachusetts Lowell 91.301: Organization of Programming Languages Fall 2002 Quiz 1 Solutions to Sample Problems 2 91.301 Problem 1 What will Scheme print in response to the following statements?
More informationUser-defined Functions. Conditional Expressions in Scheme
User-defined Functions The list (lambda (args (body s to a function with (args as its argument list and (body as the function body. No quotes are needed for (args or (body. (lambda (x (+ x 1 s to the increment
More information