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

Few Versatile vs. Many Specialized Collections: How to design a collection library for exploratory programming?

Few Versatile vs. Many Specialized Collections: How to design a collection library for exploratory programming?

While an integral part of all programming languages, the design of collection libraries is rarely studied. This work briefly reviews the collection libraries of 14 languages to identify possible design dimensions. Some languages have surprisingly few but versatile collections, while others have large libraries with many specialized collections. Based on the identified design dimensions, we argue that a small collection library with only a sequence, a map, and a set type are a suitable choice to facilitate exploratory programming. Such a design minimizes the number of decisions programmers have to make when dealing with collections, and it improves discoverability of collection operations. We further discuss techniques that make their implementation practical from a performance perspective. Based on these arguments, we conclude that languages which aim to support exploratory programming should strive for small and versatile collection libraries.

Stefan Marr

April 10, 2018
Tweet

More Decks by Stefan Marr

Other Decks in Programming

Transcript

  1. Few Versatile vs. Many Specialized
    Collections
    How to design a collection library for
    exploratory programming?
    Stefan Marr, Benoit Daloze
    PX/18
    10 April 2018
    http://stefan-marr.de/papers/px-marr-daloze-few-versatile-vs-many-specialized-collections/

    View full-size slide

  2. 2
    Opinion
    Paper
    Worst case: you simply agree

    View full-size slide

  3. How to design a collection library?
    ?
    3
    ? ?

    View full-size slide

  4. What do existing systems do?
    4
    C/C++
    C#

    View full-size slide

  5. Five* Design Dimensions
    • Collection types
    • Language style
    • Properties
    • Operation design
    • Algorithms, data structures, implementation
    choices
    5
    * Probably more, but a start

    View full-size slide

  6. Exploratory Programming
    Programming
    ✓ Domain ???
    6
    Tax Codes
    Routing
    Algorithms
    Machine
    Learning
    Protein
    Folding
    ? ?
    ?

    View full-size slide

  7. A Design for Exploratory Programming
    Collection Types
    sequences, maps, sets
    7
    SEQ[1, 2, 3]
    MAP{a: 1, b: 2}
    SET{1, 2, 3}
    array, list, vector
    multimap
    stack, queue

    View full-size slide

  8. A Design for Exploratory Programming
    Language Style
    OO, FP, …, typed/untyped, templates, …
    Defined by Language, but:
    Adaptive optimizations better than explicit choices
    Types: might require hiding of superfluous details
    8

    View full-size slide

  9. A Design for Exploratory Programming
    Properties
    Choose Defaults
    variable sized, ordered, thread safe
    Offer opt-in/opt-out for special cases!
    9
    array
    list
    SEQ[1, 2, 3]

    View full-size slide

  10. A Design for Exploratory Programming
    Operation Design
    All you can need!
    Optimized for discoverability via
    completion/suggestions
    10

    View full-size slide

  11. A Design for Exploratory Programming
    Algorithms, data structures,
    implementation choices
    Abstraction is bliss!
    Delegate choices to VM
    11
    ArrayList
    LinkedList
    SEQ[1, 2, 3]

    View full-size slide

  12. For Exploratory Programming:
    12
    Few but Versatile!
    SEQ[1, 2, 3]
    MAP{a: 1, b: 2}
    SET{1, 2, 3}
    Defaults + Opt In/Out
    All operations you can need!
    Abstraction is bliss!

    View full-size slide