tour of language landscape
TRANSCRIPT
ZOOZU
VAPA
BOROU
DUMBU
dark shades of blue, red, green & purple
white & some shades of yellow
some shades of green & blue
other shades of green, red & brown
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
R
FunScript AzureAmazon S3
CSVSQLiteSQL Server
WSDL
WorldBank
RegexODATA IKVM
FacebookApiary
XAMLFreebaseHadoop
Oracle
Minesweeper
Don SymePowershell
JSON
Fizzbuzz
Mixin
RSS
MatlabDates
NorthPole
XML
Python
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
“…a clean design is one that supports visual thinking so
people can meet their informational needs with a
minimum of conscious effort.”
- Daniel Higginbotham (www.visualmess.com)
@theburningmonk
Whilst talking with an ex-colleague, a question came up on how to implement the Stable Marriage problem using a message passing approach. Naturally, I wanted to answer that question with Erlang!
Let’s first dissect the problem and decide what processes we need and how they need to interact with one another.
The stable marriage problem is commonly stated as:Given n men and n women, where each person has ranked all members of the opposite sex with a unique number between 1 and n in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. If there are no such people, all the marriages are “stable”. (It is assumed that the participants are binary gendered and that marriages are not same-sex).From the problem description, we can see that we need:* a module for man* a module for woman* a module for orchestrating the experimentIn terms of interaction between the different modules, I imagined something along the lines of…
how we read ENGLISH
see also http://bit.ly/1KN8cd0
@theburningmonk
Whilst talking with an ex-colleague, a question came up on how to implement the Stable Marriage problem using a message passing approach. Naturally, I wanted to answer that question with Erlang!
Let’s first dissect the problem and decide what processes we need and how they need to interact with one another.
The stable marriage problem is commonly stated as:Given n men and n women, where each person has ranked all members of the opposite sex with a unique number between 1 and n in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. If there are no such people, all the marriages are “stable”. (It is assumed that the participants are binary gendered and that marriages are not same-sex).From the problem description, we can see that we need:* a module for man* a module for woman* a module for orchestrating the experimentIn terms of interaction between the different modules, I imagined something along the lines of…
2. top-to-bottom1.left-to-right
how we read ENGLISH
see also http://bit.ly/1KN8cd0
@theburningmonk
how we read CODE
public void DoSomething(int x, int y){ Foo(y, Bar(x, Zoo(Monkey())));}
see also http://bit.ly/1KN8cd0
@theburningmonk
how we read CODE
public void DoSomething(int x, int y){ Foo(y, Bar(x, Zoo(Monkey())));}
2. bottom-to-top
1.right-to-left
see also http://bit.ly/1KN8cd0
@theburningmonk
Whilst talking with an ex-colleague, a question came up on how to implement the Stable Marriage problem using a message passing approach. Naturally, I wanted to answer that question with Erlang!
Let’s first dissect the problem and decide what processes we need and how they need to interact with one another.
The stable marriage problem is commonly stated as:Given n men and n women, where each person has ranked all members of the opposite sex with a unique number between 1 and n in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. If there are no such people, all the marriages are “stable”. (It is assumed that the participants are binary gendered and that marriages are not same-sex).From the problem description, we can see that we need:* a module for man* a module for woman* a module for orchestrating the experimentIn terms of interaction between the different modules, I imagined something along the lines of…
2. top-to-bottom
1.left-to-right
how we read ENGLISH
public void DoSomething(int x, int y){ Foo(y, Bar(x, Zoo(Monkey())));}
2. top-to-bottom
1.right-to-left
how we read CODE
see also http://bit.ly/1KN8cd0
@theburningmonk
“…a clean design is one that supports visual thinking so
people can meet their informational needs with a
minimum of conscious effort.”
@theburningmonk
how we read CODE
let drawCircle x y radius = radius |> circle |> filled (rgb 150 170 150) |> alpha 0.5 |> move (x, y)
see also http://bit.ly/1KN8cd0
@theburningmonk
how we read CODE
let drawCircle x y radius = radius |> circle |> filled (rgb 150 170 150) |> alpha 0.5 |> move (x, y)
2. top-to-bottom1.left-to-right
see also http://bit.ly/1KN8cd0
@theburningmonk
let drawCircle x y radius = circle radius |> filled (rgb 150 170 150) |> alpha 0.5 |> move (x, y)
see also http://bit.ly/1KN8cd0
@theburningmonk
let drawCircle x y radius = circle radius |> filled (rgb 150 170 150) |> alpha 0.5 |> move (x, y)
see also http://bit.ly/1KN8cd0
@theburningmonk
let drawCircle x y radius = circle radius |> filled (rgb 150 170 150) |> alpha 0.5 |> move (x, y)
see also http://bit.ly/1KN8cd0
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
NASA orbiter crashed because one engineer accidentally used miles instead of kilometres
@theburningmonk
10<Meter> / 2<Second> = 5<Meter/Second>10<Meter> * 2<Second> = 20<Meter Second> 10<Meter> + 10<Meter> = 20<Meter>10<Meter> * 10 = 100<Meter>10<Meter> * 10<Meter> = 100<Meter2>10<Meter> + 2<Second> // error10<Meter> + 2 // error
@theburningmonk
10<Meter> / 2<Second> = 5<Meter/Second>10<Meter> * 2<Second> = 20<Meter Second> 10<Meter> + 10<Meter> = 20<Meter>10<Meter> * 10 = 100<Meter>10<Meter> * 10<Meter> = 100<Meter2>10<Meter> + 2<Second> // error10<Meter> + 2 // error
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
Homoiconicity
…homoiconicity is a property of some programming languages in which the program structure is similar to its syntax, and therefore the program’s internal representation can be
inferred by reading the text’s layout…
@theburningmonk
quote
(+ 1 2) => 3 (quote (+ 1 2)) => (+ 1 2)
see also http://bit.ly/1PpIrjS
@theburningmonk
quote
(+ 1 2) => 3 (quote (+ 1 2)) => (+ 1 2) ‘(+ 1 2) => (+ 1 2)see also http://bit.ly/1PpIrjS
@theburningmonk
eval
‘(+ 1 2) => (+ 1 2) (eval ‘(+ 1 2)) => 3
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
see also http://bit.ly/1PpIrjS
@theburningmonk
(assert-equals (inc 1) 2) ; => nil (assert-equals (inc 1) (+ 0 1)) ; => AssertionError FAIL in (inc 1) ; expected: (+ 0 1) ; actual: 2
see also http://bit.ly/1PpIrjS
@theburningmonk
(assert-equals (inc 1) 2) ; => nil (assert-equals (inc 1) (+ 0 1)) ; => AssertionError FAIL in (inc 1) ; expected: (+ 0 1) ; actual: 2
see also http://bit.ly/1PpIrjS
@theburningmonk
(assert-equals (inc 1) 2) ; => nil (assert-equals (inc 1) (+ 0 1)) ; => AssertionError FAIL in (inc 1) ; expected: (+ 0 1) ; actual: 2
huh?? where? what? how?
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
(assert-equals (inc 1) (+ 0 1))
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
(assert-equals (inc 1) (+ 0 1))
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
(assert-equals (inc 1) (+ 0 1))
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
see also http://bit.ly/1PpIrjS
@theburningmonk
(defmacro assert-equals [actual expected] ‘(let [actual-val# ~actual] (when-not (= actual-val# ~expected) (throw (AssertionError. (str “FAIL in “ ‘~actual “\n expected: “ ‘~expected “\n actual: “ actual-val#))))))
‘(
see also http://bit.ly/1PpIrjS
@theburningmonk
(macroexpand '(assert-equals (inc 1) (+ 0 1))) ; => ; (let* [actual-value__16087__auto__ (inc 1)] ; (clojure.core/when-not ; (clojure.core/= actual-value__16087__auto__ (+ 0 1)) ; (throw (java.lang.AssertionError. ; (clojure.core/str ; "FAIL in " (quote (inc 1)) ; "\nexpected: " (quote (+ 0 1)) ; "\n actual: " actual-value__16087__auto__)))))
see also http://bit.ly/1PpIrjS
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
fn foo() { // v has ownership of the vector let v = vec![1, 2, 3]; // mutable binding let mut v2 = vec![]; } // vector is deallocated at the // end of scope, // this happens deterministically
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
// moved ownership to v2 let v2 = v;
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
// moved ownership to v2 let v2 = v;
println!("v[0] is {}", v[0]); // error: use of moved value: `v` // println!("v[0] is {}", v[0]); // ^
see also http://bit.ly/1F6WBVD
@theburningmonk
fn take(v : Vec<i32>) { // ownership of vector transferred // to v in this scope }
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
// moved ownership take(v);
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
// moved ownership take(v);
println!("v[0] is {}", v[0]); // error: use of moved value: `v` // println!("v[0] is {}", v[0]); // ^
see also http://bit.ly/1F6WBVD
@theburningmonk
// note we're taking a reference, // &Vec<i32>, instead of Vec<i32> fn take(v : &Vec<i32>) { // no need to deallocate the vector // after we go out of scope here }
see also http://bit.ly/1F6WBVD
@theburningmonk
// take ownership let v = vec![1, 2, 3];
// notice we're passing a reference, // &v, instead of v take(&v); // borrow ownership
println!("v[0] is {}", v[0]); // v[0] is 1
see also http://bit.ly/1F6WBVD
@theburningmonk
fn take(v : &Vec<i32>) { v.push(5); }
let v = vec![]; take(&v); // cannot borrow immutable borrowed // content `*v` as mutable // v.push(5); // ^
see also http://bit.ly/1F6WBVD
@theburningmonk
fn take(v : &mut Vec<i32>) { v.push(5); }
let mut v = vec![]; take(&mut v);
println!("v[0] is {}", v[0]); // v[0] is 5
see also http://bit.ly/1F6WBVD
@theburningmonk
Rule 1.the borrower’s scope must not
outlast the owner
see also http://bit.ly/1F6WBVD
@theburningmonk
Rule 2.one of the following, but not both:
2.1 0 or more refs to a resource 2.2 exactly 1 mutable ref
see also http://bit.ly/1F6WBVD
@theburningmonk
data race
There is a ‘data race’ when two or more pointers access the same memory location at the same time, where at least one of them is writing, and
the operations are not synchronised.
see also http://bit.ly/1F6WBVD
@theburningmonk
data race
a. two or more pointers to the same resourceb. at least one is writingc. operations are not synchronised
see also http://bit.ly/1F6WBVD
@theburningmonk
Data Race Conditionsa. two or more pointers to the same resourceb. at least one is writingc. operations are not synchronised
Borrowing Rulesone of the following, but not both:
2.1 0 or more refs to a resource 2.2 exactly 1 mutable ref
see also http://bit.ly/1F6WBVD
@theburningmonk
Data Race Conditionsa. two or more pointers to the same resourceb. at least one is writingc. operations are not synchronised
Borrowing Rulesone of the following, but not both:
2.1 0 or more refs to a resource 2.2 exactly 1 mutable ref
see also http://bit.ly/1F6WBVD
@theburningmonk
Dependent Types
Uniqueness Types
Bit Syntax
Borrowed Pointers
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Signals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
Type Provider Pipes
Statically Resolved TP Implicit Interface Implementation
Borrowed Pointers Dependent Types
Uniqueness Types
Bit SyntaxSignals
Macros
Unit-of-Measure
Actor Model
@theburningmonk
10,000 hours to be good at something
see also http://bit.ly/1KN7SLq
@theburningmonk
10,000 hours to be good at something
see also http://bit.ly/1KN7SLq
@theburningmonk
10,000 hours to reach top of an ultra-
competitive field
see also http://bit.ly/1KN7SLq
@theburningmonk
the first 20 hours - how to learn anything
see also http://bit.ly/1KN7SLq
@theburningmonk
Practice Time
How
goo
d yo
u ar
e
see also http://bit.ly/1KN7SLq
@theburningmonk
1.Deconstruct the skill2.Learn enough to self-correct
see also http://bit.ly/1KN7SLq
@theburningmonk
1.Deconstruct the skill2.Learn enough to self-correct3.Remove practice barriers
see also http://bit.ly/1KN7SLq
@theburningmonk
1.Deconstruct the skill2.Learn enough to self-correct3.Remove practice barriers4.Practice at least 20 hrs
see also http://bit.ly/1KN7SLq
@theburningmonk
learn a new paradigmnot a new syntax
see also http://bit.ly/1IzXVSo
“Programming languages have a devious influence: they shape our thinking
habits.”
- Edsger W. Dijkstra
@theburningmonk
“A language that doesn't affect the way you think
about programming, is not worth knowing.”
- Alan Perlis
@theburningmonk
“Learning is an act of creation itself, because something
happens in you that wasn't there before.”
- Alan Kay