Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with...

25
Rethinking compilers Rethinking compilers with live coding with live coding Tomas Petricek Tomas Petricek , Alan Turing Institute + fsharpWorks , Alan Turing Institute + fsharpWorks | | | | @tomaspetricek @tomaspetricek tomasp.net tomasp.net fsharpworks.com fsharpworks.com

Transcript of Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with...

Page 1: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Rethinking compilersRethinking compilers with live codingwith live coding

Tomas PetricekTomas Petricek, Alan Turing Institute + fsharpWorks , Alan Turing Institute + fsharpWorks | | | | @tomaspetricek@tomaspetricek tomasp.nettomasp.net fsharpworks.comfsharpworks.com

Page 2: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Welcome to the Welcome to the post-factpost-fact world world

Page 3: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net
Page 4: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Can the result be Can the result be reproducedreproduced??

Is the visualization Is the visualization misleadingmisleading??

Can the reader Can the reader explore furtherexplore further??

Page 5: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

The GammaThe Gamma

Page 6: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Making Making data sciencedata science easier easier

Page 7: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net
Page 8: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net
Page 9: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net
Page 10: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net
Page 11: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

DEMODEMOLive previews in TheGammaLive previews in TheGamma

Page 12: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

TEXTBOOK COMPILERSTEXTBOOK COMPILERS

Page 13: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Textbook compiler Textbook compiler is batch basedis batch based

Textbook compiler Textbook compiler builds & transforms treesbuilds & transforms trees

Textbook compiler Textbook compiler rejects bad programsrejects bad programs

Page 14: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

ExampleExample - live image processing - live image processing

let pope = image.load("pope.png") let shadow = image.load("shadow.png")

shadow.greyScale().blur(5) .combine(pope, 50)

Page 15: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

SKETCHSKETCHTransforming abstract syntax treesTransforming abstract syntax trees

Page 16: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

DEMODEMOWriting a batch evaluatorWriting a batch evaluator

Page 17: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

LIVE COMPILERSLIVE COMPILERS

Page 18: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Live compiler Live compiler caches earlier resultscaches earlier results

Live compiler Live compiler builds dependency graphsbuilds dependency graphs

Live compiler Live compiler accepts bad programsaccepts bad programs

Page 19: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

SKETCHSKETCHBuilding a dependency graphBuilding a dependency graph

Page 20: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

DEMODEMOWriting a graph-based evaluatorWriting a graph-based evaluator

Page 21: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

SUMMARYSUMMARY

Page 22: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Check out Check out TheGammaTheGamma project projectAnd help make facts great again!

www.thegamma.net

gamma.turing.ac.uk

Page 23: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

F# languageF# language

Pragmatic functional-first programming

Fable compilerFable compiler

F# to JavaScript compilerfor the 21st century

www.fsharp.org www.fable.io

Page 24: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Dependency graphsDependency graphs over syntax trees over syntax trees

Reusing nodesReusing nodes enables caching enables caching

Good luck writing a decent parser :-)Good luck writing a decent parser :-)

Page 25: Rethinking compilers with live coding - Lambda Days · 2018-02-26 · Rethinking compilers with live coding Tomas Petricek, Alan Turing Institute + fsharpWorks @tomaspetricek | tomasp.net

Now you know how to writeNow you know how to write your own live coding environment!your own live coding environment!

Questions?Questions?

Tomas PetricekTomas Petricek, Alan Turing Institute + fsharpWorks , Alan Turing Institute + fsharpWorks | | | | @tomaspetricek@tomaspetricek tomasp.nettomasp.net fsharpworks.comfsharpworks.com