Adv. Course in Programming Languages
|
|
- Beryl Elliott
- 5 years ago
- Views:
Transcription
1 Department of Computer Science, University of Tsukuba No.3
2 How to write Code Generator for Power? In your favorite programming language!! C, C++ (with template), C# Fortran Lisp, Scheme, Clojure Java, Scala Perl, Python, Ruby, JavaScript SML, OCaml, F#, MetaOCaml Haskell (with template) Prolog etc. etc. Red ones have supports for quasiquotation or code generation.
3 How to write Code Generator for Power? In your favorite programming language!! C, C++ (with template), C# Fortran Lisp, Scheme, Clojure Java, Scala Perl, Python, Ruby, JavaScript SML, OCaml, F#, MetaOCaml Haskell (with template) Prolog etc. etc. Red ones have supports for quasiquotation or code generation.
4 Staged Power in Various Languages In the May 19th class: Oishi-kun s solution in Haskell (with template) Mano-kun s solution in Java (with string) Tanaka-kun s solution in C++ (with template) Yamaguchi-kun s solution in Terra and Lua
5 Staged Power in MetaOCaml let rec power n x = if n = 1 then x else x * (power (n-1) x)
6 Staged Power in MetaOCaml let rec power n x = if n = 1 then x else x * (power (n-1) x) let rec staged_power n x = if n = 1 then x else.<.~x *.~(staged_power (n-1).<x>.) >.
7 Staged Power in MetaOCaml let rec power n x = if n = 1 then x else x * (power (n-1) x) let rec staged_power n x = if n = 1 then x else.<.~x *.~(staged_power (n-1).<x>.) >. staged_power 3.<5>. =>.<.~<5>. *.~(staged_power 2.<5>. ) >. =>.< 5 *.~(staged_power 2.<5>. ) >.... =>.<5 * (5 * 5)>.
8 Computation in MetaOCaml Code in brackets are (usually) not evaluated:.<1 + 2>. reduces to.<1 + 2>. (not computed) But escaped expression in brackets are evaluated: let x =.<3 + 4>. in.<1 +.~x * 2>. =>.<1 +.~(.<3+4>.) * 2)>. =>.<1 + (3+4) * 2)>. And that s all!
9 Another Example of Program Generation Matrix-vector multiplication: a a 1n b 1 c =... a m1... a mn b n c m where c i = Σ 1 j n a ij b j
10 Another Example of Program Generation Matrix-vector multiplication: a a 1n b 1 c =... a m1... a mn b n c m where or c i = Σ 1 j n a ij b j c(i) = Σ 1 j n a(i, j) b(j)
11 Implementing matrix-vector multiplication let mvmul nrow ncol mat1 vec1 vec2 = for i = 0 to nrow - 1 do let tmp = ref 0.0 in for j = 0 to ncol - 1 do tmp :=!tmp +. mat1.(i * ncol + j) *. vec1.(j) done; vec2.(i) <-!tmp done OCaml specific: for i = 0 to n-1 do.. done for for-loop. let tmp = ref 0.0 for creating mutable cell.! tmp for the value in tmp. ary.(e) for the e-th element of array.
12 How to write a program generator? First of all, we need to know, which data are known statically. Situation 1: we don t know anything. Situation 2: we know the size of matrix/vector, but don t know the elements of matrix/vector. Situation 3: we know the size of matrix/vector and the matrix elements, but don t know vector elements. Situation 3 : (switch matrix/vector) Situation 4: we know everything. Program generation is effective for situations 2 and 3, where we know something and don t know something. But, sometimes, we can still use Program Generation techniques in Situation 1 (next page).
13 How to write a program generator? We know nothing about the data, but know the architecture of our machine. cache size; if we know the cache size, we can divide a very large matrix into small components which fit in the cache. target CPU; if we know the CPU has some special instruction such as vector instructions, we may generate an efficient code using them. Then we can still generate an efficient code suitable for each particular architecture.
14 Matrix-Vector Multiplication; Scenario 1 Suppose we know the size of matrix/vector, but don t know their elements. Also assume that the size is not too large. let mvmuls1 nrow ncol mat1 vec1 vec2 = gen_for 0 (nrow - 1) (fun row ->.<let tmp = ref 0.0 in begin.~(gen_for 0 (ncol - 1) (fun col ->.<tmp :=!tmp +. (.~mat1).(row * ncol + col) *. (.~vec1).(col)>.)); (.~vec2).(row) <-!tmp end>.)
15 Matrix-Vector Multiplication; Scenario 1 A helper function: let gen_for init fin loop_body =... in gen_for 1 3 (fun i ->.<foo i>.) ==>.<foo 1; foo 2; foo 3>.
16 Matrix-Vector Multiplication; Scenario 1 Generated code: mvmul1 =.<fun x_201 y_202 z_203 -> let tmp_208 = ref 0.0 in tmp_208 :=! tmp_ x_201.(0 * 6 + 0) *. y_202.(0); tmp_208 :=! tmp_ x_201.(0 * 6 + 1) *. y_202.(1); tmp_208 :=! tmp_ x_201.(0 * 6 + 2) *. y_202.(2); tmp_208 :=! tmp_ x_201.(0 * 6 + 3) *. y_202.(3); tmp_208 :=! tmp_ x_201.(0 * 6 + 4) *. y_202.(4); tmp_208 :=! tmp_ x_201.(0 * 6 + 5) *. y_202.(5); (); z_203.(0) <-! tmp_208;...>. Completely unrolling the loop.
17 Matrix-Vector Multiplication; Scenario 1 We can do better; to pre-compute the index 0*6+0 etc.... let idx = row * ncol + col in.<tmp :=!tmp +. (.~mat1).(idx) *. (.~vec1).(col)>.));... The value of idx is computed at the time of code generation, and its result is embedded into the code.
18 Matrix-Vector Multiplication; Scenario 1 Generated code: tmp_208 :=! tmp_ x_201.(0 * 6 + 0) *. y_202.(0); mvmul1 =.<fun x_201 y_202 z_203 -> mvmul2 =.<fun x_209 y_210 z_211 ->... tmp_216 :=! tmp_ x_209.(0) *. y_210.(0);...
19 Matrix-Vector Multiplication; Scenario 2 Suppose we know the size of matrix/vector and the elements of matrix, but don t know the elements of vector. Again, we assume that the size is not too large. let mvmuls3 nrow ncol mat1 vec1 vec2 =... let v = mat1.(row * ncol + col) in.<tmp :=!tmp +. v *. (.~vec1).(col)>.));... Now mat1 is static, and vec1 remains dynamic.
20 Matrix-Vector Multiplication; Scenario 2 Generated code: val mvmul3 =.<fun x_217 y_218 -> let tmp_223 = ref 0.0 in tmp_223 :=! tmp_ *. x_217.(0); tmp_223 :=! tmp_ *. x_217.(1); tmp_223 :=! tmp_ *. x_217.(2); tmp_223 :=! tmp_ *. x_217.(3); tmp_223 :=! tmp_ *. x_217.(4); tmp_223 :=! tmp_ *. x_217.(5); (); y_218.(0) <-! tmp_223;...>.
21 Matrix-Vector Multiplication; Scenario 2 If the matrix contains many occurrences of 0.0 and 1.0, then we want to optimize v * 1.0 to v, v * 0.0 to 0.0 and v to v. Generated code: val mvmul4 =.<fun mat1 x_255 y_256 -> (let tmp_261 = Pervasives.ref 0.0 in (tmp_261 := ((! tmp_261) +. (x_255.(0))); (); (); (); y_256.(0) <-! tmp_261);... ()>. These optimization can be done by the compiler, so in an ordinary program we do not have to care about them. But in program generation, we MUST avoid code explosion, that is, generating too large code.
22 Matrix-Vector Multiplication; Scenario 3 We can have other scenarios such as: size and matrix elements are known, vector elements are unknown. the matrix is too large, and we don t want to fully unroll the loop (to avoid code explosion). for a row which has less than four non-zero elements, we want to unroll it. Otherwise, we keep the for-loop as it is. Idealized Generated code: val mvmul5 =.<fun mat1 vec1 vec2 -> vec2.(0) <- 2.0 *. vec1.(2) *. vec1.(4) * vec2.(1) <- 6.0 *. vec1.(0) *. vec1.(1); let tmp = ref 0.0 in for col = 0 to 5 do tmp :=! tmp +. (mat1.(12 + col) *. vec1.(col); done; vec2.(2) <- tmp
23 Automatic vs Hand-Written Fully automatic; compilers, partial evaluators easy for programmers relatively easy to establish the correctness uniform optimization is not quite optimal for each specific domain Hand-written; staged computation hard for programmers relatively hard to establish the correctness domain-specific optimization
24 Automatic vs Hand-Written Should we write everything by hand? YES, for custom optimization. No, for automatic staging (partial evaluation).
25 Exercise Write a code-generator in your favorite programming language: C++ template Ruby (using eval function) MetaOCaml (3rd week) Scala (lightweight modular staging, 4th week) or others (any language is ok) Example application: power function, matrix multiplication, gibonacci function (x, y, x + y, x + 2y, 2x + 3y, ) Send your answer file by to me before 5th week s class, and give a presentation about it in the class.
Concepts in Programming Languages
Concepts in Programming Languages Marcelo Fiore Computer Laboratory University of Cambridge 2012 2013 (Easter Term) 1 Practicalities Course web page: with lecture
More informationKey components of a lang. Deconstructing OCaml. In OCaml. Units of computation. In Java/Python. In OCaml. Units of computation.
Key components of a lang Deconstructing OCaml What makes up a language Units of computation Types Memory model In OCaml Units of computation In OCaml In Java/Python Expressions that evaluate to values
More informationLast time: generic programming
1/ 45 Last time: generic programming val show : a data a string 2/ 45 This time: staging.< e >. 3/ 45 Review: abstraction Lambda abstraction λx : A.M ΛA :: K.M λa :: K.B Abstraction of type equalities
More informationMeta-Programming and JIT Compilation
Meta-Programming and JIT Compilation Sean Treichler 1 Portability vs. Performance Many scientific codes sp ~100% of their cycles in a tiny fraction of the code base We want these kernels to be as fast
More informationTopic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.
Topic I Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapter 1 of Programming languages: Design and implementation (3RD EDITION)
More informationOutline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context
Types 1 / 15 Outline Introduction Concepts and terminology The case for static typing Implementing a static type system Basic typing relations Adding context 2 / 15 Types and type errors Type: a set of
More informationType Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones
Type Inference Prof. Clarkson Fall 2016 Today s music: Cool, Calm, and Collected by The Rolling Stones Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax Formal semantics
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 informationCSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016
CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Spring 2016 Type-checking (Static) type-checking can reject a program before it runs to prevent the possibility of some errors A feature
More informationSKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)
SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2
More informationBack to OCaml. Summary of polymorphism. Example 1. Type inference. Example 2. Example 2. Subtype. Polymorphic types allow us to reuse code.
Summary of polymorphism Subtype Parametric Bounded F-bounded Back to OCaml Polymorphic types allow us to reuse code However, not always obvious from staring at code But... Types never entered w/ program!
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 informationProgramming (ERIM) Lecture 1: Introduction to programming paradigms and typing systems. Tommi Tervonen
Programming (ERIM) Lecture 1: Introduction to programming paradigms and typing systems Tommi Tervonen Econometric Institute, Erasmus School of Economics Course learning objectives After this course, you
More informationComputational Effects across Generated Binders Part 1: Problems and solutions
Computational Effects across Generated Binders Part 1: Problems and solutions Yukiyoshi Kameyama Oleg Kiselyov Chung-chieh Shan University of Tsukuba TBD IFIP WG2.11 September 5, 2011 1 Outline Problems
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 informationTopics Covered Thus Far CMSC 330: Organization of Programming Languages
Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free
More informationFunctional Programming Principles in Scala. Martin Odersky
Functional Programming Principles in Scala Martin Odersky Programming Paradigms Paradigm: In science, a paradigm describes distinct concepts or thought patterns in some scientific discipline. Main programming
More informationCMSC330. Objects, Functional Programming, and lambda calculus
CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed
More informationMetaprogramming assignment 3
Metaprogramming assignment 3 Optimising embedded languages Due at noon on Thursday 29th November 2018 This exercise uses the BER MetaOCaml compiler, which you can install via opam. The end of this document
More informationCOMP 201: Principles of Programming
COMP 201: Principles of Programming 1 Learning Outcomes To understand what computing entails and what the different branches of computing are. To understand the basic design of a computer and how it represents
More informationMetaprogramming. CS315B Lecture 7
Metaprogramming CS315B Lecture 7 Prof. Aiken CS 315B Lecture 7 1 Projects Time to start thinking about projects! A regent program/library of your choosing List of suggested projects will be published later
More informationRobot Programming with Lisp
4. Functional Programming: Higher-order Functions, Map/Reduce, Lexical Scope Institute for Artificial University of Bremen 9 of November, 2017 Functional Programming Pure functional programming concepts
More informationEnvironments
Environments PLAI Chapter 6 Evaluating using substitutions is very inefficient To work around this, we want to use a cache of substitutions. We begin evaluating with no cached substitutions, then collect
More informationMonday Feb 16, 5pm. solve these equalities. Midterm Thursday Feb 12. covers only ocaml part of the course, assignments 1 through 3.
News Programming Assignment 4 is up, due Monday Feb 16, 5pm Long assignment, start early Midterm Thursday Feb 12 covers only ocaml part of the course, assignments 1 through 3. Recap: Inferring types Introduce
More informationThe Design and Implementation of BER MetaOCaml
The Design and Implementation of BER MetaOCaml System Description http://okmij.org/ftp/ml/metaocaml.html FLOPS 2014 June 4, 2014 MetaOCaml is a superset of OCaml extending it with the data type for program
More informationCS457/557 Functional Languages
CS457/557 Functional Languages Spring 2018 Lecture 1: Course Introduction Andrew Tolmach Portland State University (with thanks to Mark P. Jones) 1 Goals of this course Introduce the beautiful ideas of
More informationWhat if Type Systems were more like Linters?
Typed Clojure An optional type system for Clojure What if Type Systems were more like Linters? Ambrose Bonnaire-Sergeant Me A Practical Optional Type System for Clojure (2012) Typed Clojure Indiegogo Campaign
More informationCOSE212: Programming Languages. Lecture 4 Recursive and Higher-Order Programming
COSE212: Programming Languages Lecture 4 Recursive and Higher-Order Programming Hakjoo Oh 2016 Fall Hakjoo Oh COSE212 2016 Fall, Lecture 4 September 27, 2016 1 / 21 Recursive and Higher-Order Programming
More informationType Checking and Type Inference
Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled
More informationCSCI 2041: Tail Recursion and Activation Records
CSCI 2041: Tail Recursion and Activation Records Chris Kauffman Last Updated: Fri Sep 21 14:31:59 CDT 2018 1 Logistics Reading OCaml System Manual: 25.2 (Pervasives Modules) Practical OCaml: Ch 3, 9 Wikipedia:
More informationTypes, Type Inference and Unification
Types, Type Inference and Unification Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Cornell CS 6110 Summary (Functional Programming) Lambda Calculus Basic ML Advanced ML: Modules, References,
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 informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All
More informationTopic 9: Type Checking
Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and
More informationTopic 9: Type Checking
Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6
More informationL3 Programming September 19, OCaml Cheatsheet
OCaml Cheatsheet Note: this document comes from a previous course (by Sylvain Schimdt). The explanations of the OCaml syntax in this sheet are by no means intended to be complete or even sufficient; check
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 informationCS115 - Module 9 - filter, map, and friends
Fall 2017 Reminder: if you have not already, ensure you: Read How to Design Programs, Intermezzo 3 (Section 18); Sections 19-23. Abstraction abstraction, n. 3a.... The process of isolating properties or
More informationParallelizing The Matrix Multiplication. 6/10/2013 LONI Parallel Programming Workshop
Parallelizing The Matrix Multiplication 6/10/2013 LONI Parallel Programming Workshop 2013 1 Serial version 6/10/2013 LONI Parallel Programming Workshop 2013 2 X = A md x B dn = C mn d c i,j = a i,k b k,j
More informationCSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)
CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent
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 informationIntroduction to Functional Programming and Haskell. Aden Seaman
Introduction to Functional Programming and Haskell Aden Seaman Functional Programming Functional Programming First Class Functions Expressions (No Assignment) (Ideally) No Side Effects Different Approach
More informationLecture 1: Course Introduction
Lecture 1: Course Introduction CS164: Programming Languages and Compilers P. N. Hilfinger, 787 Soda Spring 2015 Acknowledgement. Portions taken from CS164 notes by G. Necula. Last modified: Wed Jan 21
More informationCS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106
CS 565: Programming Languages Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 Administrivia Who am I? Course web page http://www.cs.purdue.edu/homes/peugster/cs565spring08/ Office hours By appointment Main
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 informationLecture 7. Memory in Python
Lecture 7 Memory in Python Announcements For This Lecture Readings Reread Chapter 3 No reading for Thursday Lab Work on Assignment Credit when submit A Nothing else to do Assignment Moved to Fri, Sep.
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
More informationMySQL. The Right Database for GIS Sometimes
MySQL The Right Database for GIS Sometimes Who am I? Web/GIS Software Engineer with Cimbura.com BS in IT, MGIS Michael Moore I like making and using tools (digital or physical) GIS Web Services I m most
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 informationCSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN
What languages do you know? CSC 326H1F, Programming Languages The usual suspects: C, C++, Java fine languages nearly the same Perhaps you've also learned some others? assembler Basic, Visual Basic, Turing,
More informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory
More informationMASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science. Issued: Wed. 26 April 2017 Due: Wed.
ps.txt Fri Apr 07 14:24:11 2017 1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.945 Spring 2017 Problem Set 9 Issued: Wed. 26 April 2017 Due: Wed. 12
More informationTYPES OF PROGRAMMING LANGUAGES
TYPES OF PROGRAMMING LANGUAGES PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/30 REASONS TO CHOOSE A PARTICULAR PROGRAMMING LANGUAGE 2/30 REASONS TO CHOOSE A PARTICULAR
More informationCOSC252: Programming Languages: Basic Semantics: Data Types. Jeremy Bolton, PhD Asst Teaching Professor
COSC252: Programming Languages: Basic Semantics: Data Types Jeremy Bolton, PhD Asst Teaching Professor Copyright 2015 Pearson. All rights reserved. Common Types and Design Concerns Primitive Data Types
More informationCOSE212: Programming Languages. Lecture 3 Functional Programming in OCaml
COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of
More informationCIS 120 Midterm II November 8, 2013 SOLUTIONS
CIS 120 Midterm II November 8, 2013 SOLUTIONS 1 1. Facts about OCaml and Java (15 points) For each part, circle true or false. a. T F The.equals method in Java is roughly similar to OCaml s = operator.
More informationSo what does studying PL buy me?
So what does studying PL buy me? Enables you to better choose the right language but isn t that decided by libraries, standards, and my boss? Yes. Chicken-and-egg. My goal: educate tomorrow s tech leaders
More informationFunctional Programming Lecture 1: Introduction
Functional Programming Lecture 1: Introduction Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz Acknowledgements
More informationCS 3110 Lecture 1 Course Overview
CS 3110 Lecture 1 Course Overview Ramin Zabih Cornell University CS Fall 2010 www.cs.cornell.edu/courses/cs3110 Course staff Professor: Ramin Zabih Graduate TA s: Joyce Chen, Brian Liu, Dane Wallinga Undergraduate
More informationIntroduction to Multicore Programming
Introduction to Multicore Programming Minsoo Ryu Department of Computer Science and Engineering 2 1 Multithreaded Programming 2 Automatic Parallelization and OpenMP 3 GPGPU 2 Multithreaded Programming
More informationFunctional Programming
The Meta Language (ML) and Functional Programming Daniel S. Fava danielsf@ifi.uio.no Department of informatics University of Oslo, Norway Motivation ML Demo Which programming languages are functional?
More informationCIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL
CIS 194: Homework 3 Due Wednesday, February 11, 2015 Interpreters An interpreter is a program that takes another program as an input and evaluates it. Many modern languages such as Java 1, Javascript,
More informationCompilation 2012 The What and Why of Compilers
Compilation 2012 The What and Why of Compilers Jan Midtgaard Michael I. Schwartzbach Aarhus University What is a Compiler? A program that: tralates from one programming language to another preserves the
More informationWeek 9 Part 1. Kyle Dewey. Tuesday, August 28, 12
Week 9 Part 1 Kyle Dewey Overview Dynamic allocation continued Heap versus stack Memory-related bugs Exam #2 Dynamic Allocation Recall... Dynamic memory allocation allows us to request memory on the fly
More informationChapter 6 part 1. Data Types. (updated based on 11th edition) ISBN
Chapter 6 part 1 Data Types (updated based on 11th edition) ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative
More informationCSE 374: Programming Concepts and Tools. Eric Mullen Spring 2017 Lecture 4: More Shell Scripts
CSE 374: Programming Concepts and Tools Eric Mullen Spring 2017 Lecture 4: More Shell Scripts Homework 1 Already out, due Thursday night at midnight Asks you to run some shell commands Remember to use
More informationCSci 4223 Lecture 18 April 3, 2013 Topics: OOP vs. FP
CSci 4223 Lecture 18 April 3, 2013 Topics: OOP vs. FP 1 Object-oriented programming vs. functional programming We ve now seen the core features of both OOP and FP. Let s compare the two paradigms, and
More informationScope. Chapter Ten Modern Programming Languages 1
Scope Chapter Ten Modern Programming Languages 1 Reusing Names Scope is trivial if you have a unique name for everything: fun square a = a * a; fun double b = b + b; But in modern languages, we often use
More informationProgramming Systems in Artificial Intelligence Functional Programming
Click to add Text Programming Systems in Artificial Intelligence Functional Programming Siegfried Nijssen 8/03/16 Discover thediscover world at the Leiden world University at Leiden University Overview
More informationCS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013
CS252 Advanced Programming Language Principles Prof. Tom Austin San José State University Fall 2013 What are some programming languages? Why are there so many? Different domains Mobile devices (Objective
More informationmax function Next concat function max function What s the pattern? concat function More on recursion Higher-order functions
Next More on recursion Higher-order functions taking and returning functions max function let max x y = if x < y then y else x;; (* return max element of list l *) Along the way, will see map and fold
More informationProgramming 2. Object Oriented Programming. Daniel POP
Programming 2 Object Oriented Programming Daniel POP Week 4 Agenda 1. Self-reference 2. Modifiers: static 3. Modifiers: const 4. Modifiers: mutable 5. Modifiers: friend Wrap-up last week Constructors Definition:
More informationOCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java
OCaml Data : Organization of Programming Languages OCaml 4 Data Types & Modules So far, we ve seen the following kinds of data Basic types (int, float, char, string) Lists Ø One kind of data structure
More informationChapter 8. Statement-Level Control Structures
Chapter 8 Statement-Level Control Structures Chapter 8 Topics Introduction Selection Statements Iterative Statements Unconditional Branching Guarded Commands Conclusions 1-2 Levels of Control Flow Within
More information! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented
Course Goal CMSC 330: Organization of Programming Languages Introduction Learn how programming languages work Broaden your language horizons! Different programming languages! Different language features
More informationModern Stored Procedures Using GraalVM
Modern Stored Procedures Using raalvm Oracle Labs Matthias Brantner Safe Harbor Statement The following is intended to outline our general product direction. t is intended
More informationUsing Scala in CS241
Using Scala in CS241 Winter 2018 Contents 1 Purpose 1 2 Scala 1 3 Basic Syntax 2 4 Tuples, Arrays, Lists and Vectors in Scala 3 5 Binary output in Scala 5 6 Maps 5 7 Option types 5 8 Objects and Classes
More informationSpring 2018 PhD Qualifying Exam in Languages
Spring 2018 PhD Qualifying Exam in Languages Illinois Institute of Technology Department of Computer Science Monday, January 29, 2018 Instructions This exam is closed book and closed notes. Read each problem
More informationCenter for Scalable Application Development Software (CScADS): Automatic Performance Tuning Workshop
Center for Scalable Application Development Software (CScADS): Automatic Performance Tuning Workshop http://cscads.rice.edu/ Discussion and Feedback CScADS Autotuning 07 Top Priority Questions for Discussion
More informationProgramming (Econometrics)
Programming (Econometrics) Lecture 1: Introduction Tommi Tervonen Econometric Institute, Erasmus University Rotterdam Course learning objectives After this course, you should be able to: Program econometrical
More informationPrograms as data first-order functional language type checking
Programs as data first-order functional language type checking Copyright 2013-18, Peter Sestoft and Cesare Tinelli. Created by Cesare Tinelli at the University of Iowa from notes originally developed by
More informationProgramming Languages, Summary CSC419; Odelia Schwartz
Programming Languages, Summary CSC419; Odelia Schwartz Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design
More informationIntroduction to Multicore Programming
Introduction to Multicore Programming Minsoo Ryu Department of Computer Science and Engineering 2 1 Multithreaded Programming 2 Synchronization 3 Automatic Parallelization and OpenMP 4 GPGPU 5 Q& A 2 Multithreaded
More informationLecture 8: Summary of Haskell course + Type Level Programming
Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell
More informationIA010: Principles of Programming Languages
IA010 5. Subroutines 1 IA010: Principles of Programming Languages 5. Subroutines Jan Obdržálek obdrzalek@fi.muni.cz Faculty of Informatics, Masaryk University, Brno Subroutines IA010 5. Subroutines 2 Subprograms,
More informationIntroduction to Scientific Computing Languages
1 / 1 Introduction to Scientific Computing Languages Prof. Paolo Bientinesi pauldj@aices.rwth-aachen.de Languages for Scientific Computing 2 / 1 What is a programming language? Languages for Scientific
More informationAbram Hindle Kitchener Waterloo Perl Monger October 19, 2006
OCaml Tutorial Abram Hindle Kitchener Waterloo Perl Monger http://kw.pm.org abez@abez.ca October 19, 2006 Abram Hindle 1 OCaml Functional Language Multiple paradigms: Imperative, Functional, Object Oriented
More informationHi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE : Fall 2017
Hi! My name is Sorin CSE 130-230 : Fall 2017 Programming Languages Sorin Lerner UC San Diego Why study PL? (discussion) Why study PL? A different language is a different vision of life - Fellini - Hypothesis:
More informationCMSC 330: Organization of Programming Languages. Functional Programming with OCaml
CMSC 330: Organization of Programming Languages Functional Programming with OCaml 1 What is a functional language? A functional language: defines computations as mathematical functions discourages use
More informationMint: A Multi-stage Extension of Java. COMP 600 Mathias Ricken Rice University February 8, 2010
Mint: A Multi-stage Extension of Java COMP 600 Mathias Ricken Rice University February 8, 2010 Multi-stage Programming Multi-stage programming (MSP) languages Provide constructs for program generation
More informationOutline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples
Outline Introduction to Programming (in C++) Introduction Programming examples Algorithms, programming languages and computer programs Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer
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 informationVariables. Substitution
Variables Elements of Programming Languages Lecture 4: Variables, binding and substitution James Cheney University of Edinburgh October 6, 2015 A variable is a symbol that can stand for another expression.
More informationDesign Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8
Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns
More informationIntroduction to Scientific Computing Languages
1 / 17 Introduction to Scientific Computing Languages Prof. Paolo Bientinesi pauldj@aices.rwth-aachen.de Languages for Scientific Computing 2 / 17 What is a programming language? Languages for Scientific
More informationCompiler Design Spring 2018
Compiler Design Spring 2018 Thomas R. Gross Computer Science Department ETH Zurich, Switzerland 1 Logistics Lecture Tuesdays: 10:15 11:55 Thursdays: 10:15 -- 11:55 In ETF E1 Recitation Announced later
More informationWeeks 6&7: Procedures and Parameter Passing
CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45
More informationLab #10 Multi-dimensional Arrays
Multi-dimensional Arrays Sheet s Owner Student ID Name Signature Group partner 1. Two-Dimensional Arrays Arrays that we have seen and used so far are one dimensional arrays, where each element is indexed
More informationCMSC 430 Introduction to Compilers. Fall Everything (else) you always wanted to know about OCaml (but were afraid to ask)
CMSC 430 Introduction to Compilers Fall 2015 Everything (else) you always wanted to know about OCaml (but were afraid to ask) OCaml You know it well from CMSC 330 All programming projects will be in OCaml
More informationThe Haskell HOP: Higher-order Programming
The Haskell HOP: Higher-order Programming COS 441 Slides 6 Slide content credits: Ranjit Jhala, UCSD Agenda Haskell so far: First-order functions This time: Higher-order functions: Functions as data, arguments
More information