declarative thinking programming
play

Declarative Thinking & Programming Florian Wilhelm - PowerPoint PPT Presentation

Declarative Thinking & Programming Florian Wilhelm EuroPython, Rimini, 2017-07-13 Dr. Florian Wilhelm Data Scientist@inovex Contributor to Pandas, Scikit-Learn, Scipy etc. @FlorianWilhelm Creator of PyScaffold FlorianWilhelm


  1. Declarative Thinking & Programming Florian Wilhelm EuroPython, Rimini, 2017-07-13

  2. Dr. Florian Wilhelm Data Scientist@inovex Contributor to Pandas, Scikit-Learn, Scipy etc. � @FlorianWilhelm Creator of PyScaffold FlorianWilhelm � florianwilhelm.info 2

  3. Outline 1. Motivation & Concept 2. Examples 3. Math Riddle 3

  4. Motivation House-warming party with your friends 4

  5. Motivation What is the actual task? 5

  6. Level of Abstraction Right level of abstraction given a task What is needed to describe the problem? map & reduce 6

  7. Imperative vs. Declarative How vs. What declarative imperative separation of over-specification, concerns, single detailed level of abstraction, instructions, ... ... depending on the level of abstraction 7

  8. Leaky Abstractions Law of Leaky Abstractions by Spolsky: “All non-trivial abstractions, to some degree, are leaky.” 8

  9. Outline 1. Motivation & Concept 2. Examples 3. Math Riddle 9

  10. Example 1: List Comprehensions List of squared number from 1 to 10 imperative : declarative : 10

  11. Example 2: Dispatching with respect to some argument Imperative: 11

  12. Example 2: Dictionaries Dispatching with respect to some argument Declarative: 12

  13. Example 3: Sets Find Plagiarism How many sentences of work A are equal to my work B? Set Theory 13

  14. Example 4: Configuration Files Python modules vs markup languages YAML vs 14

  15. Outline 1. Motivation & Concept 2. Examples 3. Math Riddle 15

  16. Math Riddle horizontal: A: digit sum of horizontal C, C: prime number, E: palindrome, G: multiple of the backward number of horizontal A, ... vertical: All numbers are square numbers. Quelle: Die Zeit, Logelei 52, http://www.zeit.de/2016/52/spiele-logelei-52 16

  17. Datalog Features • declarative logic programming • subset of Prolog • query language for deductive DBs • other use-cases: security, data integration, information extraction, networking, program analysis etc. PyDatalog: https://sites.google.com/site/pydatalog/home 17

  18. PyDatalog Rules & Facts Is X a square number? Read the leftmost <= as if Is X divisible by Y? 18

  19. PyDatalog Rules & Facts Is X prime? 19

  20. PyDatalog Rules & Facts Map digits to number 20

  21. Math Riddle Leaky Abstraction Keep the number of solutions low at all times 21

  22. Math Riddle Upper left corner A2, A3 are digits from [1...9] and number A2 A3 is prime 22

  23. Math Riddle Solution Querying the knowledge base: Solution: http://www.florianwilhelm.info/2017/07/declarative_thinking_and_programming/ 23

  24. Other Applications NixOS 24

  25. Summary Advantages of Declarative Programming • improved readability of our code • reduced number of errors • increased performance • separation of concerns „Declarative programming means finding the right abstraction level describing the problem“ 25

  26. Thanks for your Attention! Questions? Find more details under http://florianwilhelm.info/2017/07/declarative_thinking_and_programming/ 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend