A Type is Worth a Thousand Tests
|
|
- Samantha Armstrong
- 5 years ago
- Views:
Transcription
1 A Type is Worth a Thousand Tests Manuel M T Chakravarty Applicative & Tweag I/O mchakravarty TacticalGrace justtesting.org haskellformac.com
2 Let s talk about
3 Let s talk about Swift
4 Let s talk about Language Design Swift
5 Let s talk about Language Design Ecosystem Swift
6 Let s talk about Why is it Language extraordinary Design Ecosystem? Swift
7 Unique Event
8 Java C# Objective-C
9 Java Scala Kotlin C# Objective-C
10 Java Scala Kotlin C# F# Objective-C
11 Java Scala Kotlin C# F# Objective-C Swift
12 Why do languages become popular?
13 Why do languages become popular? Platforms
14 Why do languages become popular? Objective-C JavaScript Web Cocoa Python/Ruby Cloud C/C++ Unix Java JVM C#.NET Platforms
15 Why do languages become popular? Swift JavaScript Web Cocoa Python/Ruby Cloud C/C++ Unix Java JVM C#.NET Platforms
16 Why will Swift be popular?
17 Why will Swift be popular?
18 Why will Swift be popular?
19 Why will Swift be popular? Why is it extraordinary?
20 Functional Programming
21 From Objective-C to Swift
22 From Objective-C to Swift Value types (products & sums) Explicit control of mutability Advanced type system Explicit optionals Generics & Pattern matching Higher-order functions & closures protocols with associated types Type REPL inference
23 From Objective-C to Swift Advanced Value λtypes type system (products & sums) Explicit Explicit control of optionals mutability Generics & Higher-order protocols with functions associated types Pattern & matching closures Type REPL inference
24 From Objective-C to Swift Value λ τ types (products & sums) Higher-order functions & Explicit control of Pattern matching mutability closures REPL Advanced type system Generics & protocols with associated types Explicit optionals Type inference
25 Swift encourages typed functional programming in a mainstream language.
26 Haskell for Mac Adopting Swift right out of the gate
27 Haskell for Mac Adopting Swift right out of the gate
28 Swift encourages typed functional programming in a mainstream language.
29 Why Type Systems?
30 Catch bugs & prevent crashes
31 Less testing!
32 What if you could gain the same confidence in correctness with fewer or simpler tests?
33 Possible states of your application
34 Possible states of your application Error states
35 Possible states of your application Error states Tested states
36 Possible states of your application with types Error states Tested states
37 Possible states of your application with types eliminate bugs Error states Tested states
38 Possible states of your application with types eliminate bugs Error states eliminate tests Tested states
39 Are types restraints?
40 Types are a design tool!
41 Languages Programs Type Systems
42 Languages Programs Type Systems Make undesirable states unrepresentable.
43 Swift encourages typed functional programming in a mainstream language.
44 Swift encourages typed functional programming in a mainstream language.
45 Swift encourages typed functional programming in a mainstream language. Value types Immutable model & UI state machines
46 Swift encourages typed functional programming in a mainstream language. Value types Immutable model & UI state machines Protocols with associated types Generic change propagation
47 Goals.app
48 Goals.app
49 Goals.app
50 Goals.app
51 Goals.app
52 Value Types Localise & structure change
53 Value types in Swift
54 Value types in Swift struct struct Point { var x: Double var y: Double }
55 Value types in Swift struct struct Point { var x: Double var y: Double } enum with associated values enum Result<ResultType> { case result(value: ResultType) case error(err: NSError) }
56 Value types in Swift struct generic type parameter struct Point { var x: Double var y: Double } enum with associated values enum Result<ResultType> { case result(value: ResultType) case error(err: NSError) }
57 Kolin Edition // Data class (similar to struct) data class Point(var x: Double, var y: Double) // Sealed class (similar to enum) sealed class Result { data class Success<T>(val value: T) : Result() data class Error(val err: Exception) : Result() }
58 Reference types versus value types var v: RefPnt var w: RefPnt class RefPnt { var x, y: Double }
59 Reference types versus value types var v: RefPnt var w: RefPnt x: 0, y: 0 class RefPnt { var x, y: Double } v = RefPnt(x: 0, y: 0)
60 Reference types versus value types var v: RefPnt var w: RefPnt x: 0, y: 0 class RefPnt { var x, y: Double } v = RefPnt(x: 0, y: 0) w = v
61 Reference types versus value types var v: RefPnt x: 10, y: 0 var w: RefPnt class RefPnt { var x, y: Double } v = RefPnt(x: 0, y: 0) w = v w.x = 10
62 Reference types versus value types var v: Point var w: Point struct Point { var x, y: Double }
63 Reference types versus value types var v: Point x: 0, y: 0 var w: Point struct Point { var x, y: Double } v = Point(x: 0, y: 0)
64 Reference types versus value types var v: Point x: 0, y: 0 var w: Point x: 0, y: 0 struct Point { var x, y: Double } v = Point(x: 0, y: 0) w = v
65 Reference types versus value types var v: Point x: 0, y: 0 var w: Point x: 10, y: 0 struct Point { var x, y: Double } v = Point(x: 0, y: 0) w = v w.x = 10
66 Value types var v: Point x: 0, y: 0 var w: Point x: 10, y: 0
67 Value types var v: Point x: 0, y: 0 var w: Point x: 10, y: 0 Localise change
68 Value types var v: Point x: 0, y: 0 var w: Point x: 10, y: 0 Localise change Facilitate local reasoning
69 Value Types Immutable Model
70 MVC & MVVM Architectures Controller View Model
71 MVC & MVVM Architectures View C Model View Model
72 MVC & MVVM Architectures passed around as reference type View View C Model Model
73 MVC & MVVM Architectures Accidental changes passed around as reference type View View C Model Model
74 MVC & MVVM Architectures Accidental changes Changes in wrong order passed around as reference type View View C Model Model
75 Immutable Goals struct Goal { let uuid: UUID // fast equality var colour: UIColor var title: String var interval: GoalInterval var frequency: Int }
76 Immutable Goals struct Goal { let uuid: UUID // fast equality var colour: UIColor var title: String var interval: GoalInterval var frequency: Int } typealias GoalProgress = (goal: Goal, count: Int?)
77 Immutable Goals struct Goal { let uuid: UUID // fast equality var colour: UIColor var title: String var interval: GoalInterval var frequency: Int } typealias GoalProgress = (goal: Goal, count: Int?) typealias Goals = [GoalProgress] // array
78 Kolin Edition data class Goal( val uuid: UUID, var colour: Color, var title: String, var interval: GoalInterval, var frequency: Int) typealias GoalProgress = Pair<Goal, Int?> typealias Goals = Array<GoalProgress>
79 Immutable Models Do Scale!
80 Immutable Models Do Scale! Haskell for Mac Uses an immutable model Adopts Cocoa Document Architecture
81 Immutable Models Do Scale! Haskell for Mac Uses an immutable model Adopts Cocoa Document Architecture Functional Programming in a Stateful World YOW! Lambda Jam 2015 (on speakerdeck.com)
82 But what if
83 But what if Use an immutable wrapper API to wrap mutable structures.
84 But what if Use an immutable wrapper API to wrap mutable structures. React (Native) Virtual DOM wraps DOM
85 But what if Use an immutable wrapper API to wrap mutable structures. React (Native) Virtual DOM wraps DOM Haskell SpriteKit Haskell library binding Algebraic data type wraps SpriteKit s mutable object graph
86 Replacing Tests
87 Replacing Tests Avoid accidental changes of model state Replaces integration tests
88 Replacing Tests Avoid accidental changes of model state Replaces integration tests Avoid races on concurrent threads Often not properly tested
89 Enums with Associated Values UI State Machines
90
91 Is goal active?
92 Is goal active? typealias GoalProgress = (goal: Goal, count: Int?) typealias Goals = [GoalProgress]
93 Is goal active? typealias GoalProgress = (goal: Goal, count: Int?) typealias Goals = [GoalProgress] Need to be careful not to lose progress info
94 var goalsactivity: [Bool]
95 var goalsactivity: [Bool] Not valid outside of editing mode
96 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } var goalsactivity: [Bool]
97 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) }
98 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } GoalsController: UITableViewController var editstate: GoalsEditState =.displaying
99 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } GoalsController: UITableViewController var editstate: GoalsEditState =.displaying switch editstate { // change mode
100 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } GoalsController: UITableViewController var editstate: GoalsEditState =.displaying switch editstate { // change mode case.displaying: navigationitem.setleftbarbutton(nil, ) editstate =.editing(goalsactivity: datasource.goalsactivity) alter UI state
101 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } GoalsController: UITableViewController var editstate: GoalsEditState =.displaying switch editstate { // change mode case.displaying: navigationitem.setleftbarbutton(nil, ) editstate =.editing(goalsactivity: datasource.goalsactivity) case.editing(let goalsactivity): navigationitem.setleftbarbutton(addbutton, ) datasource.commitgoalsactivity(goalsactivity) editstate =.displaying } alter UI state
102 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } GoalsController guard case.editing(var goalsactivity) = editstate else { return }
103 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } access to mode-specific state is guarded GoalsController guard case.editing(var goalsactivity) = editstate else { return }
104 enum GoalsEditState { case displaying case editing(goalsactivity: [Bool]) } access to mode-specific state is guarded GoalsController guard case.editing(var goalsactivity) = editstate else { return } let newisactive =!goalsactivity[indexpath.item] cell.editingaccessorytype = newisactive?.checkmark :.none
105 Kolin Edition sealed class GoalsEditState { data class Displaying : GoalsEditState() data class Editing(val goalsactivity: Array<Boolean>) : GoalsEditState() }
106 sealed class GoalsEditState { data class Displaying : GoalsEditState() data class Editing(val goalsactivity: Array<Boolean>) : GoalsEditState() } var editstate: GoalsEditState = GoalsEditState.Displaying()... when(editstate) { is GoalsEditState.Displaying -> { navigationitem.setleftbarbutton(null,...) editstate = GoalsEditState.Editing( goalsactivity = datasource.goalsactivity) } is GoalsEditState.Editing -> { navigationitem.setleftbarbutton(addbutton,...) datasource.commitgoalsactivity(goalsactivity) editstate = GoalsEditState.Displaying() } }
107 Replacing Tests
108 Replacing Tests Avoid inconsistent state changes Replaces UI tests
109 Replacing Tests Avoid inconsistent state changes Replaces UI tests Avoid non-exhaustive transitions Replaces exhaustiveness tests
110 Protocols with associated types Structured change propagation
111 Now that the model layer is immutable, how do we change anything?
112 Δt: 0s 25 Mutable Variable
113 Δt: 1s 7 Mutable Variable
114 Δt: 2s 11 Mutable Variable
115 Δt: 3s 73 Mutable Variable
116 Δt: 4s 42 Mutable Variable
117 Δt
118 Δt Flow of changes explicit in code
119 Δt Flow of changes explicit in code Changes can be processed with combinators (map, fold, accumulate, and so on)
120 Changes API protocol Observable: class { associatedtype ObservedValue
121 Changes API protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } registered observer call back
122 Kolin Edition interface Observable<ObservedValue> { fun <Context : Any> observe( context: Context, observer: (Context, ObservedValue) -> Unit) }
123 Changes API protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } registered observer call back
124 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () }
125 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } Ephemeral stream of changes class Changing<Value>: Observable { typealias ObservedValue = Value func announce(change: Value) { } func observe { } }
126 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } Ephemeral stream of changes class Changing<Value>: Observable { typealias ObservedValue = Value func announce(change: Value) { } func observe { } } Add another change value into the stream
127 interface Observable<ObservedValue> { fun <Context : Any> observe( context: Context, observer: (Context, ObservedValue) -> Unit) } class Changing<ObservedValue> : Observable<ObservedValue> { fun announce(change: ObservedValue) {... } fun observe... {... } }
128 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } Ephemeral stream of changes class Changing<Value>: Observable { typealias ObservedValue = Value func announce(change: Value) { } func observe { } } Add another change value into the stream
129 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } Accumulating value class Accumulating<Value, Accumulator>: Observable { typealias ObservedValue = Accumulator init <Observed: Observable where > ( observing observed: Observed, startingfrom initial: Accumulator, accumulate: (Value, Accumulator) -> Accumulator) func observe { } }
130 protocol Observable: class { associatedtype ObservedValue func observe<context: AnyObject>( withcontext context: Context, observer: (Context, ObservedValue) -> ()) -> () } Accumulating value class Accumulating<Value, Accumulator>: Observable { typealias ObservedValue = Accumulator init <Observed: Observable where > ( observing observed: Observed, startingfrom initial: Accumulator, accumulate: (Value, Accumulator) -> Accumulator) func observe { } } Accumulating change
131 interface Observable<ObservedValue> { fun <Context : Any> observe( context: Context, observer: (Context, ObservedValue) -> Unit) } class Accumulating<Value, Acc>( val observed: Observed, val initial: Acc, val accumulate: (Value, Acc) -> Acc) : Observable<Acc> { fun observe... {... } }
132 extension Observable { }
133 extension Observable { map apply function to each observed value }
134 extension Observable { map apply function to each observed value merge combine two streams of observations }
135 extension Observable { map apply function to each observed value merge combine two streams of observations accumulate combine the values of a stream of observations using an accumulation function }
136 Change Propagation in Goals G0 3 G1 nil G2 1 Views Model
137 Change Propagation in Goals observe G0 3 G1 nil G2 1 observe Views Model
138 Change Propagation in Goals observe G0 3 merge G1 nil G2 1 observe Views Model
139 Change Propagation in Goals observe ProgressEdits G0 3 merge G1 nil G2 1 GoalEdits observe Views Model
140 Change Propagation in Goals observe ProgressEdits Edits merge accumulate G0 3 G1 nil G2 1 GoalEdits observe Views Model
141 Change Propagation in Goals observe ProgressEdits Edits merge accumulate G0 3 G1 nil G2 1 GoalEdits Accumulating<Edit, Goals> observe Views Model
142 GoalEdits ProgressEdits Edits Accumulating<Edit, Goals>
143 typealias GoalEdits = Changing<GoalEdit> ProgressEdits Edits Accumulating<Edit, Goals>
144 typealias GoalEdits = Changing<GoalEdit> ProgressEdits Edits Accumulating<Edit, Goals>
145 typealias GoalEdits = Changing<GoalEdit> enum GoalEdit { case add(goal: Goal) case delete(goal: Goal) case update(goal: Goal) case setactivity(activity: [Bool]) } ProgressEdits Edits Accumulating<Edit, Goals>
146 typealias GoalEdits = Changing<GoalEdit> enum GoalEdit { case add(goal: Goal) case delete(goal: Goal) case update(goal: Goal) case setactivity(activity: [Bool]) } extension GoalEdit { func transform(_ goals: Goals) -> Goals { switch self { case.add(let newgoal): ProgressEdits Edits Accumulating<Edit, Goals>
147 Kolin Edition typealias GoalEdits = Changing<GoalEdit> sealed class GoalEdit { data class Add(val goal: Goal) : GoalEdit() data class Delete(val goal: Goal) : GoalEdit() data class Update(val goal: Goal) : GoalEdit() data class SetActivity(val activity: Array<Boolean>) : GoalEdit() } fun GoalEdit.transform(goals: Goals): Goals { when(this) { is GoalEdit.Add -> { } }
148 typealias GoalEdits = Changing<GoalEdit> enum GoalEdit { case add(goal: Goal) case delete(goal: Goal) case update(goal: Goal) case setactivity(activity: [Bool]) } extension GoalEdit { func transform(_ goals: Goals) -> Goals { switch self { case.add(let newgoal): ProgressEdits Edits Accumulating<Edit, Goals>
149 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> Edits Accumulating<Edit, Goals>
150 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> Edits Accumulating<Edit, Goals>
151 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> enum ProgressEdit { case bump(goal: Goal) } Edits Accumulating<Edit, Goals>
152 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> enum ProgressEdit { case bump(goal: Goal) } extension ProgressEdit { func transform(_ goals: Goals) -> Goals { } } Edits Accumulating<Edit, Goals>
153 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> enum ProgressEdit { case bump(goal: Goal) } extension ProgressEdit { func transform(_ goals: Goals) -> Goals { } } typealias Edits = Changing<Edit> Accumulating<Edit, Goals>
154 GoalEdits typealias ProgressEdits = Changing<ProgressEdit> enum ProgressEdit { case bump(goal: Goal) } extension ProgressEdit { func transform(_ goals: Goals) -> Goals { } } typealias Edits = Changing<Edit> enum Edit { case goaledit(edit: GoalEdit) case progressedit(edit: ProgressEdit) } Accumulating<Edit, Goals>
155 GoalEdits ProgressEdits Edits let model: Accumulating<Edit, Goals>
156 GoalEdits ProgressEdits Edits let model: Accumulating<Edit, Goals>
157 GoalEdits ProgressEdits Edits let model: Accumulating<Edit, Goals> = edits.accumulate(startingfrom: initialgoals) { edit, currentgoals in return edit.transform(currentgoals) }
158 Kolin Edition val model: Accumulating<Edit, Goals> = edits.accumulate(initial = initialgoals) { edit, currentgoals -> return edit.transform(currentgoals) }
159 Replacing Tests
160 Replacing Tests Avoid changes from unexpected places Replaces integration tests
161 Replacing Tests Avoid changes from unexpected places Replaces integration tests Avoid conflicting state changes Replaces integration tests
162 Check out the source code of Goals.app! haskellformac.com mchakravarty TacticalGrace justtesting.org types >< state
163 Check out the source code of Goals.app! Type systems are a design tool Swift encourages typed functional programming Types replace entire categories of tests haskellformac.com mchakravarty TacticalGrace justtesting.org types >< state
164 Thank you!
165 Image Attribution Wikimedia
Transitioning from C# to Scala Using Apache Thrift. Twitter Finagle
Transitioning from C# to Scala Using Apache Thrift and Twitter Finagle Steven Skelton September 19, 2013 Empathica Empathica provides Customer Experience Management programs to more than 200 of the world's
More informationGeneric Programming with Protocol in Swift. ios
Generic Programming with Protocol in Swift ios Generic Programming with Protocol in Swift ios func swapint(inout a: Int, inout _ b: Int) { let tmp = a a = b b = tmp var someint = 1 var anotherint = 5
More informationSoftware System Design and Implementation
Software System Design and Implementation Functional Programming Gabriele Keller The University of New South Wales School of Computer Science and Engineering Sydney, Australia COMP3141 16s1 Course software
More informationF# for Industrial Applications Worth a Try?
F# for Industrial Applications Worth a Try? Jazoon TechDays 2015 Dr. Daniel Egloff Managing Director Microsoft MVP daniel.egloff@quantalea.net October 23, 2015 Who are we Software and solution provider
More informationCSE341: Programming Languages Lecture 9 Function-Closure Idioms. Dan Grossman Winter 2013
CSE341: Programming Languages Lecture 9 Function-Closure Idioms Dan Grossman Winter 2013 More idioms We know the rule for lexical scope and function closures Now what is it good for A partial but wide-ranging
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 informationScala, Your Next Programming Language
Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that
More informationMobile Application Programming. Swift Classes
Mobile Application Programming Swift Classes Swift Top-Level Entities Like C/C++ but unlike Java, Swift allows declarations of functions, variables, and constants at the top-level, outside any class declaration
More informationSwift. Introducing swift. Thomas Woodfin
Swift Introducing swift Thomas Woodfin Content Swift benefits Programming language Development Guidelines Swift benefits What is Swift Benefits What is Swift New programming language for ios and OS X Development
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationQuestions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?
Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:
More informationSWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter
SWIFT! class Session { let title: String // constant non-optional field: can never be null and can never be changed var instruktør: Person? // variable optional field: null is permitted var attendees:
More informationKotlin/Native concurrency model. nikolay
Kotlin/Native concurrency model nikolay igotti@jetbrains What do we want from concurrency? Do many things concurrently Easily offload tasks Get notified once task a task is done Share state safely Mutate
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And
More informationSwift 5, ABI Stability and
Swift 5, ABI Stability and Concurrency @phillfarrugia Important Documents Concurrency Manifesto by Chris Lattner https: /gist.github.com/lattner/ 31ed37682ef1576b16bca1432ea9f782 Kicking off Concurrency
More informationFuture Web App Technologies
Future Web App Technologies Mendel Rosenblum MEAN software stack Stack works but not the final say in web app technologies Angular.js Browser-side JavaScript framework HTML Templates with two-way binding
More informationIntroduction to Swift. Dr. Sarah Abraham
Introduction to Swift Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 What is Swift? Programming language for developing OSX, ios, WatchOS, and TvOS applications Best of C and Objective-C
More informationA Brief History of Distributed Programming: RPC. YOW Brisbane 2016
A Brief History of Distributed Programming: RPC YOW Brisbane 2016 Christopher Meiklejohn Université catholique de Louvain @cmeik christophermeiklejohn.com Caitie McCaffrey Distributed Systems Engineer
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Mostly Swift but some other stuff too Autolayout teaser Quick review of what we learned in Concentration CountableRange of floating point numbers Tuples Computed
More informationSwift. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder
Swift Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Why Swift Recommended for all ios, macos, watchos,
More informationApple s new Swift language
Microsoft and Apple Training Apple s new Swift language Peter Himschoot peter@u2u.be Agenda Developing for ios overview Xcode, Objective-C, Swift, Development life cycle UI development Interface Builder
More informationiphone Application Programming Lab 3: Swift Types and Custom Operator + A02 discussion
Lab 3: Swift Types and Custom Operator + A02 discussion Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Learning Objectives Discuss A02 Another implementation
More informationIntroduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming
Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages Call-by-value Operational Semantics
More informationCPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia
CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple
More informationG Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,
More informationSWIFT & #IOExtendedCLT, 18th May 2016
SWIFT & KOTLIN @DagnaBieda, #IOExtendedCLT, 18th May 2016 Software Engineer at Quoin, 209 Delburg Street, Davidson, NC Sources tell The Next Web that Google is considering making Swift a first class language
More informationShared state model. April 3, / 29
Shared state April 3, 2012 1 / 29 the s s limitations of explicit state: cells equivalence of the two s programming in limiting interleavings locks, monitors, transactions comparing the 3 s 2 / 29 Message
More informationRx in the real world. 1 Rob Ciolli
Rx in the real world 1 Rob Ciolli 2 Rob Ciolli 3 Rob Ciolli The App 4 Rob Ciolli Quick architecture overview 5 Rob Ciolli MV - WTF 6 Rob Ciolli Model Simple, immutable data struct returned from DB or APIs
More informationParsing Scheme (+ (* 2 3) 1) * 1
Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes
More informationFirst Programming Language in CS Education The Arguments for Scala
First Programming Language in CS Education The Arguments for Scala WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that is under contract with CRC Press.
More informationExecutive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.
Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Poor co-ordination that exists in threads on JVM is bottleneck
More informationBuy a Feature: an Adventure in Immutability and Actors. David Pollak BayFP August 22, 2008
Buy a Feature: an Adventure in Immutability and Actors David Pollak BayFP August 22, 2008 David Pollak Not strict, but pretty lazy Lead developer for Lift web framework Scala since November 2006, Ruby/Rails,
More informationMulti-catch. Future Features. Sometimes we need to handle more than one exception in a single catch block:
1 Multi-catch Sometimes we need to handle more than one exception in a single catch block: try { // some code } catch (e: ExceptionA ExceptionB) { log(e); throw e; } Note that this is not proposing general
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative
More informationProgramovací jazyky F# a OCaml. Chapter 5. Hiding recursion using function-as-values
Programovací jazyky F# a OCaml Chapter 5. Hiding recursion using function-as-values Hiding the recursive part» Writing recursive functions explicitly let rec sum list = match list with [] -> 0 x::xs ->
More informationCSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings
More informationCSE341: Programming Languages Lecture 9 Function-Closure Idioms. Dan Grossman Fall 2011
CSE341: Programming Languages Lecture 9 Function-Closure Idioms Dan Grossman Fall 2011 More idioms We know the rule for lexical scope and function closures Now what is it good for A partial but wide-ranging
More informationProgramming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI
Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First
More informationBuilding Faster in Xcode
#WWDC18 Building Faster in Xcode Session 408 David Owens, Xcode Engineer Jordan Rose, Swift Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written
More informationCSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures
CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught
More informationTypes And Categories. Anat Gilboa
Types And Categories Anat Gilboa (@anat_gilboa) 1 Background 2 The Plan 3 The Plan https://github.com/hmemcpy/milewski-ctfp-pdf 4 The Plan 5 https://chrisdone.com/posts/monads-are-burritos 6 What to expect
More informationSwift, functional programming, and does it matter? Alexis
Swift, functional programming, and does it matter? Alexis Gallagher @alexisgallagher Questions What s new in Swift? Is Swift a functional programming language? And what is functional anyway? How useful
More informationMobile Application Programming. Swift Classes
Mobile Application Programming Swift Classes Swift Objects Classes, structures, and enums are all object types with different defaults in usage Classes are reference types that share the same object when
More informationProblems with Concurrency
with Concurrency February 14, 2012 1 / 27 s with concurrency race conditions deadlocks GUI source of s non-determinism deterministic execution model interleavings 2 / 27 General ideas Shared variable Shared
More informationProgramming in Scala Second Edition
Programming in Scala Second Edition Martin Odersky, Lex Spoon, Bill Venners artima ARTIMA PRESS WALNUT CREEK, CALIFORNIA Contents Contents List of Figures List of Tables List of Listings Foreword Foreword
More informationself Some(1) self y 1 .Some Optional, if let Optional<Int>.None Optional<Int>.None
let tq: Int? = 1 let b = tq.map { (a: Int) -> Int? in if a % 2 == 0 { return a else { return Optional.None if let _ = b { print("not nil") self Some(1) self y 1 f, : Optional.None public func
More informationBackground Type Classes (1B) Young Won Lim 6/28/18
Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
More informationCS 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 informationProblems with Concurrency. February 19, 2014
with Concurrency February 19, 2014 s with concurrency interleavings race conditions dead GUI source of s non-determinism deterministic execution model 2 / 30 General ideas Shared variable Access interleavings
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 informationan overview Alceste Scalas Programming languages reading group
an overview Alceste Scalas Programming languages reading group 31 October 2017 Scala: what s the hype about? Object oriented and functional programming language Runs on the JVM... interoperability with
More informationSwift by Practical Example. Justin Miller
Swift by Practical Example Justin Miller Mapbox @incanus77 Introduction Mobile lead at Mapbox Eleven years of Swift experience Not really :-) But Cocoa, yes; I started with Project Builder in 10.2, pre-xcode
More informationLectures Basics in Procedural Programming: Machinery
Lectures 3-4-5-6 Basics in Procedural Programming: Machinery February 21-28, 2014 2014-03-01 11:04:07 1/48 Lecture3-6E-2014.pdf (#21) Basics in Procedural Programming: Machinery Naming and Binding Mutable
More informationNotes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.)
Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.) David Haraburda January 30, 2013 1 Introduction Scala is a multi-paradigm language that runs on the JVM (is totally
More informationRichard Mallion. Swift for Admins #TEAMSWIFT
Richard Mallion Swift for Admins #TEAMSWIFT Apple Introduces Swift At the WWDC 2014 Keynote, Apple introduced Swift A new modern programming language It targets the frameworks for Cocoa and Cocoa Touch
More informationBuilding a testable mixed-codebase ios Framework
Building a testable mixed-codebase ios Framework Nikos Maounis ios Developer @Psy2k Christos Karaiskos ios Developer @karaiskc Outline Introduction and Motivation Distributing Libraries and Resources Design
More informationIntroduction to Mobile Development
Introduction to Mobile Development Building mobile applications can be as easy as opening up the IDE, throwing something together, doing a quick bit of testing, and submitting to an App Store all done
More informationIntroduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming
Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming The ML Programming Language General purpose programming language designed by Robin Milner in 1970 Meta Language
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 21 March 2 nd, 2016 GUI: notifiers Transition to Java What is the type of xs? let r = {contents = 3} let xs = [(fun () -> r.contents
More informationRecap: 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 informationBuilding Better Apps with Value Types in Swift Session 414
Developer Tools #WWDC15 Building Better Apps with Value Types in Swift Session 414 Doug Gregor Language Lawyer Bill Dudney Arranger of Bits 2015 Apple Inc. All rights reserved. Redistribution or public
More informationDeclarative concurrency. March 3, 2014
March 3, 2014 (DP) what is declarativeness lists, trees iterative comutation recursive computation (DC) DP and DC in Haskell and other languages 2 / 32 Some quotes What is declarativeness? ness is important
More informationScala : 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 informationCSE 230. Concurrency: STM. Slides due to: Kathleen Fisher, Simon Peyton Jones, Satnam Singh, Don Stewart
CSE 230 Concurrency: STM Slides due to: Kathleen Fisher, Simon Peyton Jones, Satnam Singh, Don Stewart The Grand Challenge How to properly use multi-cores? Need new programming models! Parallelism vs Concurrency
More informationConcepts of programming languages
Concepts of programming languages Something El(m)se Paolo Servillo, Enzo van Kessel, Jesse de Ruijter 1 Contents What is Elm? The language The architecture Transcompiling Elm in practice 2 What is Elm?
More informationAnnouncements. Lab 3 is due on Wednesday by 11:59 PM
Announcements Lab 3 is due on Wednesday by 11:59 PM Extensible Networking Platform 1 1 - CSE 438 Mobile Application Development Today s Topics Property Lists iphone s File System Archiving Objects SQLite
More informationKotlin for the Pragmatic Functionalist
Kotlin for the Pragmatic Functionalist Paco Estevez Kotlin logo: 2015-present - JetBrains KotlinConf logo: 2017 - JetBrains Kategory logo: 2017 present - The Kategory maintainers ReasonML logo: 2015 present
More informationHaskell An Introduction
Haskell An Introduction What is Haskell? General purpose Purely functional No function can have side-effects IO is done using special types Lazy Strongly typed Polymorphic types Concise and elegant A First
More informationRust intro. (for Java Developers) JFokus #jfokus 1. 1
Rust intro (for Java Developers) JFokus 2017 - #jfokus 1. 1 Hi! Computer Engineer Programming Electronics Math
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 24 Thursday, April 19, 2018 1 Error-propagating semantics For the last few weeks, we have been studying type systems.
More informationDavid Pollak CUFP September 26 th, 2008
Buy a Feature Adventure in Immutability and Actors David Pollak CUFP September 26 th, 2008 David Pollak Not strict, but pretty lazy Lead developer for Lift web framework Scala since November 2006, Ruby/Rails,
More informationStanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015
Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C
More informationClojure. A (not-so-pure) functional approach to concurrency. Paolo Baldan Linguaggi per il Global Computing AA 2016/2017
Clojure A (not-so-pure) functional approach to concurrency Paolo Baldan Linguaggi per il Global Computing AA 2016/2017 In the words of the inventor Functional programming (rooted in Lisp, from 60s old
More informationFunctional Programming Lecture 13: FP in the Real World
Functional Programming Lecture 13: FP in the Real World Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz 1 Mixed
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 informationProgramming language seminar The F# language. Peter Sestoft Wednesday Course plan
Programming language seminar 2011 The F# language Peter Sestoft Wednesday 2011-08-31 www.itu.dk 1 Course plan Four cycles, each containing a mini-project: F# Types and type inference Scala and Scala actors
More informationBE PROACTIVE USE REACTIVE
BE PROACTIVE USE REACTIVE This morning we re going to talk about reactive programming. We ll cover some of the what, why, and how, hopefully with a bend towards grasping the fundamentals. We ll have some
More information/ Cloud Computing. Recitation 13 April 17th 2018
15-319 / 15-619 Cloud Computing Recitation 13 April 17th 2018 Overview Last week s reflection Team Project Phase 2 Quiz 11 OLI Unit 5: Modules 21 & 22 This week s schedule Project 4.2 No more OLI modules
More informationHaskell in the corporate environment. Jeff Polakow October 17, 2008
Haskell in the corporate environment Jeff Polakow October 17, 2008 Talk Overview Haskell and functional programming System description Haskell in the corporate environment Functional Programming in Industry
More informationImproving STM Performance with Transactional Structs 1
Improving STM Performance with Transactional Structs 1 Ryan Yates and Michael L. Scott University of Rochester IFL, 8-31-2016 1 This work was funded in part by the National Science Foundation under grants
More informationTackling Concurrency With STM. Mark Volkmann 10/22/09
Tackling Concurrency With Mark Volkmann mark@ociweb.com 10/22/09 Two Flavors of Concurrency Divide and conquer divide data into subsets and process it by running the same code on each subset concurrently
More informationTackling Concurrency With STM
Tackling Concurrency With Mark Volkmann mark@ociweb.com 10/22/09 Two Flavors of Concurrency Divide and conquer divide data into subsets and process it by running the same code on each subset concurrently
More informationWhat s New in Foundation for Swift Session 207
App Frameworks #WWDC16 What s New in Foundation for Swift Session 207 Tony Parker Foundation, Apple Michael LeHew Foundation, Apple 2016 Apple Inc. All rights reserved. Redistribution or public display
More informationStanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016
Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling
More informationA Fourth Look At ML. Chapter Eleven Modern Programming Languages, 2nd ed. 1
A Fourth Look At ML Chapter Eleven Modern Programming Languages, 2nd ed. 1 Type Definitions Predefined, but not primitive in ML: datatype bool = true false; Type constructor for lists: datatype 'element
More informationArchitecture using Functional Programming concepts < + >
Architecture using Functional Programming concepts < + > Jorge Castillo @JorgeCastilloPr 1 2 Kotlin and Functional Programming FP means concern separation (declarative computations vs runtime execution),
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 informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques () Lecture 12 February 7, 2018 Partiality, Sequencing, Records Chapters 12, 13 Midterm 1 This Friday in class Review session Tonight, 6 7:30 PM DRLB A1 Announcements
More informationCS193E Lecture 14. Cocoa Bindings
CS193E Lecture 14 Cocoa Bindings Agenda Questions? Personal Timeline IV Key Value Coding Key Value Observing Key Value Binding Cocoa Bindings What are Cocoa Bindings? Added in Panther, more mature in Tiger
More informationThe story so far. Elements of Programming Languages. Pairs in various languages. Pairs
Elements of Programming Languages Lecture 6: Data structures James Cheney University of Edinburgh October 9, 2017 The story so far We ve now covered the main ingredients of any programming language: Abstract
More informationSymbolic Computation and Common Lisp
Symbolic Computation and Common Lisp Dr. Neil T. Dantam CSCI-56, Colorado School of Mines Fall 28 Dantam (Mines CSCI-56) Lisp Fall 28 / 92 Why? Symbolic Computing: Much of this course deals with processing
More informationTypical workflow. CSE341: Programming Languages. Lecture 17 Implementing Languages Including Closures. Reality more complicated
Typical workflow concrete synta (string) "(fn => + ) 4" Parsing CSE341: Programming Languages abstract synta (tree) Lecture 17 Implementing Languages Including Closures Function Constant + 4 Var Var Type
More informationRegistering for the Apple Developer Program
It isn t necessary to be a member of the Apple Developer Program if you don t intend to submit apps to the App Stores, or don t need the cloud-dependent features. We strongly recommend joining, though,
More informationSafe Smart Contract Programming with Scilla
Safe Smart Contract Programming with Scilla Ilya Sergey Associate Professor, Yale-NUS College Lead Language Designer, Zilliqa http://ilyasergey.net Smart Contracts Stateful mutable objects replicated via
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 informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second
More informationNews. 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 informationClustering in Go May 2016
Clustering in Go May 2016 Wilfried Schobeiri MediaMath http://127.0.0.1:3999/clustering-in-go.slide#1 1/42 Who am I? Go enthusiast These days, mostly codes for fun Focused on Infrastruture & Platform @
More informationAssignment I: Concentration
Assignment I: Concentration Objective The goal of this assignment is to recreate the demonstration given in lecture and then make some small enhancements. It is important that you understand what you are
More informationCombining Concurrency Abstractions
Combining Concurrency Abstractions Philipp Haller Typesafe, Switzerland Correctly and Efficiently Combining Concurrency Abstractions Philipp Haller Typesafe, Switzerland The Problem Tendency to combine
More information