]> gitweb.factorcode.org Git - factor-talks.git/blob - minneapolis-talk/minneapolis-talk.factor
Remove "talks." namespace.
[factor-talks.git] / minneapolis-talk / minneapolis-talk.factor
1 USING: slides help.markup math arrays hashtables namespaces
2 sequences kernel parser memoize ;
3 IN: minneapolis-talk
4
5 CONSTANT: minneapolis-slides
6 {
7     { $slide "What is Factor?"
8         "Dynamically typed, stack language"
9         "Have our cake and eat it too"
10         "Research -vs- production"
11         "High level -vs- performance"
12         "Interactive -vs- stand-alone apps"
13     }
14     { $slide "The view from 10,000 feet"
15         "Influenced by Forth, Lisp, Joy, Smalltalk, even Java..."
16         "Vocabularies: modules"
17         "Words: named functions, classes, variables"
18         "Combinators: higher-order functions"
19         "Quotations: anonymous functions"
20     }
21     { $slide "Stack-based programming"
22         { "Most languages are " { $emphasis "applicative" } }
23         "Words pop inputs from the stack and push outputs on the stack"
24         "Literals are pushed on the stack"
25         { $code "{ 1 2 } { 7 } append reverse sum ." }
26     }
27     { $slide "Stack-based programming"
28         "With the stack you can omit unnecessary names"
29         "You can still name things: lexical/dynamic variables, sequences, associations, objects, ..."
30     }
31     { $slide "Functional programming"
32         "A quotation is a sequence of literals and words"
33         "Combinators replace imperative-style loops"
34         "A simple example:"
35         { $code "10 [ \"Hello world\" print ] times" }
36         { "Partial application: " { $link curry } }
37         { $code "{ 3 1 3 3 7 } [ 5 + ] map ." }
38         { $code "{ 3 1 3 3 7 } 5 [ + ] curry map ." }
39     }
40     { $slide "Word definitions"
41         { $code ": name ( inputs -- outputs )"
42         "    definition ;" }
43         "Stack effect comments document stack inputs and outputs."
44         "Example from previous slide:"
45         { $code ": add-each ( seq n -- newseq )"
46         "    [ + ] curry map ;" }
47         { $code "{ 3 1 3 3 7 } 5 add-each ." }
48     }
49     { $slide "Object-oriented programming"
50         { "Define a tuple class and a constructor:"
51         { $code
52             "TUPLE: person name address ;"
53             "C: <person> person"
54         } }
55         { "Create an instance:"
56         { $code
57             "\"Cosmo Kramer\""
58             "\"100 Blah blah St, New York\""
59             "<person>"
60         } }
61     }
62     { $slide "Object-oriented programming"
63         "We can inspect it and edit objects"
64         "We can reshape the class!"
65         { $code "TUPLE: person" "name address age phone-number ;" }
66         { $code "TUPLE: person" "name address phone-number age ;" }
67     }
68     { $slide "An example"
69         { $code
70             "TUPLE: square dimension ;"
71             "C: <square> square"
72             ""
73             "TUPLE: circle radius ;"
74             "C: <circle> circle"
75             ""
76             "TUPLE: rectangle width height ;"
77             "C: <rectangle> rectangle"
78         }
79     }
80     STRIP-TEASE:
81         $slide "An example"
82         { $code
83             "USE: math.constants"
84             "GENERIC: area ( shape -- meters^2 )"
85             "M: square area square-dimension sq ;"
86             "M: circle area circle-radius sq pi * ;"
87             "M: rectangle area"
88             "    dup rectangle-width"
89             "    swap rectangle-height * ;"
90         }
91     ;
92
93     { $slide "An example"
94         { $code "10 <square> area ." }
95         { $code "18 <circle> area ." }
96         { $code "20 40 <rectangle> area ." }
97     }
98     { $slide "Meta language"
99         "Here's fibonacci:"
100         { $code
101             ": fib ( x -- y )"
102             "    dup 1 > ["
103             "        1 - dup fib swap 1 - fib +"
104             "    ] when ;"
105         }
106         "It is slow:"
107         { $code
108             "35 <iota> [ fib ] map ."
109         }
110         "Let's profile it!"
111     }
112     { $slide "Memoization"
113         { { $link POSTPONE: : } " is just another word" }
114         "What if we could define a word which caches its results?"
115         { "The " { $vocab-link "memoize" } " library provides such a feature" }
116         { "Just change " { $link POSTPONE: : } " to " { $link POSTPONE: MEMO: } }
117     }
118     { $slide "Memoization"
119         { $code
120             "USE: memoize"
121             ""
122             "MEMO: fib ( x -- y )"
123             "    dup 1 > ["
124             "        1 - dup fib swap 1 - fib +"
125             "    ] when ;"
126         }
127         "It is faster:"
128         { $code
129             "35 <iota> [ fib ] map ."
130         }
131     }
132     { $slide "The Factor UI"
133         "Written in Factor"
134         "Renders with OpenGL"
135         "Backends for Windows, X11, Cocoa"
136         "You can call Windows, X11, Cocoa APIs directly too"
137         "OpenGL 2.1 shaders, OpenAL 3D audio..."
138     }
139     { $slide "Live coding demo"
140
141     }
142     { $slide "C library interface"
143         "Efficient"
144         "No need to write C code"
145         "Supports floats, structs, unions, ..."
146         "Function pointers, callbacks"
147     }
148     { $slide "Live coding demo"
149
150     }
151     { $slide "Deployment"
152         { "Let's play " { $vocab-link "tetris" } }
153     }
154     { $slide "Implementation"
155         "Portable: Windows, Mac OS X, Linux"
156         "Non-optimizing compiler"
157         "Optimizing compiler: x86, x86-64, PowerPC, ARM"
158         "Generational garbage collector"
159         "Non-blocking I/O"
160     }
161     { $slide "Some statistics"
162         "VM: 11,800 lines of C"
163         "Core library: 22,600 lines of Factor"
164         "Docs, tests, extra libraries: 117,000 lines of Factor"
165     }
166     { $slide "But wait, there's more!"
167         "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, ..."
168     }
169     { $slide "Community"
170         "Factor development began in 2003"
171         "About a dozen contributors"
172         "Handful of \"core contributors\""
173         { "Web site: " { $url "http://factorcode.org" } }
174         "IRC: #concatenative on irc.freenode.net"
175         "Mailing list: factor-talk@lists.sf.net"
176     }
177     { $slide "Questions?" }
178 }
179
180 : minneapolis-talk ( -- )
181     minneapolis-slides "Minneapolis talk" slides-window ;
182
183 MAIN: minneapolis-talk