summaryrefslogtreecommitdiff
path: root/minneapolis-talk/minneapolis-talk.factor
blob: 7c0a02cdfd3320d91155a03fe5798ac40e8cb2b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
USING: slides help.markup math arrays hashtables namespaces
sequences kernel parser memoize ;
IN: minneapolis-talk

CONSTANT: minneapolis-slides
{
    { $slide "What is Factor?"
        "Dynamically typed, stack language"
        "Have our cake and eat it too"
        "Research -vs- production"
        "High level -vs- performance"
        "Interactive -vs- stand-alone apps"
    }
    { $slide "The view from 10,000 feet"
        "Influenced by Forth, Lisp, Joy, Smalltalk, even Java..."
        "Vocabularies: modules"
        "Words: named functions, classes, variables"
        "Combinators: higher-order functions"
        "Quotations: anonymous functions"
    }
    { $slide "Stack-based programming"
        { "Most languages are " { $emphasis "applicative" } }
        "Words pop inputs from the stack and push outputs on the stack"
        "Literals are pushed on the stack"
        { $code "{ 1 2 } { 7 } append reverse sum ." }
    }
    { $slide "Stack-based programming"
        "With the stack you can omit unnecessary names"
        "You can still name things: lexical/dynamic variables, sequences, associations, objects, ..."
    }
    { $slide "Functional programming"
        "A quotation is a sequence of literals and words"
        "Combinators replace imperative-style loops"
        "A simple example:"
        { $code "10 [ \"Hello world\" print ] times" }
        { "Partial application: " { $link curry } }
        { $code "{ 3 1 3 3 7 } [ 5 + ] map ." }
        { $code "{ 3 1 3 3 7 } 5 [ + ] curry map ." }
    }
    { $slide "Word definitions"
        { $code ": name ( inputs -- outputs )"
        "    definition ;" }
        "Stack effect comments document stack inputs and outputs."
        "Example from previous slide:"
        { $code ": add-each ( seq n -- newseq )"
        "    [ + ] curry map ;" }
        { $code "{ 3 1 3 3 7 } 5 add-each ." }
    }
    { $slide "Object-oriented programming"
        { "Define a tuple class and a constructor:"
        { $code
            "TUPLE: person name address ;"
            "C: <person> person"
        } }
        { "Create an instance:"
        { $code
            "\"Cosmo Kramer\""
            "\"100 Blah blah St, New York\""
            "<person>"
        } }
    }
    { $slide "Object-oriented programming"
        "We can inspect it and edit objects"
        "We can reshape the class!"
        { $code "TUPLE: person" "name address age phone-number ;" }
        { $code "TUPLE: person" "name address phone-number age ;" }
    }
    { $slide "An example"
        { $code
            "TUPLE: square dimension ;"
            "C: <square> square"
            ""
            "TUPLE: circle radius ;"
            "C: <circle> circle"
            ""
            "TUPLE: rectangle width height ;"
            "C: <rectangle> rectangle"
        }
    }
    STRIP-TEASE:
        $slide "An example"
        { $code
            "USE: math.constants"
            "GENERIC: area ( shape -- meters^2 )"
            "M: square area square-dimension sq ;"
            "M: circle area circle-radius sq pi * ;"
            "M: rectangle area"
            "    dup rectangle-width"
            "    swap rectangle-height * ;"
        }
    ;

    { $slide "An example"
        { $code "10 <square> area ." }
        { $code "18 <circle> area ." }
        { $code "20 40 <rectangle> area ." }
    }
    { $slide "Meta language"
        "Here's fibonacci:"
        { $code
            ": fib ( x -- y )"
            "    dup 1 > ["
            "        1 - dup fib swap 1 - fib +"
            "    ] when ;"
        }
        "It is slow:"
        { $code
            "35 <iota> [ fib ] map ."
        }
        "Let's profile it!"
    }
    { $slide "Memoization"
        { { $link POSTPONE: : } " is just another word" }
        "What if we could define a word which caches its results?"
        { "The " { $vocab-link "memoize" } " library provides such a feature" }
        { "Just change " { $link POSTPONE: : } " to " { $link POSTPONE: MEMO: } }
    }
    { $slide "Memoization"
        { $code
            "USE: memoize"
            ""
            "MEMO: fib ( x -- y )"
            "    dup 1 > ["
            "        1 - dup fib swap 1 - fib +"
            "    ] when ;"
        }
        "It is faster:"
        { $code
            "35 <iota> [ fib ] map ."
        }
    }
    { $slide "The Factor UI"
        "Written in Factor"
        "Renders with OpenGL"
        "Backends for Windows, X11, Cocoa"
        "You can call Windows, X11, Cocoa APIs directly too"
        "OpenGL 2.1 shaders, OpenAL 3D audio..."
    }
    { $slide "Live coding demo"

    }
    { $slide "C library interface"
        "Efficient"
        "No need to write C code"
        "Supports floats, structs, unions, ..."
        "Function pointers, callbacks"
    }
    { $slide "Live coding demo"

    }
    { $slide "Deployment"
        { "Let's play " { $vocab-link "tetris" } }
    }
    { $slide "Implementation"
        "Portable: Windows, Mac OS X, Linux"
        "Non-optimizing compiler"
        "Optimizing compiler: x86, x86-64, PowerPC, ARM"
        "Generational garbage collector"
        "Non-blocking I/O"
    }
    { $slide "Some statistics"
        "VM: 11,800 lines of C"
        "Core library: 22,600 lines of Factor"
        "Docs, tests, extra libraries: 117,000 lines of Factor"
    }
    { $slide "But wait, there's more!"
        "Web server and framework, syntax highlighting, Ogg Theora video, SMTP, embedded Prolog, efficient unboxed arrays, XML, Unicode 5.0, memory mapped files, regular expressions, LDAP, database access, coroutines, Factor->JavaScript compiler, JSON, pattern matching, advanced math, parser generators, serialization, RSS/Atom, ..."
    }
    { $slide "Community"
        "Factor development began in 2003"
        "About a dozen contributors"
        "Handful of \"core contributors\""
        { "Web site: " { $url "http://factorcode.org" } }
        "IRC: #concatenative on irc.freenode.net"
        "Mailing list: factor-talk@lists.sf.net"
    }
    { $slide "Questions?" }
}

: minneapolis-talk ( -- )
    minneapolis-slides "Minneapolis talk" slides-window ;

MAIN: minneapolis-talk