SLIDE 1 make world Chris Smowton University of Cambridge
SLIDE 2
SLIDE 3
SLIDE 4 spell-rite
/usr/share/real_words ~/nonsense
SLIDE 5 spell-rite
/usr/share/real_words ~/nonsense
SLIDE 6 spell-rite
/usr/share/real_words ~/nonsense
SLIDE 7 /usr/share/real_words
~/nonsense
SLIDE 8 $> echo “quexalcote” >> /usr/share/real_words $> make speaknspell
/usr/share/real_words
~/nonsense
SLIDE 9
int f(bool x, int y) { if(x) { return 42; } else { return y; } }
SLIDE 10
int f(bool x, int y) { if(x) { return 42; } else { return y; } }
x == true
SLIDE 11
int f(int y) { if(true) { return 42; } else { return y; } }
SLIDE 12
int f(int y) { if(true) { return 42; } else { return y; } }
SLIDE 13
return 42;
SLIDE 14
void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }
SLIDE 15
void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }
“/usr/share/dict” is “aardvark, ...”
SLIDE 16
void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }
SLIDE 17
void spell(char* text) { Machine* m = apply_machine(m, text); }
SLIDE 18
void apply_machine( ) { // There are no words! }
SLIDE 19
void apply_machine( ) { // No word contains “$”! }
SLIDE 20
int f() { int x = 5; x = pow(x, x); printf(x); }
SLIDE 21
int f() { int x = 5; x = pow(x, x); printf(x); }
x?
SLIDE 22
int f() { int x = 5; x = pow(x, x); printf(x); }
x == 3125 return x ** x;
SLIDE 23
void spell() { ... read(dict_fd, buf); ... }
SLIDE 24
void spell() { ... read(dict_fd, buf); ... }
buf?
SLIDE 25
void spell() { ... read(dict_fd, buf); ... }
buf == “quexalcote\n”
SLIDE 26
int wordcount() { fd = open(“~/stuff”); while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
SLIDE 27
int wordcount() { fd = <”~/stuff”, pos=0>; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
SLIDE 28
int wordcount() { fd = <”~/stuff”, pos=0>; if(eof) return count; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
SLIDE 29 int wordcount() { fd = <”~/stuff”, pos=0>; if(eof) return count; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
Not EOF yet! Not EOF yet!
SLIDE 30 int wordcount() { fd = <”~/stuff”, pos=0>; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
buf == “aardvark\n”
SLIDE 31
int wordcount() { fd = <”~/stuff”, pos=0>; read(fd, buf); if(strstr(“aardvark”, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
SLIDE 32
int wordcount() { fd = <”~/stuff”, pos=10>; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }
SLIDE 33
int wordcount() { return 42; }
SLIDE 34
int wordcount() { count = 42; fd = <”~/stuff”, pos=200> ... }
SLIDE 35
int wordcount() { count = 42; fd = open(“~/stuff”); lseek(fd, 200, SEEK_SET); }
SLIDE 36 Challenges
- Adaptive optimisation
- IPC and servers
- Efficiency
SLIDE 37 Summary
- Make programs better!
- No manual work!