Ep 098: Composed Learnings
► Play EpisodeEach week, we discuss a different topic about Clojure and functional programming.
If you have a question or topic you'd like us to discuss, tweet @clojuredesign, send an email to feedback@clojuredesign.club, or join the #clojuredesign-podcast
channel on the Clojurians Slack.
This week, the topic is: "composition is life". We reflect on keeping the necessary mess at the edges so our core can be composed together with beauty and simplicity.
Our discussion includes:
- Our reflections on the episodes in this series.
- The best concepts from the episodes in this series.
- How to separate data from behavior.
- Why zucchini bread is at the core of functional programming.
- What baking has to do with functional programming.
- How to get objectivity for better understanding.
- Why you should focus on trade offs.
- How Clojure and immutability steer you toward composition.
- An inventory of different kinds of functions.
- Why side effects ruin composition.
- How Clojure lets you focus on your problem.
- How composition works in the small and the large.
- The paradox of constraints providing more freedom.
- The cognitive load of functional programming vs object-oriented programming.
Selected quotes:
- "This episode we thought we would take it and put it all together." "The last draft."
- "Functional programming is built on composition."
- "Object-oriented programming tends to have at least a little bit of behavior and data together, so you can't separate them if you want to make a new thing."
- "If you just want classes to be one thing, just data or just methods, all of a sudden you end up with something that looks a lot like functional programming."
- "Constraints breed freedom and clarity. If you can't reach other functionality through data, then data will never hurt you."
- "It takes a while to discover what is worth separating and what's fine to leave in larger chunks." "You have to use it."
- "So by moving [a problem] into a separate domain, you're able to see the essentials, the fundamentals, more clearly because you're not stuck in those ruts of thinking that you do without realizing."
- "I've been known to eat the same thing for breakfast every day, for weeks on end."
- "Clojure core plus immutability really steers you in the direction of composition."
- "'Transforms' is a little unfair of a category because that's almost all of functional programming."
- "Data cake. Delicious!"
- "I want to do something with this data that affects the world around me besides generating heat."
- "Side effects ruin composition because side effects are a second dimension that is difficult to compose."
- "When you write functions in the way that Clojure expects them, this whole world of core opens up, and the only thing you had to implement was your the code that was relevant to your domain."
- "There's almost nothing to Clojure itself. Most of my time writing in Clojure is thinking about my problem--not thinking about how I'm going to express it or how I'm going to model the object graph or any of that stuff."
- "I'm just left thinking about my own problem."
- "The key in all composition is a clear delineation and separation of responsibilities."
- "Because they're smaller, you can understand them at a glance."
- "With side effects, there's an infinite number of additional dimensions that are possible. You can't just worry about what the function says it does, you have to worry about all the other things that it could be doing!"
- "Side effects are like really advanced politics between hostile countries. There are the words that come out of their mouth, and then there's all the stuff that really matters that no one's talking about!"
- "Clojure is for the peaceful."
- "If you like to keep all the messiness at the edges so the core of your application can be composed together with beauty and simplicity, making your day wonderful, then Clojure might be for you!"
Common kinds of functions:
- Predicates: provide truth values
- Reducers: take the current "state" and an input and return a new state
- Transforms: broad category that covers many kinds of functions
- Conversions: take one kind of thing and turn it into another kind of thing eg. parse-long
- Extractors: return part of a data object
- Mergers: combine data together
- Decorators/enrichers: takes a data shape and adds more into it while preserving the original data shape
- Side effectors: affects the world in a clear and specific way
Links: