







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In this short course we study the basic concept of the programming. In these lecture slides the key points are:Programming Thought, Different Language, Language Affects, Learn New Languages, Fundamental Building Blocks, Choose Right Language, Extensible System, Imperative Programming, Functional Programming, Mapreduce
Typology: Slides
1 / 13
This page cannot be seen from the preview
Don't miss anything!








Programming Languages
A Programming Language
L1: x++; y--; (y=0)?L2:L L2: …
Fact: This is “equivalent to” to every PL!
Good luck writing quicksort … or Windows, Google, Spotify!
So why study PL?
“ A different language is a different vision of life”
So why study PL?
Programming language
shapes
Programming thought
So why study PL?
Language affects how:
Course Goals
“Free your mind”
-Morpheus
Learn New Languages/Constructs
Goal: How to design new PLs …“who, me ?”
Buried in every extensible system is a PL
Enables you to choose right PL
My goal: educate tomorrow’s tech leaders & bosses, so you’ll make informed choices
Speaking of Right and Wrong...
Imperative
Programming
x = x+
WTF? x = x+1 Imperative = Mutation
Func%onal Programming?
No Assignment.
No Muta0on.
No Loops.
OMG! Who uses FP?!
So, Who Uses FP?
MapReduce
So, Who Uses FP?
Linq, F#
So, Who Uses FP?
So, Who Uses FP?
So, Who Uses FP?
So, Who Uses FP?
Interacting with ML
“Read-Eval-Print” Loop
Repeat:
What are these expressions, values and types?
Base type: Integers
Complex expressions using “operators”: (why the quotes ?)
(^2 )
int
2+2 (^4) 2 * (9+10) (^38) 2 * (9+10) -12 (^26)
Base type: Strings
Complex expressions using “operators”: (why the quotes ?)
“ab” (^) “ab”
string
“ab” ^ “xy” (^) “abxy”
Base type: Booleans
Complex expressions using “operators”:
true (^) true
bool
false (^) false 1 < (^2) true “aa” = “pq” (^) false (“aa” = “pq”) && (1<2) (^) false (“aa” = “aa”) && (1<2) (^) true
Type Errors
Untypable expression is rejected
(2+3) || (“a” = “b”)
(2 + “a”)
“pq” ^ 9
(2+2 , 7>8); (^) (4,false)
int * bool
(9-3,“ab”^“cd”,(2+2 ,7>8)) (^) (6, “abcd”,(4,false))
(int * string * (int * bool))
Complex types: Lists []; (^) [] ’a list
[1;2;3]; [1;2;3] int list
[“a”;“b”; “c”^“d”]; [“a”;“b”; “cd”] string list
[1+1;2+2;3+3;4+4]; [2;4;6;8] int list
[(1,“a”^“b”);(3+4,“c”)]; [(1,“ab”);(7,“c”)] (int*string) list [[1];[2;3];[4;5;6]]; (^) [[1];[2;3];[4;5;6]]; (int list) list
Complex types: Lists
List operator “tail”
int list tl ([“a”]@[“b”]); (^) [“b”] string list
tl [];
tl [1;2;3];
tl
Only take the tail of nonempty list
[2;3]
Recap: Tuples vs. Lists? What’s the difference?
(3, “abcd”) (int * string) (3, “abcd”,(3.5,4.2)) (int * string * (float* float))
[3;4;5;6;7] int list
So far, a fancy calculator…
… what do we need next?