Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Papers we love: Elixir edition

Papers we love: Elixir edition

Andrea Leopardi

July 16, 2018
Tweet

More Decks by Andrea Leopardi

Other Decks in Programming

Transcript

  1. PAPERS WE LOVE
    ELIXIR EDITION
    PAPERS WE LOVE
    ELIXIR EDITION

    View Slide

  2. @whatyouhide

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. “You know Yelp?
    Yeah, but for weed”– me

    View Slide

  9. View Slide

  10. View Slide

  11. “You know Uber Eats?”– me

    View Slide

  12. View Slide

  13. weedmaps.com/careers

    View Slide

  14. ELIXIR
    functional
    concurrent
    fault tolerant

    View Slide

  15. The Elixir core team

    View Slide

  16. we existing research

    View Slide

  17. Formatting code
    Diffing data structures
    Property-based testing ⚙

    View Slide

  18. FORMATTING CODE

    View Slide

  19. Code formatter
    welcoming to newcomers
    consistency across teams/orgs/community
    no style discussions

    View Slide

  20. print code with line length limit

    View Slide

  21. %{foo: [1, 2, 3], bar: "baz"}

    View Slide

  22. %{foo: [1, 2, 3], bar: "baz"}
    30

    View Slide

  23. %{foo: [1, 2, 3], bar: "baz"}
    25

    View Slide

  24. %{
    foo: [1, 2, 3],
    bar: "baz"
    }
    25

    View Slide

  25. %{
    foo: [1, 2, 3],
    bar: "baz"
    }
    13

    View Slide

  26. %{
    foo: [
    1,
    2,
    3
    ],
    bar: "baz"
    }
    13

    View Slide

  27. The Design of a Pretty-printing Library
    John Hughes

    View Slide

  28. Documents
    "text"
    concat(document1, document2)
    nest(document, columns)

    View Slide

  29. "["
    |> concat("1,")
    |> concat("2,")
    |> concat("3")
    |> concat("]")
    [1, 2, 3]

    View Slide

  30. "["
    |> line("1,")
    |> line("2,")
    |> line("3")
    |> nest(2)
    |> line("]")
    [
    1,
    2,
    3
    ]

    View Slide

  31. A Prettier Printer
    Philip Wadler

    View Slide

  32. group(
    "["
    |> concat("1,")
    |> concat("2,")
    |> concat("3")
    |> nest(2)
    |> concat("]")
    )
    [
    1,
    2,
    3
    ]

    View Slide

  33. choose(
    doc,
    replace_concat_with_line_break(doc)
    ) DANGER:
    STRICT LANGUAGE AHEAD

    View Slide

  34. Strictly Pretty
    Christian Lindig

    View Slide

  35. Our documents
    color(doc, :blue)
    nest(doc, :cursor)
    ...

    View Slide

  36. DIFFING
    DATA STRUCTURES

    View Slide

  37. 1) test two strings are different (Test)
    test.ex:6
    Assertion with == failed
    code: assert "hello world!" == "Hello, my world"
    left: "hello world!"
    right: "Hello, my world"
    stacktrace:
    test.ex:7: (test)

    View Slide

  38. View Slide

  39. An O(ND) Difference Algorithm
    and Its Variations
    Eugene W. Myers

    View Slide

  40. “Find the shortest edit script to turn
    a sequence A into a sequence B.”
    = Find shortest path
    in a graph

    View Slide

  41. O(ND)
    D is related to how
    "similar" the two
    sequences are
    DNA strand mutation
    source code changes

    View Slide

  42. iex> List.myers_difference([1, 4, 2, 3], [1, 2, 3, 4])
    [eq: [1], del: [4], eq: [2, 3], ins: [4]]

    View Slide

  43. Now colorize

    View Slide

  44. No modifications to
    the paper this time

    View Slide

  45. String Matching with Metric Trees
    Using an Approximate Distance
    Ilaria Bartolini, Paolo Ciaccia, Marco Patella

    View Slide

  46. PROPERTY-BASED
    TESTING

    View Slide

  47. Shape of input
    Properties of output
    +
    +
    Randomness
    =
    Property-based testing

    View Slide

  48. check all list <- list_of(term()) do
    sorted = sort(list)
    assert is_list(sorted)
    assert length(list) == length(sorted)
    end

    View Slide

  49. String.starts_with?(s1 <> s2, s1)
    String.ends_with?(s1 <> s2, s2)
    For any strings s1 and s2:

    View Slide

  50. Only Erlang tools
    (with different license)

    View Slide

  51. QuickCheck: A Lightweight Tool for
    Random Testing of Haskell Programs
    Koen Classen John Hughes

    View Slide

  52. all the base ideas are there
    but it relies too
    heavily on types

    View Slide

  53. data Colour = Red | Blue | Green
    instance Arbitrary Colour where
    arbitrary = oneof
    [return Red, return Blue, return Green]

    View Slide

  54. (prop/for-all [v (gen/vector gen/int)]
    (= (sort v) (sort (sort v))))
    Clojure's test.check

    View Slide

  55. StreamData
    check all s1 <- string(),
    s2 <- string() do
    assert String.starts_with?(s1 <> s2, s1)
    assert String.ends_with?(s1 <> s2, s2)
    end

    View Slide

  56. Generators
    functions that take
    some random state
    and return a lazy tree

    View Slide

  57. Lazy tree
    a value plus a "recipe"
    for shrinking it

    View Slide

  58. StreamData.integer()
    3
    0
    2
    0
    1
    0

    View Slide

  59. StreamData.integer()
    3
    0
    2
    0
    1
    0

    View Slide

  60. map(StreamData.integer(), fn x -> x * 2 end)
    3 * 2
    0 * 2
    2 * 2
    0 * 2
    1 * 2
    0 * 2

    View Slide

  61. map(StreamData.integer(), fn x -> x * 2 end)
    6
    0
    4
    0
    2
    0

    View Slide

  62. HONORABLE
    MENTIONS

    View Slide

  63. How to make ad-hoc
    polymorphism less ad hoc
    Philip Wadler
    Stephen Blott

    View Slide

  64. Recursive functions of
    symbolic expressions and their
    computation by machine
    John McCarthy

    View Slide

  65. Advances in record
    linkage methodology as
    applied to the 1985
    census of Tampa Florida
    Matthew A. Jaro

    View Slide

  66. Iteratee: Teaching an Old
    Fold New Tricks
    John W. Lato

    View Slide

  67. CONCLUSIONS

    View Slide

  68. Existing research
    is AWESOME

    View Slide

  69. Research tends to solve problems in a
    general/simple/flexible/elegant way

    View Slide

  70. HDD
    Hughes-driven development

    View Slide

  71. @whatyouhide

    View Slide