4. • Horse-power of many-core…
• …but how to program those? Concurrent
• Schematized, static, dynamic…
• …so, what’s the sweet spot? Dynamic
• New level of expressiveness…
• …how about the essence? Functional
5.
6. Dynamic
Languages
Simple and succinct
Implicitly typed
Meta-programming
No compilation
Static
Languages
Robust
Performant
Intelligent tools
Better scaling
9. Theory of Computation
(Lambda Calculus, Alonzo Church)
LISP Heritage
Reality of Hardware
Fortran Heritage (Memory, John Von Neumann)
ML
SmallTalk
C
Java
C++
C#
Scheme
Haskell
10. var res = xs.Where(C# x => x % 2 == 0);
Visual Basic Dim res = xs.Where(Function(x) x Mod 2 = 0)
F# let res = xs |> Seq.filter (fun x -> x % 2 = 0);
var res = xs.filter(function(x) {
return x % 2 == 0;
});
JavaScript
auto res = find_if(xs.begin(), xs.end(), [] (int i) {
return x % 2 == 0;
});
C++11
11. First class functions
FP
Immutable
data
Referential
transparency
Algebraic data types
Type
inference
Pattern
matching
Essence
Niceties
14. “Local” Inference
• Confine your focus to a single
declaration
• Compute the type directly
• Move on to the next one…
• Can't infer parameter types…
15.
16.
17.
18.
19.
20.
21.
22. Pros
• Mostly intuitive behavior
• Very simple to implement
• (the compiler does this work anyway)
23.
24.
25.
26.
27.
28.
29.
30.
31. “Global” Inference
• Look at the literals
• Look at the functions and other values
something interacts with
• Look at any explicit type constraints
• If there are no constraints anywhere,
automatically generalize to generic types
46. //start an instance of the firefox browser
start firefox
//go to url
url "http://lefthandedgoat.github.io/canopy/testpages/"
//assert that the element with an id of 'welcome' has
//the text 'Welcome‘
"#welcome" == "Welcome"
47. project "F# DSL Article" starts "01/01/2009"
resource "Dmitri" isa "Writer" with_rate 140
resource "Computer" isa "Dumb Machine" with_rate 0
group "DSL Popularization" done_by "Dmitri"
task "Create basic estimation DSL" takes 1 day
task "Write article" takes 1 day
task "Post article and wait for comments" takes 1 week
group "Infrastructure Support" done_by "Computer"
task "Provide VS2010 and MS Project" takes 1 day
task "Download and deploy TypograFix" takes 1 day
task "Sit idly while owner waits for comments" takes 1 week
prepare my_project