Dependent Types for JavaScript

Size: px
Start display at page:

Download "Dependent Types for JavaScript"

Transcription

1 Dependent Types for JavaScript Ravi Chugh Ranjit Jhala University of California, San Diego David Herman Mozilla Research

2 Dependent Why Types for JavaScript? Pervasive Used at Massive Scale

3 Why Add Types? var x = {}; x.f; x.f.f; produces undefined rather than error but this raises TypeError 3

4 Why Add Types? var x = {}; x.f; x.f.f; There Are Run- Gme Errors reading from undefined, applying non- funcgon values, Worse: Browsers Hide Them! 4

5 Why Add Types? Prevent Errors Prevent the Unexpected 5

6 Okay, But Who Cares? Programmers JSLint, Closure Compiler, TypeScript, Dart Browser Vendors Compete based on performance, security, reliability Standards CommiSees AcGvely evolving JavaScript and Web standards 6

7 Dependent Why Types for JavaScript? Isn t the Language Terrible?

8 JavaScript scope manipulagon implicit global object var liying,,, == new Array(4) 8

9 JavaScript scope manipulagon implicit global object objects type- tests prototypes lambdas var liying,,, == new Array(4) 9

10 JavaScript scope manipulagon The Good Parts implicit global object objects type- tests prototypes lambdas var liying,,, == new Array(4) 10

11 JavaScript The Good Parts Our Approach Prior Type Systems Key Idea: Use Logic! 11

12 JavaScript The Good Parts DJS Dependent JavaScript 12

13 Outline MoGvaGon Our Approach: Logic! EvaluaGon 13

14 typeof true // boolean typeof 0.1 typeof 0 // number // number typeof {} // object typeof [] // object typeof null // object 14

15 typeof returns run- Gme tags Tags are very coarse- grained types undefined boolean string number object function 15

16 Refinement Types { x p } set of values x s.t. formula p is true Num NumOrBool Int { n tag(n) = number } { v tag(v) = number tag(v) = boolean } { i tag(i) = number integer(i) } Any { x true } 16

17 Refinement Types SyntacGc Sugar for Common Types Num NumOrBool Int { n tag(n) = number } { v tag(v) = number tag(v) = boolean } { i tag(i) = number integer(i) } Any { x true } 17

18 Refinement Types 3 :: { n n = 3 } 3 :: { n n > 0 } 3 :: { n tag(n) = number integer(n) } 3 :: { n tag(n) = number } 18

19 Refinement Types Subtyping is ImplicaGon <: <: <: <: { n n = 3 } { n n > 0 } { n tag(n) = number integer(n) } { n tag(n) = number } 19

20 Refinement Types Subtyping is ImplicaGon { n n = 3 } { n n > 0 } { n tag(n) = number integer(n) } { n tag(n) = number } 20

21 Tag- Tests Duck Typing Mutable Objects 21

22 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!true!x; // false else return 0 - x; } negate( true ) 22

23 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!x; else return 0-2 x; // -2 } negate( 2 ) 23

24 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!x; else WAT?! return 0 - [] x; // 0 } negate( [] ) 24

25 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!x; else return 0 - x; } Use types to prevent implicit coercion (-) :: (Num,Num) Num 25

26 Tag- Tests Duck Typing Mutable Objects //: negate :: (x:any) Any var negate = function(x) { } if (typeof x == boolean ) else return!x; return 0 - x; FuncGon type annotagon inside comments 26

27 Tag- Tests Duck Typing Mutable Objects //: negate :: (x:any) Any var negate = function(x) { } if (typeof x == boolean ) else return!x; return 0 - x; DJS is Path SensiGve x is boolean... so negagon is well- typed 27

28 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { } if (typeof x == boolean ) else //: negate :: (x:any) Any return!x; return 0 - x; DJS is Path SensiGve x is arbitrary non- boolean value so DJS signals error! 28

29 Tag- Tests Duck Typing Mutable Objects //: negate :: (x:numorbool) Any var negate = function(x) { if (typeof x == boolean ) else return!x; return 0 - x; } 29

30 Tag- Tests Duck Typing Mutable Objects //: negate :: (x:numorbool) Any var negate = function(x) { } if (typeof x == boolean ) else return!x; return 0 - x; this Gme, x is a number so subtracgon is well- typed 30

31 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { } if (typeof x == boolean ) else //: negate :: (x:numorbool) Any return!x; return 0 - x; but return type is imprecise 31

32 Tag- Tests Duck Typing Mutable Objects //: negate :: (x:numorbool) NumOrBool var negate = function(x) { if (typeof x == boolean ) return!x; else return 0 - x; } 32

33 Tag- Tests Duck Typing Mutable Objects /*: negate :: (x:numorbool) { v tag(v) = tag(x) } */ var negate = function(x) { } if (typeof x == boolean ) else return!x; return 0 - x; output type depends on input value 33

34 Tag- Tests Duck Typing Mutable Objects /*: negate :: (x:numorbool) { v tag(v) = tag(x) } */ Programmer chooses degree of precision in specificagon 34

35 Tag- Tests Duck Typing Mutable Objects What is Duck Typing? if (duck.quack) return Duck says + duck.quack(); else return This duck can t quack! ; 35

36 Tag- Tests Duck Typing Mutable Objects What is Duck Typing? (+) :: (Num,Num) Num (+) :: (Str,Str) Str if (duck.quack) return Duck says + duck.quack(); else return This duck can t quack! ; 36

37 Tag- Tests Duck Typing Mutable Objects What is Duck Typing? Can dynamically test the presence of a method but not its type if (duck.quack) return Duck says + duck.quack(); else return This duck can t quack! ; 37

38 Tag- Tests Duck Typing Mutable Objects { d tag(d) = Dict { v has(d, quack ) { v sel(d, quack ) :: Unit Str } Operators from McCarthy theory of arrays if (duck.quack) return Duck says + duck.quack(); else return This duck can t quack! ; 38

39 Tag- Tests Duck Typing Mutable Objects { d tag(d) = Dict { v has(d, quack ) { v sel(d, quack ) :: Unit Str } Call produces Str, so concat well- typed if (duck.quack) return Duck says + duck.quack(); else return This duck can t quack! ; 39

40 Tag- Tests Duck Typing Mutable Objects DJS is Flow SensiGve var x = {}; x.f = 7; x.f + 2; x 0 :Empty x 1 :{d d = upd(x 0, f,7)} DJS verifies that x.f is definitely a number McCarthy operator 40

41 Tag- Tests Duck Typing Mutable Objects DJS is Flow SensiGve var x = {}; x.f = 7; x.f + 2; x 0 :Empty x 1 :{d d = upd(x 0, f,7)} Strong updates to singleton objects Weak updates to collecgons of objects 41

42 Tag- Tests Duck Typing Mutable Objects 42

43 Tag- Tests Duck Typing Mutable Objects Typical Dynamic Features 43

44 Tag- Tests Duck Typing Mutable Objects Typical Dynamic Features JavaScript tl;dr Harder, but DJS handles them 44

45 Tag- Tests Duck Typing Mutable Objects child Upon construcgon, each object links to a prototype object parent grandpa... null 45

46 Tag- Tests Duck Typing Mutable Objects SemanGcs var of Key k = Lookup first ; child[k]; child If child contains k, then Read k from child parent Else if parent contains k, then Read k from parent grandpa Else if grandpa contains k, then Read k from grandpa... Else if null Else Return undefined 46

47 Tag- Tests Duck Typing Mutable Objects SemanGcs var of Key k = Lookup first ; child[k]; child { v if If has(child,k) contains k, then { v ifv Read = sel(child,k) k from child parent Else if parent contains k, then Read k from parent grandpa Else if grandpa contains k, then Read k from grandpa H (Rest of Heap)... null Else if Else Return undefined 47

48 Tag- Tests Duck Typing Mutable Objects SemanGcs var of Key k = Lookup first ; child[k]; child { v if If has(child,k) contains k, then { v ifv Read = sel(child,k) k from child parent { v else Else if if parent has(parent,k) contains k, then then { v ifv Read = sel(parent,k) k from grandpa Else if grandpa contains k, then Read k from grandpa H (Rest of Heap)... null Else if Else Return undefined 48

49 Tag- Tests Duck Typing Mutable Objects SemanGcs var of Key k = Lookup first ; child[k]; child { v if If has(child,k) contains k, then { v ifv Read = sel(child,k) k from child parent { v else Else if if parent has(parent,k) contains k, then then { v ifv Read = sel(parent,k) k from grandpa??? Else if grandpa contains k, then Read k from grandpa H (Rest of Heap)... null Else if Else Return undefined 49

50 Tag- Tests Duck Typing Mutable Objects SemanGcs var of Key k = Lookup first ; child[k]; child { v if has(child,k) then { v ifv = sel(child,k) parent { v else if has(parent,k) then { v ifv = sel(parent,k) grandpa??? { v else { v ifv = HeapSel(H,grandpa,k)) } H (Rest of Heap)... null Abstract predicate to summarize the unknown porion of the prototype chain 50

51 Tag- Tests Duck Typing Mutable Objects var k = first ; child[k]; child { first : John } { v if has(child,k) then { v ifv = sel(child,k) parent { first : Ida, last : McCarthy } { v else if has(parent,k) then { v ifv = sel(parent,k) grandpa??? { v else { v ifv = HeapSel(H,grandpa,k)) } H (Rest of Heap)... null <: { v v = John } 51

52 Tag- Tests Duck Typing Mutable Objects var k = last ; child[k]; child { first : John } { v if has(child,k) then { v ifv = sel(child,k) parent { first : Ida, last : McCarthy } { v else if has(parent,k) then { v ifv = sel(parent,k) grandpa??? { v else { v ifv = HeapSel(H,grandpa,k)) } H (Rest of Heap)... null <: { v v = McCarthy } 52

53 Tag- Tests Duck Typing Mutable Objects Prototype Chain Unrolling Key Idea: Reduce prototype semangcs to decidable theory of arrays 53

54 Tag- Tests Duck Typing Mutable Objects var nums = [0,1,2] A finite tuple while ( ) { nums[nums.length] = 17 } extended to unbounded collecgon 54

55 Tag- Tests Duck Typing Mutable Objects var nums = [0,1,2] while ( ) { nums[nums.length] = 17 } delete nums[1] A hole in the array for (i = 0; i < nums.length; i++) sum += nums[i] Missing element within length 55

56 Tag- Tests Duck Typing Mutable Objects Track types, packedness, and length of arrays where possible { a a :: Arr(T) { a packed(a) { a len(a) = 10 } len(a) T? T? T? T? T? T? X T T T T X T? { x T(x) x = undefined } X { x x = undefined } 56

57 Tag- Tests Duck Typing Mutable Objects Encode tuples as arrays var tup = [17, cacti ] { a a :: Arr(Any) { a packed(a) len(a) = 2 { a Int(sel(a,0)) { a Str(sel(a,1)) } 57

58 Tag- Tests Duck Typing Mutable Objects var tup = [17, cacti ] tup[tup.length] = true { a a :: Arr(Any) { a packed(a) len(a) = 3 { a } 58

59 Tag- Tests Duck Typing Mutable Objects DJS handles other quirks: Special length property Array.prototype Non- integer keys 59

60 Tag- Tests Duck Typing Mutable Objects 60

61 What About eval? Old Types eval( ); Arbitrary code loading 61

62 What About eval? Old Types New Types eval( ); //: #assume New Types Contract Checking at Run- Gme aka Gradual Typing 62

63 Recap of DJS Techniques Logic! Path and Flow SensiGvity Prototype Unrolling SyntacGc Sugar 63

64 Outline MoGvaGon Our Approach: Logic! EvaluaGon 64

65 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas 65

66 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas 66

67 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas Four inheritance paserns from Crockford s JS: The Good Parts 67

68 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas Array- manipulagng examples from SunSpider 68

69 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas typeof() funcgon to replace typeof from Closure Compiler 69

70 13 Benchmarks The Good Parts arrays objects type- tests prototypes lambdas Well- typed programs don t have run- Gme errors 70

71 DJS Program ImplementaIon Desugarer Based on Guha et al. [ECOOP 2010] JavaScript λ- Calculus + References + Desugared Program

72 DJS Program Desugarer Based on Guha et al. [ECOOP 2010] ImplementaIon Programmer Chooses Warnings or Errors Local Type Inference Subtyping w/o Z3 If Possible Desugared Program Type Checker Z3 SMT Solver

73 AnnotaIon Burden (Improved since paper) += ~300 LOC to start += ~100 LOC annotagons =+ ~400 LOC total 33% AnnotaGon Overhead Common Cases Simplified via SyntacGc Sugar and Local Type Inference

74 Performance (Improved since paper) Total benchmark suite: ~10 seconds ~1100 Z3 queries 11/13 benchmarks in 0-1 s Common Cases Fast via SyntacGc Reasoning When Possible

75 Future Work Syntax, Inference, Performance Larger Examples Type Checker in JS; Run in Browser IDE Support for Refactoring, etc. 75

76 JavaScript The Good Parts DJS Types via Logic! 76

77 Thanks! D! ::! ravichugh.com/djs PS: I m on the Job Market 77

78 Extra Slides 78

79 Usability System D [POPL 12] Dependent JavaScript [this paper] F, occurrence types refinement types + nested refinements DJS syntacgc types dependent types Coq JS Expressivity

80 System D [POPL 2012] + Types for JS PrimiGves + Strong Updates + Quirky JS + Prototype Inheritance Dependent JavaScript (DJS)

81 {p} {v p} FuncIon Types and Objects /*: x:numorbool {ite Num(x) Num(v) Bool(v)} */ function negate(x) { x = (typeof x == number )? 0 x :!x return x } /*: x:any {v iff falsy(x)} */ function negate(x) { x = (typeof x == number )? 0 x :!x return x } 81

82 FuncIon Types and Objects x:t 1 /H 1 T 2 /H 2 input type input heap output type output heap ObjHas(d,k,H,d ) has(d,k) HeapHas(H,d,k) /*: x:ref / [x -> d:dict > x.pro] {v iff ObjHas(d, f,curheap,x.pro)} / sameheap */ function hasf(x) { return f in x } 82

83 FuncIon Types and Objects x:t 1 /H 1 T 2 /H 2 input type input heap output type output heap ObjSel(d,k,H,d ) ite has(d,k) sel(d,k) HeapSel(H,d,k) /*: x:ref / [x -> d:dict > x.pro] {v = ObjSel(d, f,curheap,x.pro)} / sameheap */ function readf(x) { return x.f } 83

84 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!x; else Whoa, but perhaps okay return 0-2 x; // -2 } negate( 2 ) 84

85 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { } if (typeof x == boolean ) else return!x; return 0 - undefined x; // NaN negate( undefined ) Error would be nicer, but okay 85

86 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { if (typeof x == boolean ) return!x; else Seems about right return 0 - {} x; // NaN } negate( {} ) 86

87 Tag- Tests Duck Typing Mutable Objects var negate = function(x) { } negate has good intengons But too many corner cases in JS semangcs! if (typeof x == boolean ) else return!x; return 0 - [] x; // 0 negate( [] ) WAT?! 87

88 Tag- Tests Duck Typing Mutable Objects if (duck.quack) else { d tag(d) = Dict { v has(d, quack ) { v sel(d, quack ) :: Unit Str } FuncGon types nested inside refinements [POPL 2012] return Duck says + duck.quack(); return This duck can t quack! ; 88

89 Tag- Tests Duck Typing Mutable Objects var x = {}; x.f; x.f.f; Programmer configures DJS to report either warnings or errors for: 1) Possible unbound keys 89

90 Tag- Tests Duck Typing Mutable Objects var x = {}; x.f; x.f.f; Programmer configures DJS to report either warnings or errors for: 1) Possible unbound keys 2) Possible run- Gme errors 90

Towards Dependent Types for JavaScript

Towards Dependent Types for JavaScript Towards Dependent Types for JavaScript Ravi Chugh, David Herman, Ranjit Jhala University of California, San Diego Mozilla Research Explicit Towards Dependent Decidable A Large Subset of Types for JavaScript

More information

Nested Refinement Types for JavaScript. Ravi Chugh

Nested Refinement Types for JavaScript. Ravi Chugh Nested Refinement Types for JavaScript Ravi Chugh Alternate Title for Jan: Why JavaScript Programmers Hate Me An Ode to Dependent Types Ravi Chugh Sta=c Types For 1. Development Tools 2. Reliability &

More information

Sta$c Verifica$on for Web Scrip$ng Languages. Ravi Chugh

Sta$c Verifica$on for Web Scrip$ng Languages. Ravi Chugh Sta$c Verifica$on for Web Scrip$ng Languages Ravi Chugh Web Pla=orm 2 Web Pla=orm 3 My Goal: Rigorous Founda2ons Web Pla=orm 4 1995 Web Page = Sta$c HTML Web Page + Links Web Page + Client- Side Code

More information

Modern Type Systems for Dynamic Languages. Ravi Chugh

Modern Type Systems for Dynamic Languages. Ravi Chugh Modern Type Systems for Dynamic Languages Ravi Chugh Web Pla0orm 2 Goal: Rigorous Founda

More information

arxiv: v2 [cs.pl] 16 Apr 2012

arxiv: v2 [cs.pl] 16 Apr 2012 Dependent Types for JavaScript Ravi Chugh University of California, San Diego rchugh@cs.ucsd.edu David Herman Mozilla Research dherman@mozilla.com Ranjit Jhala University of California, San Diego jhala@cs.ucsd.edu

More information

JavaScript: Sort of a Big Deal,

JavaScript: Sort of a Big Deal, : Sort of a Big Deal, But Sort of Quirky... March 20, 2017 Lisp in C s Clothing (Crockford, 2001) Dynamically Typed: no static type annotations or type checks. C-Like Syntax: curly-braces, for, semicolons,

More information

Refinement Types for TypeScript

Refinement Types for TypeScript Refinement Types for TypeScript Panagiotis Vekris Benjamin Cosman Ranjit Jhala University of California, San Diego PLDI 16 Thursday, June 16 Extensible static analyses for modern scripting languages 2

More information

Software Verification : Introduction

Software Verification : Introduction Software Verification : Introduction Ranjit Jhala, UC San Diego April 4, 2013 What is Algorithmic Verification? Algorithms, Techniques and Tools to ensure that Programs Don t Have Bugs (What does that

More information

UNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu.

UNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu. UNIVERSITY OF TORONTO Faculty of Arts and Science Midterm Sample s CSC324H1 Duration: 50 minutes Instructor(s): David Liu. No Aids Allowed Name: Student Number: Please read the following guidelines carefully.

More information

Trust, but Verify. Two-Phase Typing for Dynamic Languages. Panagiotis Vekris, Benjamin Cosman, Ranjit Jhala. University of California, San Diego

Trust, but Verify. Two-Phase Typing for Dynamic Languages. Panagiotis Vekris, Benjamin Cosman, Ranjit Jhala. University of California, San Diego Trust, but Verify Two-Phase Typing for Dynamic Languages Panagiotis Vekris, Benjamin Cosman, Ranjit Jhala University of California, San Diego Scripting Languages Then Perl is the duct tape of the Internet.

More information

INF5750. Introduction to JavaScript and Node.js

INF5750. Introduction to JavaScript and Node.js INF5750 Introduction to JavaScript and Node.js Outline Introduction to JavaScript Language basics Introduction to Node.js Tips and tools for working with JS and Node.js What is JavaScript? Built as scripting

More information

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing

More information

A Structural Operational Semantics for JavaScript

A Structural Operational Semantics for JavaScript Dept. of Computer Science, Stanford University Joint work with Sergio Maffeis and John C. Mitchell Outline 1 Motivation Web Security problem Informal and Formal Semantics Related work 2 Formal Semantics

More information

Nested Refinements: A Logic for Duck Typing

Nested Refinements: A Logic for Duck Typing Nested Refinements: A Logic for Duck Typing Ravi Chugh Patrick M. Rondon Ranjit Jhala University of California, San Diego {rchugh, prondon, jhala}@cs.ucsd.edu Abstract Programs written in dynamic languages

More information

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects JavaScript CAC Noida is an ISO 9001:2015 certified training center with professional experience that dates back to 2005. The vision is to provide professional education merging corporate culture globally

More information

ADsafety. Type-based Verification of JavaScript Sandboxing. Joe Gibbs Politz Spiridon Aristides Eliopoulos Arjun Guha Shriram Krishnamurthi

ADsafety. Type-based Verification of JavaScript Sandboxing. Joe Gibbs Politz Spiridon Aristides Eliopoulos Arjun Guha Shriram Krishnamurthi ADsafety Type-based Verification of JavaScript Sandboxing Joe Gibbs Politz Spiridon Aristides Eliopoulos Arjun Guha Shriram Krishnamurthi 1 2 3 third-party ad third-party ad 4 Who is running code in your

More information

Chapter 3 Data Types and Variables

Chapter 3 Data Types and Variables Chapter 3 Data Types and Variables Adapted from JavaScript: The Complete Reference 2 nd Edition by Thomas Powell & Fritz Schneider 2004 Thomas Powell, Fritz Schneider, McGraw-Hill Jargon Review Variable

More information

Client-Side Web Technologies. JavaScript Part I

Client-Side Web Technologies. JavaScript Part I Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful

More information

System Functions and their Types in Shen

System Functions and their Types in Shen System Functions and their Types in Shen absvector Given a non-negative integer returns a vector in the native platform. absvector? A boolean Recognisor for native vectors. address-> Given an absolute

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

Programming Languages

Programming Languages CSE 130 : Spring 2011 Programming Languages Lecture 3: Crash Course Ctd, Expressions and Types Ranjit Jhala UC San Diego A shorthand for function binding # let neg = fun f -> fun x -> not (f x); # let

More information

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,

More information

TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript

TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript Michael Pradel 1, Parker Schuh 2, Koushik Sen 2 1 TU Darmstadt, 2 UC Berkeley 1 Motivation JavaScript: Dynamic and permissive Problems remain

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages www.cs.bgu.ac.il/~ppl172 Collaboration and Management Dana Fisman Lesson 2 - Types with TypeScript 1 Types What are types in programming languages? What types are you

More information

JavaScript for PHP Developers

JavaScript for PHP Developers JavaScript for PHP Developers Ed Finkler @funkatron coj@funkatron.com May 18, 2010 #tekx #js4php http://joind.in/1564 What is this? 2 A practical overview of JS for the PHP developer Stop c+p'ing, start

More information

CSolve: Verifying C With Liquid Types

CSolve: Verifying C With Liquid Types CSolve: Verifying C With Liquid Types Patrick Rondon, Alexander Bakst, Ming Kawaguchi, and Ranjit Jhala University of California, San Diego {prondon, abakst, mwookawa, jhala@cs.ucsd.edu Abstract. We present

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

Programming Languages Lecture 14: Sum, Product, Recursive Types CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate

More information

Recency Types for Dynamically-Typed, Object-Based Languages

Recency Types for Dynamically-Typed, Object-Based Languages Recency Types for Dynamically-Typed, Object-Based Languages Phillip Heidegger, Peter Thiemann Albert-Ludwigs-Universität Freiburg 15.10.2008 Task: Maintenance Finding bugs in JavaScript programs Understanding

More information

CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th

CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th Name: CAS ID (e.g., abc01234@pomona.edu): I encourage you to collaborate. collaborations below. Please record your Each question is worth

More information

Semantic Subtyping with an SMT Solver

Semantic Subtyping with an SMT Solver Semantic Subtyping with an SMT Solver Cătălin Hrițcu, Saarland University, 16 December 2009 Joint work with Andy Gordon (MSR Cambridge), Gavin Bierman (MSR Cambridge), and Dave Langworthy (MS Redmond)

More information

Lecture 15 CIS 341: COMPILERS

Lecture 15 CIS 341: COMPILERS Lecture 15 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th No lecture on Thursday, March 22 Dr. Z will be away Zdancewic CIS 341: Compilers 2 Adding Integers

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

2 Blending static and dynamic typing

2 Blending static and dynamic typing 2 Blending static and dynamic typing We begin this chapter presenting a little bit of the history behind combining static and dynamic typing in the same language. Then, we introduce optional type systems

More information

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Maxime Chevalier-Boisvert joint work with Marc Feeley ECOOP - July 20th, 2016 Overview Previous work: Lazy Basic Block Versioning

More information

CSE 341: Programming Languages

CSE 341: Programming Languages CSE 341: Programming Languages Winter 2005 Lecture 17 varargs and apply, implementing higher-order functions CSE341 Winter 2005, Lecture 17 1 Today: Some easy Scheme odds and ends Implementing higher-order

More information

Language Based isolation of Untrusted JavaScript

Language Based isolation of Untrusted JavaScript Dept. of Computer Science, Stanford University Joint work with Sergio Maffeis (Imperial College London) and John C. Mitchell (Stanford University) Outline 1 Motivation 2 Case Study : FBJS Design Attacks

More information

Functional Programming. Pure Functional Languages

Functional 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 information

TRANSLATING DART TO EFFICIENT JAVASCRIPT. Kasper Lund Google

TRANSLATING DART TO EFFICIENT JAVASCRIPT. Kasper Lund Google TRANSLATING DART TO EFFICIENT JAVASCRIPT Kasper Lund Google Translating Dart to efficient JavaScript Kasper Lund, Google Who am I? Kasper Lund, software engineer at Google Projects OOVM: Embedded Smalltalk

More information

COMP520 - GoLite Type Checking Specification

COMP520 - GoLite Type Checking Specification COMP520 - GoLite Type Checking Specification Vincent Foley March 5, 2017 1 Introduction This document presents the typing rules for all the language constructs (i.e. declarations, statements, expressions)

More information

Functional JavaScript. Douglas Crockford Yahoo! Inc.

Functional JavaScript. Douglas Crockford Yahoo! Inc. Functional JavaScript Douglas Crockford Yahoo! Inc. The World's Most Misunderstood Programming Language A language of many contrasts. The broadest range of programmer skills of any programming language.

More information

CS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 17 Recursive Types Dan Grossman 2012 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML),

More information

Functional Programming. Pure Functional Languages

Functional 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 information

Abstract Interpretation

Abstract Interpretation Abstract Interpretation Ranjit Jhala, UC San Diego April 22, 2013 Fundamental Challenge of Program Analysis How to infer (loop) invariants? Fundamental Challenge of Program Analysis Key issue for any analysis

More information

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our

More information

Programming Languages

Programming Languages CSE 130 : Fall 2008 Programming Languages Lecture 3: Epressions and Types Ranjit Jhala UC San Diego News PA 1 due (net) Fri 10/10 5pm PA 2 out today or tomorrow Office hours posted on Webpage: Held in

More information

CSE341 Autumn 2017, Final Examination December 12, 2017

CSE341 Autumn 2017, Final Examination December 12, 2017 CSE341 Autumn 2017, Final Examination December 12, 2017 Please do not turn the page until 2:30. Rules: The exam is closed-book, closed-note, etc. except for both sides of one 8.5x11in piece of paper. Please

More information

Experimental New Directions for JavaScript

Experimental New Directions for JavaScript Experimental New Directions for JavaScript Andreas Rossberg, V8/Google Motivation Broad need for (more) scalable JavaScript Usability, esp. maintainability Performance, esp. predictability ES6 opens up

More information

COMP520 - GoLite Type Checking Specification

COMP520 - GoLite Type Checking Specification COMP520 - GoLite Type Checking Specification Vincent Foley April 8, 2018 1 Introduction This document presents the typing rules for all the language constructs (i.e. declarations, statements, expressions)

More information

Programming Languages

Programming Languages CSE 130: Spring 2010 Programming Languages Lecture 3: Epressions and Types Ranjit Jhala UC San Diego A Problem fun -> +1 Can functions only have a single parameter? A Solution: Simultaneous Binding Parameter

More information

COMP520 - GoLite Type Checking Specification

COMP520 - GoLite Type Checking Specification COMP520 - GoLite Type Checking Specification Vincent Foley February 26, 2015 1 Declarations Declarations are the primary means of introducing new identifiers in the symbol table. In Go, top-level declarations

More information

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values CSE 130: Programming Languages Environments & Closures News PA 3 due THIS Friday (5/1) Midterm NEXT Friday (5/8) Ranjit Jhala UC San Diego Recap: Functions as first-class values Arguments, return values,

More information

Type Assisted Synthesis of Programs with Algebraic Data Types

Type Assisted Synthesis of Programs with Algebraic Data Types Type Assisted Synthesis of Programs with Algebraic Data Types Jeevana Priya Inala MIT Collaborators: Xiaokang Qiu (MIT), Ben Lerner (Brown), Armando Solar-Lezama (MIT) Example - Desugaring a simple language

More information

CIS 120 Midterm II November 16, 2012 SOLUTIONS

CIS 120 Midterm II November 16, 2012 SOLUTIONS CIS 120 Midterm II November 16, 2012 SOLUTIONS 1 1. Java vs. OCaml (22 points) a. In OCaml, the proper way to check whether two string values s and t are structurally equal is: s == t s = t s.equals(t)

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

CMSC 330: Organization of Programming Languages. Operational Semantics

CMSC 330: Organization of Programming Languages. Operational Semantics CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged

More information

Small Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis

Small Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis Small Formulas for Large Programs: On-line Constraint Simplification In Scalable Static Analysis Isil Dillig, Thomas Dillig, Alex Aiken Stanford University Scalability and Formula Size Many program analysis

More information

Scheme in Scheme: The Metacircular Evaluator Eval and Apply

Scheme in Scheme: The Metacircular Evaluator Eval and Apply Scheme in Scheme: The Metacircular Evaluator Eval and Apply CS21b: Structure and Interpretation of Computer Programs Brandeis University Spring Term, 2015 The metacircular evaluator is A rendition of Scheme,

More information

CSCI 3155: Principles of Programming Languages Exam preparation #1 2007

CSCI 3155: Principles of Programming Languages Exam preparation #1 2007 CSCI 3155: Principles of Programming Languages Exam preparation #1 2007 Exercise 1. Consider the if-then-else construct of Pascal, as in the following example: IF 1 = 2 THEN PRINT X ELSE PRINT Y (a) Assume

More information

Semantic Subtyping with an SMT Solver

Semantic Subtyping with an SMT Solver Semantic Subtyping with an SMT Solver Cătălin Hrițcu, Saarland University, Saarbrücken, Germany Joint work with Andy Gordon, Gavin Bierman, and Dave Langworthy (all from Microsoft) Refinement Types + Type-test

More information

n n Try tutorial on front page to get started! n spring13/ n Stack Overflow!

n   n Try tutorial on front page to get started! n   spring13/ n Stack Overflow! Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!

More information

CVO103: Programming Languages. Lecture 5 Design and Implementation of PLs (1) Expressions

CVO103: Programming Languages. Lecture 5 Design and Implementation of PLs (1) Expressions CVO103: Programming Languages Lecture 5 Design and Implementation of PLs (1) Expressions Hakjoo Oh 2018 Spring Hakjoo Oh CVO103 2018 Spring, Lecture 5 April 3, 2018 1 / 23 Plan Part 1 (Preliminaries):

More information

The gradual typing approach to mixing static and dynamic typing

The gradual typing approach to mixing static and dynamic typing 1 / 38 The gradual typing approach to mixing static and dynamic typing Jeremy G. Siek University of Colorado = Indiana University TFP 2013 at Provo, Utah, May 2013 The Goals of Gradual Typing Enjoy the

More information

The Polymorphic Blame Calculus and Parametricity

The Polymorphic Blame Calculus and Parametricity 1 / 31 The Polymorphic Blame Calculus and Parametricity Jeremy G. Siek Indiana University, Bloomington University of Strathclyde August 2015 2 / 31 Integrating static and dynamic typing Static Dynamic

More information

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Outline. 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 information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

Programming Languages: Application and Interpretation

Programming Languages: Application and Interpretation Programming Languages: Application and Interpretation Version 6.7 October 26, 2016 This is the documentation for the software accompanying the textbook Programming Languages: Application and Interpretation

More information

CSCI-GA Scripting Languages

CSCI-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 information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 2 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics

More information

CS 11 Haskell track: lecture 1

CS 11 Haskell track: lecture 1 CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of

More information

JavaScript: The Good Parts

JavaScript: The Good Parts JavaScript: The Good Parts The World's Most Misunderstood Programming Language Douglas Crockford Yahoo! Inc. A language of many contrasts. The broadest range of programmer skills of any programming language.

More information

Test 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.

Test 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 information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

A Structural Operational Semantics for JavaScript

A Structural Operational Semantics for JavaScript Dept. of Computer Science, Stanford University 1 Need for a Formal Semantics? 2 Structural Operational Semantics for IMP Formalizing the program state Semantic Rules Formal properties 3 Structural Operational

More information

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false Test 1 Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which celebrity has not received an ACM Turing Award? A. Alan Kay B. John McCarthy C. Dennis Ritchie D. Bjarne Stroustrup

More information

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016 CSE-505: Programming Languages Lecture 20.5 Recursive Types Zach Tatlock 2016 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML), but

More information

News. Programming Languages. Recap. Recap: Environments. Functions. of functions: Closures. CSE 130 : Fall Lecture 5: Functions and Datatypes

News. Programming Languages. Recap. Recap: Environments. Functions. of functions: Closures. CSE 130 : Fall Lecture 5: Functions and Datatypes CSE 130 : Fall 2007 Programming Languages News PA deadlines shifted PA #2 now due 10/24 (next Wed) Lecture 5: Functions and Datatypes Ranjit Jhala UC San Diego Recap: Environments Phone book Variables

More information

Substructural Typestates

Substructural Typestates Programming Languages meets Program Verification 2014 Substructural Typestates Filipe Militão (CMU & UNL) Jonathan Aldrich (CMU) Luís Caires (UNL) Motivation! File file = new File( out.txt );! file.write(

More information

Scala : an LLVM-targeted Scala compiler

Scala : an LLVM-targeted Scala compiler Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

Introductory logic and sets for Computer scientists

Introductory logic and sets for Computer scientists Introductory logic and sets for Computer scientists Nimal Nissanke University of Reading ADDISON WESLEY LONGMAN Harlow, England II Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario

More information

low and not larger than high. 18 points

low and not larger than high. 18 points CSE 330 Test 1 (1 point) Spring 015 Multiple Choice. Write your answer to the LEFT of each problem. 3 points each 1. Lisp was invented at: A. IBM B. MIT C. Netscape D. Stanford. In C++, what operator is

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional! CS 498RK FALL 2017 JAVASCRIPT Fashionable and Functional! JAVASCRIPT popular scripting language on the Web, supported by browsers separate scripting from structure (HTML) and presentation (CSS) client-

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 7 Lambda Calculus Dan Grossman Spring 2011 Where we are Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now:

More information

JSJS - Project Proposal

JSJS - Project Proposal JSJS - Project Proposal A general purpose, strongly typed programming language for the web Jain Bahul Srivastav Prakhar Jain Ayush Sadekar Gaurang bkj2111 ps2894 aj2672 gss2147 Description JSJS is a strongly

More information

Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM

Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM 1 of 18 9/6/2010 9:40 PM Flash CS4 Professional ActionScript 3.0 Language Reference Language Reference only Compiler Errors Home All Packages All Classes Language Elements Index Appendixes Conventions

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

DRAWING ENVIRONMENT DIAGRAMS

DRAWING ENVIRONMENT DIAGRAMS DRAWING ENVIRONMENT DIAGRAMS COMPUTER SCIENCE 61A September 10, 2012 0.1 Background A frame is a location where variable bindings are stored A binding is a connection between a name and a value. The name

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2005 P. N. Hilfinger Project #2: Static Analyzer for Pyth Due: Wednesday, 6 April

More information

Types for Flexible Objects

Types for Flexible Objects Types for Flexible Objects Building a Typed Scripting Language Pottayil Harisanker Menon, Zachary Palmer, Alexander Rozenshteyn, Scott F. Smith The Johns Hopkins University November 17th, 2014 2/1 Objective

More information

JavaScript: The Good Parts. Douglas Crockford Yahoo! Inc.

JavaScript: The Good Parts. Douglas Crockford Yahoo! Inc. JavaScript: The Good Parts Douglas Crockford Yahoo! Inc. http://www.crockford.com/codecamp/ The World's Most Popular Programming Language The World's Most Popular Programming Language The World's Most

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Recap: Functions as first-class values

Recap: Functions as first-class values Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse

More information

Static Analysis for JavaScript

Static Analysis for JavaScript Static Analysis for JavaScript Adi Yoga Sidi Prabawa Supervisor: Associate Professor Chin Wei Ngan Department of Computer Science School of Computing National University of Singapore June 30, 2013 Abstract

More information

Type systems. Static typing

Type systems. Static typing Type system A type is a set of values and operations on those values A language s type system specifies which operations are valid for a type The aim of type checking is to ensure that operations are used

More information