180 likes | 367 Views
Programmeren met Algebra. André van Delft 6 februari 2012 Presentatie op Grotius College Delft. CV. 1979-1985 Studie Wiskunde in Leiden 1982-1985 Studie Bedrijfskunde in Delft/Rotterdam 1985-1989 Promotieplaats Informatica in Leiden 1989-2006 Software-ontwikkelaar op contractbasis
E N D
Programmeren met Algebra André van Delft 6 februari 2012 Presentatie op Grotius College Delft
CV • 1979-1985 Studie Wiskunde in Leiden • 1982-1985 Studie Bedrijfskunde in Delft/Rotterdam • 1985-1989 Promotieplaats Informatica in Leiden • 1989-2006 Software-ontwikkelaar op contractbasis • 2006-2012 Wetenschapper bij NATO/NC3A • Onderzoek & Ontwikkeling van Programmeertalen • Parallelisme • Grootheden & Eenheden • Rare talen
Programmeren moeilijk sinds 1995 • Meerdere taken tegelijk: threading • Hoofdtaak Main thread • Langdurige taken Background thread • Schermafhandeling GUI thread • Gebeurtenissen (event handling) & communicatie • Toetsenbord, muis, touch screen • GPS, sensoren • Internet, Bluetooth • Programmeertalen: C C++Java, C# Scala Geen oplossing…
GUI-applicatie - 1 • Invoerveld • Zoekknop • Zoeken… • Resultaten
GUI-applicatie - 2 valsearchButton = new Button("Go”) { reactions.+= { caseButtonClicked(b) => enabled = false outputTA.text = "Starting search...” new Thread(new Runnable { defrun() { Thread.sleep(3000) SwingUtilities.invokeLater(new Runnable{ defrun() {outputTA.text="Search ready” enabled = true }}) }}).start } }
GUI-applicatie - 3 live = searchSequence... searchSequence = searchCommand showSearchingText searchInDatabase showSearchResults searchCommand= searchButton showSearchingText = @gui: {outputTA.text = "…"} showSearchResults = @gui: {outputTA.text = "…"} searchInDatabase = {* Thread.sleep(3000) *}
GUI-applicatie - 4 • Zoeken: knop of Enter-toets • Afbreken: knop of Escape-toets • Exit: knop of ; daarna: “Are yousure?”… • Alleen zoeken als tekstveld gevuld is • Voortgang tonen
GUI-applicatie - 5 searchGuard = if(!searchTF.text.isEmpty) . anyEvent(comp) ... searchInDatabase = {*Thread.sleep(3000)*} || progressMonitor progressMonitor = {*Thread.sleep( 250)*} @gui:{searchTF.text+=here.pass} ... live = searchSequence... || exit searchCommand = searchButton + Key.Enter cancelCommand = cancelButton + Key.Escape exitCommand = exitButton+ windowClosing exit = exitCommand@gui: while(!areYouSure) cancelSearch = cancelCommand @gui: showCanceledText searchSequence = searchGuardsearchCommand; showSearchingText searchInDatabase showSearchResults / cancelSearch
Process Algebra Wiskundige theorie over processen Bergstra&Klop, Amsterdam, 1982 x+y = y+x (x+y)+z = x+(y+z) x+x = x (x+y)·z = x·z+y·z (x·y)·z = x·(y·z) O+x = x O·x = O 1·x = x x·1 = x δ+x = x δ·x = δ ε·x = x x·ε = x x y = x y + y x + x|y (x+ε)·y = x·y+ε·y = x·y+y
Werking: Templates & Call Graphs {Hello}+ε; {World} (x+ε)·y = x·y+ε·y = x·y+y
Slot • Eenvoudig en efficiënt • Nu 2000 regels Scala • Nog veel te doen en te ontdekken • Open Source:http://code.google.com/p/subscript/ • www.rosettacode.org …
Hello World http://rosettacode.org/wiki/Hello_world/Text C: #include <stdio.h> intmain(void) { printf(”Hello, World!\n”); return 0; } HQ9+: H C0H: C1R: Hello_world/Text
100 Doors C: #include <stdio.h> intmain() { int door, square, increment; for(door = 1, square = 1, increment = 1; door <= 100; door++ == square && (square += increment += 2)) printf("door #%d is %s.\n", door, (door == square? "open" : "closed")); return0; } http://rosettacode.org/wiki/100_doors C1R: 100_doors • Stupid • Thismeans thatnearlyevery C1R "solution" in Rosetta is simply a heading, followedby string whichgives the path name to the C solution. Thisis a form of redundancythat is effectively spam. • David St. Hubbins: It's such a fine line betweenstupid, and uh... • Nigel Tufnel: Clever. • David St. Hubbins: Yeah, and clever.
Zeef van Eratosthenes - 2 main = generator(2,1000000) ==> (..==>sieve) =={toPrint}==> printer generator(s,e) = for(i<-s to e) <=i sieve = =>p:Int? @toPrint:<=p; ..=>i:Int? if (i%p!=0) <=i printer = ..=>i:Int? println,i <==>(i:Int) = {}