make world Chris Smowton University of Cambridge spell-rite - - PowerPoint PPT Presentation

make world chris smowton university of cambridge
SMART_READER_LITE
LIVE PREVIEW

make world Chris Smowton University of Cambridge spell-rite - - PowerPoint PPT Presentation

make world Chris Smowton University of Cambridge spell-rite /usr/share/real_words ~/nonsense spell-rite /usr/share/real_words ~/nonsense spell-rite /usr/share/real_words ~/nonsense /usr/share/real_words ~/nonsense /usr/share/real_words


slide-1
SLIDE 1

make world Chris Smowton University of Cambridge

slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4

spell-rite

/usr/share/real_words ~/nonsense

slide-5
SLIDE 5

spell-rite

/usr/share/real_words ~/nonsense

slide-6
SLIDE 6

spell-rite

/usr/share/real_words ~/nonsense

slide-7
SLIDE 7

/usr/share/real_words

~/nonsense

slide-8
SLIDE 8

$> echo “quexalcote” >> /usr/share/real_words $> make speaknspell

/usr/share/real_words

~/nonsense

slide-9
SLIDE 9

int f(bool x, int y) { if(x) { return 42; } else { return y; } }

slide-10
SLIDE 10

int f(bool x, int y) { if(x) { return 42; } else { return y; } }

x == true

slide-11
SLIDE 11

int f(int y) { if(true) { return 42; } else { return y; } }

slide-12
SLIDE 12

int f(int y) { if(true) { return 42; } else { return y; } }

slide-13
SLIDE 13

return 42;

slide-14
SLIDE 14

void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }

slide-15
SLIDE 15

void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }

“/usr/share/dict” is “aardvark, ...”

slide-16
SLIDE 16

void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }

slide-17
SLIDE 17

void spell(char* text) { Machine* m = apply_machine(m, text); }

slide-18
SLIDE 18

void apply_machine( ) { // There are no words! }

slide-19
SLIDE 19

void apply_machine( ) { // No word contains “$”! }

slide-20
SLIDE 20

int f() { int x = 5; x = pow(x, x); printf(x); }

slide-21
SLIDE 21

int f() { int x = 5; x = pow(x, x); printf(x); }

x?

slide-22
SLIDE 22

int f() { int x = 5; x = pow(x, x); printf(x); }

x == 3125 return x ** x;

slide-23
SLIDE 23

void spell() { ... read(dict_fd, buf); ... }

slide-24
SLIDE 24

void spell() { ... read(dict_fd, buf); ... }

buf?

slide-25
SLIDE 25

void spell() { ... read(dict_fd, buf); ... }

buf == “quexalcote\n”

slide-26
SLIDE 26

int wordcount() { fd = open(“~/stuff”); while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

slide-27
SLIDE 27

int wordcount() { fd = <”~/stuff”, pos=0>; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

slide-28
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
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
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
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
SLIDE 32

int wordcount() { fd = <”~/stuff”, pos=10>; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

slide-33
SLIDE 33

int wordcount() { return 42; }

slide-34
SLIDE 34

int wordcount() { count = 42; fd = <”~/stuff”, pos=200> ... }

slide-35
SLIDE 35

int wordcount() { count = 42; fd = open(“~/stuff”); lseek(fd, 200, SEEK_SET); }

slide-36
SLIDE 36

Challenges

  • Adaptive optimisation
  • IPC and servers
  • Efficiency
slide-37
SLIDE 37

Summary

  • Make programs better!
  • No manual work!