A presentation at LambdaDays in in Kraków, Poland by Brooklyn Zelenka
BRIDGING THE DIVIDE 💔 ❤ ✨⚔ A NOBLE QUEST OF BOOTSTRAPS, SUGAR, AND SPECTRAL PYRAMIDS 🐉⚡
BRIDGING THE DIVIDE 💔 ✨⚔ A NOBLE QUEST OF BOOTSTRAPS, SUGAR, AND SPECTRAL PYRAMIDS 🐉⚡
If you don’t like what you got Why don’t you change it If your programming language is all screwed up Rearrange it 🤘😈🔥 TROOPER, “RAISE A LIT TLE HELL” (SORT OF)
M E TA TA L K I N G A B O U T T H I S T A L K
M E TA TA L K I N G A B O U T T H I S T A L K
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🔹 Ethereum Core Dev
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🔹 Ethereum Core Dev 📜 Authored bunch of standards
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🔹 Ethereum Core Dev 📜 Authored bunch of standards ⚛ FISSION Framework
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🔹 Ethereum Core Dev 📜 Authored bunch of standards ⚛ FISSION Framework 💬 Clarity Language
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🔹 Ethereum Core Dev 📜 Authored bunch of standards ⚛ FISSION Framework 💬 Clarity Language 🧙 Open Sourceress
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🧙 Open Sourceress 🔹 Ethereum Core Dev 🤓 PLT Enthusiast 📜 Authored bunch of standards ⚛ FISSION Framework 💬 Clarity Language
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🧙 Open Sourceress 🔹 Ethereum Core Dev 🤓 PLT Enthusiast 📜 Authored bunch of standards λ Founded VanFP ⚛ FISSION Framework 💬 Clarity Language
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🧙 Open Sourceress 🔹 Ethereum Core Dev 🤓 PLT Enthusiast 📜 Authored bunch of standards λ Founded VanFP ⚛ FISSION Framework ⚗ Previously Elixir consultant & trainer 💬 Clarity Language
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🧙 Open Sourceress 🔹 Ethereum Core Dev 🤓 PLT Enthusiast 📜 Authored bunch of standards λ Founded VanFP ⚛ FISSION Framework ⚗ Previously Elixir consultant & trainer 💬 Clarity Language 📚 Witchcraft, Algae, Quark, Exceptional
M E TA B R O O K LY N Z E L E N K A — @ E X P E D E ♠ CEO & Chief Scientist @ SPADE Co 🧙 Open Sourceress 🔹 Ethereum Core Dev 🤓 PLT Enthusiast 📜 Authored bunch of standards λ Founded VanFP ⚛ FISSION Framework ⚗ Previously Elixir consultant & trainer 💬 Clarity Language 📚 Witchcraft, Algae, Quark, Exceptional T E G E M CO KERS! C I T S
M E TA FOLLOW UP TO LOVE POTION NUMBER 9
M E TA FOLLOW UP TO LOVE POTION NUMBER 9
M E TA STRUCTURE 🏛
M E TA STRUCTURE 🏛 • Philosophy
M E TA STRUCTURE 🏛 • Philosophy • Principles
M E TA STRUCTURE 🏛 • Philosophy • Principles • Toy Example
M E TA STRUCTURE 🏛 • Philosophy • Principles • Toy Example • (Partly also an experience report 🤫)
M E TA WHY FOCUS ON LIBRARIES? 📚
M E TA WHY FOCUS ON LIBRARIES? 📚 • Much material on language design • Language ergonomics are an active area of research
M E TA WHY FOCUS ON LIBRARIES? 📚 • Much material on language design • Language ergonomics are an active area of research • Different constraints when working inside an existing language
M E TA WHY FOCUS ON LIBRARIES? 📚 • Much material on language design • Language ergonomics are an active area of research • Different constraints when working inside an existing language • Blending languages and porting concepts
M E TA WHY FOCUS ON LIBRARIES? 📚 • Much material on language design • Language ergonomics are an active area of research • Different constraints when working inside an existing language • Blending languages and porting concepts • I agonized over how to make Haskell idioms fit into Elixir • Learn from my mistakes experiences!
M E TA C O D E I L L U S T R AT I O N S W I L L B E H I G H L E V E L
M E TA C O D E I L L U S T R AT I O N S W I L L B E H I G H L E V E L
M E TA C O D E I L L U S T R AT I O N S W I L L B E H I G H L E V E L
M E TA C O D E I L L U S T R AT I O N S W I L L B E H I G H L E V E L
TOOLS OF THOUGHT 🛠🧠 A P P L I C AT I O N S C O M E A N D G O , B U T C O N C E P T S S TAY T H E S A M E
To think is to forget a difference, to generalize, to abstract 🙂 JORGE LUIS BORGES
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals • 24-hours and 360-degrees have nice divisors
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals • 24-hours and 360-degrees have nice divisors
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals • 24-hours and 360-degrees have nice divisors Flavours 🍨🍧
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals • 24-hours and 360-degrees have nice divisors Flavours 🍨🍧 1. Algorithms (“how”) • ex. Long division
TOOLS OF THOUGHT 🛠🧠 TOOLS & ME THODS > BIOLOGY 🏕🔥🚀 • Possibly use our minds less than our ancestors • We have better mental tools 🏹🔥 • Metric > Imperial • Arabic numerals > Roman numerals • 24-hours and 360-degrees have nice divisors Flavours 🍨🍧 1. Algorithms (“how”) • ex. Long division 2. Abstraction (“what”) • ex. Geometric metaphors
TOOLS OF THOUGHT 🛠🧠 N O T J U S T FA S T E R H O R S E S = 🏎
TOOLS OF THOUGHT 🛠🧠 N O T J U S T FA S T E R H O R S E S = 🏎 • Algorithms > hardware • Moore’s Law ending ☠ • Algorithms more beneficial to performance in many domains
TOOLS OF THOUGHT 🛠🧠 N O T J U S T FA S T E R H O R S E S = 🏎 • Algorithms > hardware • Moore’s Law ending ☠ • Algorithms more beneficial to performance in many domains • Abstraction very important to software quality • Because of the “human” part of HCI • (Of course a PLT person would say this 😜)
TOOLS OF THOUGHT 🛠🧠 N O T J U S T FA S T E R H O R S E S = 🏎 • Algorithms > hardware • Moore’s Law ending ☠ • Algorithms more beneficial to performance in many domains • Abstraction very important to software quality • Because of the “human” part of HCI • (Of course a PLT person would say this 😜) • Recent successes A • Machine learning • Zero knowledge proofs
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction 💭 Concepts & Practice
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction 💭 Concepts & Practice 🗣 Grammar & Vocabulary
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction 💭 Concepts & Practice 🗣 Grammar & Vocabulary 📝 Concrete Code
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction 💭 Concepts & Practice 🗣 Grammar & Vocabulary 📝 Concrete Code ⚙ Machine
TOOLS OF THOUGHT 🛠🧠 P L AT O N I C I D E A L 👼 🌌 Reality 🤔 Philosophy 🔺 Abstraction 💭 Concepts & Practice 🗣 Grammar & Vocabulary 📝 Concrete Code ⚙ Machine 🎭 Real World Outcomes
TOOLS OF THOUGHT 🛠🧠 FORKING & BLENDING 🍰 🌌 🤔 🔺 💭 Context A 🗣 📝 ⚙ 🎭
TOOLS OF THOUGHT 🛠🧠 FORKING & BLENDING 🍰 🌌 🤔 🔺 💭 Context A 🗣 📝 ⚙ 🎭
TOOLS OF THOUGHT 🛠🧠 FORKING & BLENDING 🍰 🌌 🤔 🔺 💭 Context A 🗣 📝 ⚙ 🎭
TOOLS OF THOUGHT 🛠🧠 FORKING & BLENDING 🍰 🌌 🤔 🔺 💭 Context A 🗣 🗣 📝 📝 ⚙ 🎭 Context B
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality • Low information • Few assumptions • Many use cases
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases GENERALITY 🌏 ⚖ POWER 🚀
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases GENERALITY 🌏 ⚖ POWER 🚀
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases Enum GENERALITY 🌏 ⚖ POWER 🚀
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases Enum GENERALITY 🌏 Ecto.Schema ⚖ POWER 🚀
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases GenServer Enum GENERALITY 🌏 Ecto.Schema ⚖ POWER 🚀
TOOLS OF THOUGHT 🛠🧠 LIBRARY SWEE T SPOTS 🍭 Generality Power • Low information • High information • Few assumptions • Can make many assumptions • Many use cases • Tailored to few use cases GenServer Enum Libraries GENERALITY 🌏 Ecto.Schema ⚖ POWER 🚀 Applications
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚 • Generality • ex. Witchcraft, Database Adapters
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚 • Generality • ex. Witchcraft, Database Adapters • Framework • ex. Phoenix, Nerves
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚 • Generality • ex. Witchcraft, Database Adapters • Framework • ex. Phoenix, Nerves • Feature Emulation • ex. TypeClass
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚 • Generality • ex. Witchcraft, Database Adapters • Framework • ex. Phoenix, Nerves • Feature Emulation • ex. TypeClass • Representation & Interface • ex. Algae, Serialization
TOOLS OF THOUGHT 🛠🧠 A TA X O N O M Y O F L I B R A R I E S 📚 • Generality • ex. Witchcraft, Database Adapters • Framework • ex. Phoenix, Nerves • Feature Emulation • ex. TypeClass • Representation & Interface • ex. Algae, Serialization • Patterns • ex. Quark, Exceptional
PORTING PRINCIPLES STRE TCHING WITHOUT SNAPPING 💥
It’s dangerous to go alone! Take this [advice]!
PORTING PRINCIPLES M O T I VAT I O N 🥕
PORTING PRINCIPLES M O T I VAT I O N 🥕 • Two styles of Scala 1. Java without the braces 2. Haskell fan fiction
PORTING PRINCIPLES M O T I VAT I O N 🥕 • Two styles of Scala 1. Java without the braces 2. Haskell fan fiction • “I’d need to convert my entire project for this lib to make sense” 👎
PORTING PRINCIPLES M O T I VAT I O N 🥕 • Two styles of Scala 1. Java without the braces 2. Haskell fan fiction • “I’d need to convert my entire project for this lib to make sense” 👎 • Also have seen this antipattern in production with Ruby, Swift, and JS
PORTING PRINCIPLES M O T I VAT I O N 🥕 • Two styles of Scala 1. Java without the braces 2. Haskell fan fiction • “I’d need to convert my entire project for this lib to make sense” 👎 • Also have seen this antipattern in production with Ruby, Swift, and JS • It doesn’t have to be this way 🚀
PORTING PRINCIPLES I, LIBRARY 🤖
PORTING PRINCIPLES I, LIBRARY 🤖
PORTING PRINCIPLES I, LIBRARY 🤖
PORTING PRINCIPLES I, LIBRARY 🤖
PORTING PRINCIPLES
PORTING PRINCIPLES HEY! LISTEN! 🧚 1. Courage ⚔ Each unit of code must be able to be taken on its own. An extension may not break nor alter the runtime semantics of either enclosed or exterior code. 2. Wisdom 📚 An extension must remain consistent with the character of the host language and broadest community standards, except where such consistency would conflict with the First Law. 3. Power 🚀 An extension must introduce or integrate its concept(s) as completely as possible, as long as such constructs do not conflict with the First or Second Laws.
CONTEXT INDEPENDENCE THE COURAGE TO VENTURE ALONE ⚔
CONTEXT INDEPENDENCE THE COURAGE TO VENTURE ALONE ⚔
The art of programming is the art of organizing complexity, of mastering multitude, and avoiding its bastard chaos as effectively as possible 🧘 EDSGER DIJKSTRA
Each unit of code must be able to be taken on its own. An extension must not break nor alter the runtime semantics of either enclosed or exterior code.
CONTEXT INDEPENDENCE I N D E P E N D E N C E D AY 🛸
CONTEXT INDEPENDENCE I N D E P E N D E N C E D AY 🛸 • Clarity, composability, and unambiguity • Same class of thing as referential transparency • Especially important with FP assumptions • Each chunk of code (horizontal or vertical) should be comprehensible on its own • Most common: behaviour depending on implicit or hidden state
CONTEXT INDEPENDENCE M A C R O S O K AY
CONTEXT INDEPENDENCE M A C R O S O K AY • Despite structural changes from macros • No macro mangle 🙅 • You have to try pretty hard to break this in Elixir
CONTEXT INDEPENDENCE CASE STUDY: Algae
CONTEXT INDEPENDENCE CASE STUDY: Algae • Concept: Bootstrap structs into ADTs
CONTEXT INDEPENDENCE CASE STUDY: Algae • Concept: Bootstrap structs into ADTs • Takeaway: Composition, orthogonality, structured abstraction
CONTEXT INDEPENDENCE CASE STUDY: Algae • Concept: Bootstrap structs into ADTs • Takeaway: Composition, orthogonality, structured abstraction • Removes nothing
CONTEXT INDEPENDENCE CASE STUDY: Algae • Concept: Bootstrap structs into ADTs • Takeaway: Composition, orthogonality, structured abstraction • Removes nothing • Adds • Structure DSL • Types with automatic default values • Manual default values • Constructor helpers (ex. Foo.new)
CONTEXT INDEPENDENCE CASE STUDY: Algae • Concept: Bootstrap structs into ADTs • Takeaway: Composition, orthogonality, structured abstraction • Removes nothing • Adds • Structure DSL • Types with automatic default values • Manual default values • Constructor helpers (ex. Foo.new) • Turns into vanilla Elixir
CONTEXT INDEPENDENCE CASE STUDY: Algae
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE CASE STUDY: Algae All the features!
CONTEXT INDEPENDENCE 42 CASE STUDY: Algae 77 All the features! 1234 98 32
CONTEXT INDEPENDENCE 42 CASE STUDY: Algae 77 All the features! 1234 98 32
CONTEXT INDEPENDENCE 42 CASE STUDY: Algae 77 All the features! 1234 98 32
ETHOS T H E W I S D O M TO B A L A N C E C O N S I ST E N CY, C H A N G E , A N D R E ST R A I N T 📚
ETHOS T H E W I S D O M TO B A L A N C E C O N S I ST E N CY, C H A N G E , A N D R E ST R A I N T 📚
The utility of a language as a tool of thought increases with the range of topics it can treat, but decreases with the amount of vocabulary and the complexity of grammatical rules which the user must keep in mind 🎛 KENNETH IVERSON
An extension must remain consistent with the character of the host language and broadest community standards, except where such consistency would conflict with the First Law.
ETHOS A M AT T E R O F C H A R A C T E R
ETHOS A M AT T E R O F C H A R A C T E R • Ethos — noun. (/ˈiːθɒs/ or US: /ˈiːθoʊs/) The fundamental character or spirit of a culture; the underlying sentiment that informs the beliefs, customs, or practices of a group or society; dominant assumptions of a people or period • Like all interesting things, it’s the fuzziest • Feel as close to the host language as possible • But also blending in features from a target
ETHOS A M AT T E R O F C H A R A C T E R 🌌 • Ethos — noun. (/ˈiːθɒs/ or US: /ˈiːθoʊs/) 🤔 The fundamental character or spirit of a culture; the underlying sentiment that informs the beliefs, customs, or practices of a group or society; dominant assumptions of a people or period • Like all interesting things, it’s the fuzziest • Feel as close to the host language as possible • But also blending in features from a target 🔺 💭 Host 🗣 📝 ⚙ 🎭
ETHOS A M AT T E R O F C H A R A C T E R 🌌 • Ethos — noun. (/ˈiːθɒs/ or US: /ˈiːθoʊs/) 🤔 The fundamental character or spirit of a culture; the underlying sentiment that informs the beliefs, customs, or practices of a group or society; dominant assumptions of a people or period • Like all interesting things, it’s the fuzziest • Feel as close to the host language as possible • But also blending in features from a target 🔺 💭 Host 🗣 🗣 🗣 📝 📝 📝 ⚙ 🎭 Target
ETHOS CASE STUDY: Exceptional’S PIPES
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2 • Consistent flow metaphor / punning on existing metaphor • Exceptional: ~>/2 and >>>/2
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2 • Consistent flow metaphor / punning on existing metaphor • Exceptional: ~>/2 and >>>/2
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2 • Consistent flow metaphor / punning on existing metaphor • Exceptional: ~>/2 and >>>/2
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2 • Consistent flow metaphor / punning on existing metaphor • Exceptional: ~>/2 and >>>/2
ETHOS CASE STUDY: Exceptional’S PIPES • Concept: Flow-ability is very core to Elixir’s ethos • Kernel.|>/2 • Consistent flow metaphor / punning on existing metaphor • Exceptional: ~>/2 and >>>/2
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional • Exception structs are totally antithetical to the Erlang ethos • Hard when you’re trying to be highly interoperable
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional • Exception structs are totally antithetical to the Erlang ethos • Hard when you’re trying to be highly interoperable
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional • Exception structs are totally antithetical to the Erlang ethos • Hard when you’re trying to be highly interoperable • Takeaway: Provide conversion functions if you go off script
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional • Exception structs are totally antithetical to the Erlang ethos • Hard when you’re trying to be highly interoperable • Takeaway: Provide conversion functions if you go off script
ETHOS CASE STUDY: TUPLES VS EXCEPTIONS • Even internal tradeoffs in Elixir’s Kernel design • Fully adhering to the underlying Elixir’s ethos • I get the most positive feedback from Exceptional • Exception structs are totally antithetical to the Erlang ethos • Hard when you’re trying to be highly interoperable • Takeaway: Provide conversion functions if you go off script
ETHOS STRONG CHARACTER
ETHOS STRONG CHARACTER • Languages like C, Haskell, Rust, Elm, and Golang stand for something
ETHOS STRONG CHARACTER • Languages like C, Haskell, Rust, Elm, and Golang stand for something • Erlang designed for a practical application: telecom switches • Erlang happened to land on FP
ETHOS STRONG CHARACTER • Languages like C, Haskell, Rust, Elm, and Golang stand for something • Erlang designed for a practical application: telecom switches • Erlang happened to land on FP • Elixir doesn’t have a clear language-level raison d’être • Like tofu: very easy to port in other flavours
INTERLUDE WHEREFORE ART THOU FUNCTIONAL PROGRAMMING? 🌹
INTERLUDE W H AT ’ S S O G R E AT A B O U T F P A N Y W AY ? 🥳
INTERLUDE W H AT ’ S S O G R E AT A B O U T F P A N Y W AY ? 🥳 • Modularity • Composition • Can describe general solutions via abstraction! • Make the large feel like the small & fewer patterns to memorize Z • Maleable code • HOFs transform your programs on the fly ⚗ • ex. Enum.map/2 can be seen as adapting every item in a structure (operational), or as transforming the functor
INTERLUDE O P E R AT I O N A L V S D E N O TAT I O N A L T H I N K I N G
INTERLUDE O P E R AT I O N A L V S D E N O TAT I O N A L T H I N K I N G • Enum.map/2 can be seen through the lens of… • Data • A cleaner for loop (operational) • Run a function on every item in a structure • Programs • Transforms the input program into a new program
INTERLUDE FUNCTIONAL ALCHEMY ⚗ @spec long_form(integer()) :: String.t()
INTERLUDE FUNCTIONAL ALCHEMY ⚗ @spec long_form(integer()) :: String.t() @spec long_forms([integer()]) :: [String.t()]
INTERLUDE FUNCTIONAL ALCHEMY ⚗ @spec long_form(integer()) :: String.t() Enum.map/2 @spec long_forms([integer()]) :: [String.t()]
INTERLUDE FUNCTIONAL ALCHEMY ⚗ integer() String.t() Enum.map/2 [integer()] [String.t()]
INTERLUDE W H AT ’ S S O T E R R I B L E A B O U T F P A N Y W AY ? 😱
INTERLUDE W H AT ’ S S O T E R R I B L E A B O U T F P A N Y W AY ? 😱 • The Church Chasm • If you have a hammer, everything looks like a nail • “Use anonymous functions for everything! Aren’t closures amazing?!” • Can focus on mechanics rather than concepts • Explicit state = lots of explicit handling, “pass the world”, &c • A tendency towards the darkest of magics
INTERLUDE {:tarpit, “tradeoffs”}
INTERLUDE {:tarpit, “tradeoffs”} • Surface simplicity has a cost • Complex in the large • Restricted domain in the small
INTERLUDE {:tarpit, “tradeoffs”} • Surface simplicity has a cost • Takeaway: strive for • Complex in the large • Orthogonality • Restricted domain in the small • Generality • Extensibility
INTERLUDE ACTOR ABYSS
INTERLUDE ACTOR ABYSS • Each step is very simple
INTERLUDE ACTOR ABYSS • Each step is very simple • Reasoning about dynamic organisms is hard • Remember to store your data for crash recovery • Called collaborator may not be there
INTERLUDE ACTOR ABYSS • Each step is very simple • Reasoning about dynamic organisms is hard • Remember to store your data for crash recovery • Called collaborator may not be there
INTERLUDE ACTOR ABYSS • Each step is very simple • Reasoning about dynamic organisms is hard • Remember to store your data for crash recovery • Called collaborator may not be there • Exactly why GenStage is great! • Abstract this all away for many use cases • More concrete than arrows & better matches the Elixir ethos
INTERLUDE ACTOR ABYSS • Each step is very simple • Reasoning about dynamic organisms is hard • Remember to store your data for crash recovery • Called collaborator may not be there • Exactly why GenStage is great! • Abstract this all away for many use cases • More concrete than arrows & better matches the Elixir ethos • Complexity grows faster than linear
INTERLUDE ACTOR ABYSS • Each step is very simple • Reasoning about dynamic organisms is hard • Remember to store your data for crash recovery • Called collaborator may not be there • Exactly why GenStage is great! • Abstract this all away for many use cases • More concrete than arrows & better matches the Elixir ethos • Complexity grows faster than linear • Takeaway: provide structured abstractions
INTERLUDE LANGUAGE SPECTRUM
INTERLUDE LANGUAGE SPECTRUM Imperative Declarative
INTERLUDE LANGUAGE SPECTRUM Imperative Declarative
INTERLUDE LANGUAGE SPECTRUM Imperative Declarative
INTERLUDE LANGUAGE PYRAMID Dynamic Operational Mechanistic 🚂 •→• Universal ↓ ↓ Denotational •→• Mathematics ] Contextual Semiotic Linguistic
INTERLUDE LANGUAGE PYRAMID Dynamic Operational Mechanistic 🚂 •→• Universal ↓ ↓ Denotational •→• Mathematics Overall historical trend ] Contextual Semiotic Linguistic
INTERLUDE LANGUAGE PYRAMID Dynamic Operational Mechanistic 🚂 •→• Universal ↓ ↓ Denotational •→• Mathematics Overall historical trend ] Contextual Semiotic Linguistic
INTERLUDE LANGUAGE PYRAMID Dynamic Operational Mechanistic 🚂 •→• Universal ↓ ↓ Denotational •→• Mathematics Overall historical trend ] Contextual Semiotic Linguistic
INTERLUDE LANGUAGE PYRAMID •→• Universal ↓ ↓ Denotational •→• Mathematics 🌌 🤔 🔺 💭 🗣 📝 ⚙ 🎭 Dynamic Operational Mechanistic 🚂 Overall historical trend ] Contextual Semiotic Linguistic
INTERLUDE LANGUAGE PYRAMID •→• Universal ↓ ↓ Denotational •→• Mathematics 🔺 💭 📝 ⚙ Dynamic Operational Mechanistic 🚂 🤔 🗣 Overall historical trend ] Contextual Semiotic Linguistic
ETHOS T H E P I P E S S T R AT E G Y
ETHOS T H E P I P E S S T R AT E G Y • A break in ethos from Erlang
ETHOS T H E P I P E S S T R AT E G Y • A break in ethos from Erlang • Fits Elixir’s strategy • Clean • Easy to follow • Similar to OO’s fluent interfaces
ETHOS T H E P I P E S S T R AT E G Y • A break in ethos from Erlang • Fits Elixir’s strategy • Clean • Easy to follow • Similar to OO’s fluent interfaces • Helps to read like English
ETHOS T H E P I P E S S T R AT E G Y • A break in ethos from Erlang • Fits Elixir’s strategy • Tradeoffs • Operational/mechanistic mode of thought • Clean • Cleans up a lot of code • Easy to follow • Focus or “zoom” effect 🔭 • Similar to OO’s fluent interfaces • Zooming doesn’t really apply to actors • Helps to read like English
ETHOS T H E P I P E S S T R AT E G Y • A break in ethos from Erlang • Fits Elixir’s strategy • Tradeoffs • Operational/mechanistic mode of thought • Clean • Cleans up a lot of code • Easy to follow • Focus or “zoom” effect 🔭 • Similar to OO’s fluent interfaces • Zooming doesn’t really apply to actors • Helps to read like English • Takeaway: consider you metaphors
ETHOS G U E S T L A N G U A G E S Y N TA X E S
ETHOS G U E S T L A N G U A G E S Y N TA X E S
ETHOS G U E S T L A N G U A G E S Y N TA X E S • Which language is this?
ETHOS G U E S T L A N G U A G E S Y N TA X E S • Which language is this?
ETHOS G U E S T L A N G U A G E S Y N TA X E S • Which language is this?
ETHOS G U E S T L A N G U A G E S Y N TA X E S • Which language is this? • Does it matter?
ETHOS G U E S T L A N G U A G E S Y N TA X E S • Which language is this? • Does it matter? • Is this appropriate?
ETHOS G U E S T L A N G U A G E S Y N TA X E S 🌌 🤔 🔺 • Which language is this? • Does it matter? • Is this appropriate? 💭 🗣 🗣 📝 📝 ⚙ 🎭
COMPLETENESS THE POWER OF THE DARK SIDE 💪
COMPLETENESS THE POWER OF THE DARK SIDE 💪
COMPLETENESS THE POWER OF HARMONIOUS TOOLS 💪
The limits of my language mean the limits of my world 🙊 LUDWIG WIT TGENSTEIN
An extension must introduce or integrate its concept(s) as completely as possible, as long as such constructs do not conflict with the First or Second Laws.
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ • ~60 symbols, depending
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ • ~60 symbols, depending • “Idioms over libraries”
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ • ~60 symbols, depending • “Idioms over libraries” • More than the sum of their parts
COMPLETENESS SWEE T SPOTS NEED NOT BE SUGARY a🍭 • Synergistic combinators • ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ • ~60 symbols, depending • “Idioms over libraries” • More than the sum of their parts Attribution: wikipedia user LucasVB • What a tragedy if we only had a few of these combinators!
COMPLETENESS INCOMPLETENESS 😡
COMPLETENESS INCOMPLETENESS 😡 • Often see attempts to add “just the parts I care about”
COMPLETENESS INCOMPLETENESS 😡 • Often see attempts to add “just the parts I care about” • ex. Only %Maybe{} and bind/2 in a library
COMPLETENESS INCOMPLETENESS 😡 • Often see attempts to add “just the parts I care about” • ex. Only %Maybe{} and bind/2 in a library • Could have exponentially more utility!
COMPLETENESS INCOMPLETENESS 😡 • Often see attempts to add “just the parts I care about” • ex. Only %Maybe{} and bind/2 in a library • Could have exponentially more utility! • If we see FP as a modular, adaptable system of transformations, we should have identity/1 and constant/2 combinators to stub out Enum.map/2
COMPLETENSS CASE STUDY: Witchcraft
COMPLETENSS CASE STUDY: Witchcraft • You can go pretty far with extension if you have a macros • ex. TypeClass
COMPLETENSS CASE STUDY: Witchcraft • You can go pretty far with extension if you have a macros • ex. TypeClass • Update, clean, and power up Kernel functions • Curried, async, flipped variants
CASE STUDY: Witchcraft SOURCES ⛲
CASE STUDY: Witchcraft SOURCES ⛲ • Cat Theory → Haskell & PureScript & Elm &c → Witchcraft
CASE STUDY: Witchcraft SOURCES ⛲ • Cat Theory → Haskell & PureScript & Elm &c → Witchcraft • Clean up the type class hierarchy • Haskell • Purescript • Fantasy Land Specification • and others
CASE STUDY: Witchcraft SOURCES ⛲ • Cat Theory → Haskell & PureScript & Elm &c → Witchcraft • Clean up the type class hierarchy • Haskell • Purescript • Fantasy Land Specification • and others • Some pipings and naming • Elm
CASE STUDY: Witchcraft SOURCES ⛲ • Cat Theory → Haskell & PureScript & Elm &c → Witchcraft 🌌 • Clean up the type class hierarchy 🤔 • Haskell 🔺 • Purescript 💭 • Fantasy Land Specification • and others • Some pipings and naming • Elm Elixir 🗣 📝 ⚙ 🎭
CASE STUDY: Witchcraft SOURCES ⛲ • Cat Theory → Haskell & PureScript & Elm &c → Witchcraft 🌌 • Clean up the type class hierarchy 🤔 • Haskell 🔺 • Purescript 💭 • Fantasy Land Specification • and others • Some pipings and naming • Elm Elixir 🗣 🗣 💭 🗣 🗣 🗣 📝 📝 📝 📝 📝 ⚙ 🎭
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity ✅
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! ✅
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance ✅
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern! ✅
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern!
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern!
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern! • Operator >>> aliases
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern! • Operator >>> aliases • Changed lots of argument orders
CASE STUDY: Witchcraft KEEPIN’ IT WITCHY d • Imported things with immediate synergy • Easy with type class hierarchies • Renamed many functions for clarity • Sometimes very hard! • Had to resort to bad puns in one instance • Cute puns are an antipattern! • Operator >>> aliases • Changed lots of argument orders • Pipable |> everything is
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/*
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft liftM/liftM2/liftM3/liftM4 → lift/* • Arity came in handy in a few places 🙌 • Collaborator functions renamed for metaphors so pipes make sense 😭 • Sometime have to think nonlinearly provide = (<**>)
CASE STUDY: Witchcraft TypeClass
CASE STUDY: Witchcraft TypeClass
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft TypeClass • Fully desugars into • Modules • Protocols • Tons of sugar • Generates a bunch of code • A completeness pattern • Functions for free!
CASE STUDY: Witchcraft COMPLETENESS COROLLARY: MODULARITY
CASE STUDY: Witchcraft COMPLETENESS COROLLARY: MODULARITY • Breaking up Witchcraft libs was a very good idea • Balance how much each lib should do • Marketed as more reusable 😉
CASE STUDY: Witchcraft TA K E A W AY S
CASE STUDY: Witchcraft TA K E A W AY S • Specs > Libraries • Think about how languages flow, and other physical metaphors • Naming is very important, especially with directionality • Balance between source and target language audiences • ie: folks coming from Haskell to Elixir, and from Elixir to these concepts
A N T I PA T T E R N S GETTING IT WRONG i
Experience is the name everyone gives to their mistakes 💔 O S C A R W I L D E , “L A DY W I N D E R M E R E ’ S FA N “
A N T I PAT T E R N S TORCHES AND PITCHFORKS
A N T I PAT T E R N S TORCHES AND PITCHFORKS If you feel like this you’ve probably created a monster
A N T I PAT T E R N S MIND TRAPS 🕳🧠
A N T I PAT T E R N S MIND TRAPS 🕳🧠 • Identify the way you tend to fail
A N T I PAT T E R N S MIND TRAPS 🕳🧠 • Identify the way you tend to fail • My failure mode is to enforce correctness
A N T I PAT T E R N S MIND TRAPS 🕳🧠 • Identify the way you tend to fail • My failure mode is to enforce correctness • Harder in libraries than in application code, since you have such control • Great definitional power comes with great responsibility to your users!
A N T I PAT T E R N S MIND TRAPS 🕳🧠 • Identify the way you tend to fail • My failure mode is to enforce correctness • Harder in libraries than in application code, since you have such control • Great definitional power comes with great responsibility to your users! • KISS principle 😘 • Common trap: getting too cute with names and metaphors • Names should be descriptive of what they do, not a brand exercise
A N T I PAT T E R N S FORCE PRACTICES ON USERS
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖 ✅
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖 • Enforced prop testing at compile time • Slow • Detracts people from using the lib ✅
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖 • Enforced prop testing at compile time • Slow • Detracts people from using the lib • Wanted to encourage good practice ✅
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖 • Enforced prop testing at compile time • Slow • Detracts people from using the lib • Wanted to encourage good practice • Please give user choice ✅
A N T I PAT T E R N S FORCE PRACTICES ON USERS • Overall very happy with TypeClass • Contains my biggest regret 😖 • Enforced prop testing at compile time • Slow • Detracts people from using the lib • Wanted to encourage good practice • Please give user choice • Generate test helpers ✅
A N T I PAT T E R N S REDEFINE / OVERWRITE Kernel
A N T I PAT T E R N S REDEFINE / OVERWRITE Kernel
A N T I PAT T E R N S REDEFINE / OVERWRITE Kernel
A N T I PAT T E R N S REDEFINE / OVERWRITE Kernel
A N T I PAT T E R N S REDEFINE / OVERWRITE Kernel a
A N T I PAT T E R N S A L L T H E O P E R AT O R S
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉 • Limited number of operators in Elixir
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉 • Limited number of operators in Elixir • Operator-space collisions 💥
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉 • Limited number of operators in Elixir • Operator-space collisions 💥 • Handy if you’re user has one lib per application, but you don’t know
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉 • Limited number of operators in Elixir • Operator-space collisions 💥 • Handy if you’re user has one lib per application, but you don’t know • Always provide a named variant • Operator 😉
A N T I PAT T E R N S A L L T H E O P E R AT O R S • Super duper handy to have 🎉 • Limited number of operators in Elixir • Operator-space collisions 💥 • Handy if you’re user has one lib per application, but you don’t know • Always provide a named variant • Operator 😉
A N T I PAT T E R N S T H E O P T I O N T O D I S A M B I G U AT E
A N T I PAT T E R N S T H E O P T I O N T O D I S A M B I G U AT E What does this do?
A N T I PAT T E R N S T H E O P T I O N T O D I S A M B I G U AT E What does this do?
A N T I PAT T E R N S T H E O P T I O N T O D I S A M B I G U AT E What does this do?
PUT TING IT ALL TOGE THER 🏗
PUT TING IT ALL TOGE THER 🏗 LET’S PORT A THING 🛳
PUT TING IT ALL TOGE THER 🏗 TOY EXAMPLE 🧸
PUT TING IT ALL TOGE THER 🏗 TOY EXAMPLE 🧸 • What to port? 🤔
PUT TING IT ALL TOGE THER 🏗 TOY EXAMPLE 🧸 • What to port? 🤔 Imperative Declarative
PUT TING IT ALL TOGE THER 🏗 TOY EXAMPLE 🧸 • What to port? 🤔 • Witchcraft already exists Imperative Declarative
PUT TING IT ALL TOGE THER 🏗 TOY EXAMPLE 🧸 • What to port? 🤔 • Witchcraft already exists • Let’s go the opposite direction Imperative Declarative
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible 2. A terrible idea 🤣
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible 2. A terrible idea 🤣 • Don’t try this at home
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible 2. A terrible idea 🤣 • Don’t try this at home • Trained professionals s
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible 2. A terrible idea 🤣 • Don’t try this at home • Trained professionals s • Just a toy example 🧸
PUT TING IT ALL TOGE THER 🏗 F E AT U R E S • Classes • Mutable instance variables • Constructor • Methods (static and non-static) • Dot notation & chaining • Duck typing 🦆 • Turns out that this is 1. Totally possible 2. A terrible idea 🤣 • Don’t try this at home • Trained professionals s • Just a toy example 🧸 • Garnet ♦
PUT TING IT ALL TOGE THER 🏗 GOING WHOLE-HOG 🐖
PUT TING IT ALL TOGE THER 🏗 GOING WHOLE-HOG 🐖 • Data hiding • All functionality behind a single interface • Essentially a struct • Instance variables persist between calls • Not going to handle inheritance, but totally possible • TypeClass does something similar
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V1 ♦
PUT TING IT ALL TOGE THER 🏗 STEPPING BACK FROM THE BRINK v
PUT TING IT ALL TOGE THER 🏗 STEPPING BACK FROM THE BRINK v • Too far! Revert! Revert! • 🤔 This pattern isn’t that uncommon • Aside from the dot chaining 😱 • Typically use GenServer or Agent • What can we step back?
PUT TING IT ALL TOGE THER 🏗 STEPPING BACK FROM THE BRINK v • Too far! Revert! Revert! • 🤔 This pattern isn’t that uncommon • Aside from the dot chaining 😱 • Typically use GenServer or Agent • What can we step back? • Analysis • Getter/setter sugar is fine • Zero linking control • Static methods are just regular functions • Data hiding can just be a process • Map-like interface with chaining 🙅 • Operators are cute, but names are clearer • Implicit variables: not ideal IMO, but sure • Vive les pipes 💪
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦ ❌ struct or builder
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦ ❌ struct or builder ❌ anonymous functions
PUT TING IT ALL TOGE THER 🏗 GARNET V2 ♦ ❌ struct or builder ❌ anonymous functions (Much simpler to implement)
F I N A L TA K E A W AY S 📦
F I N A L TA K E A W AY S 📦 THE HIGH LEVEL REVIEW 👀
F I N A L TA K E A W AY S 📦 BIG THEMES
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should • Library-as-language-extension (think “version x.1”)
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should • Library-as-language-extension (think “version x.1”) • Languages are more than keywords; they’re philosophies and practices
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should • Library-as-language-extension (think “version x.1”) • Languages are more than keywords; they’re philosophies and practices • Language matters less than concepts
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should • Library-as-language-extension (think “version x.1”) • Languages are more than keywords; they’re philosophies and practices • Language matters less than concepts • Focus on cohesion when extending or blending
F I N A L TA K E A W AY S 📦 BIG THEMES • Standard libs are not sacred • But all lib code should feel like it belongs in there! • Just because you can doesn’t mean you should • Library-as-language-extension (think “version x.1”) • Languages are more than keywords; they’re philosophies and practices • Language matters less than concepts • Focus on cohesion when extending or blending • Love your code ❤
Like punning, programming is a play on words 📚 AL AN J. PERLIS
THANK YOU, KRAKÓW z🎉 @EXPEDE GITHUB.COM/EXPEDE H E L L O @ B R O O K LY N Z E L E N K A . C O M
Ever wished that you had feature X in language Y? Frustrated that two libraries don’t play nice together? Have framework fatigue? Language design principles also extend to libraries. This is especially true when porting concepts and features from another language or ecosystem. In this follow-up to her Empex 2018 keynote, Brooklyn will explore a philosophy of library design with an eye towards porting, drawing concretely from her experiences bootstrapping features primarily inspired by Haskell and OCaml to Elixir. Which factors do you need to balance, when is it appropriate to deviate from the core syntax (of both source and target), and importantly: how far can you bend before you break?