←back to thread

873 points belter | 5 comments | | HN request time: 0.54s | source
1. jagraff ◴[] No.42949051[source]
> Contrarily, library development is about abstractions. Spend time hunting for an algebra

This line piqued my interest - what does an algebra mean in this context? Does anyone know of any good resources for further exploration?

replies(4): >>42949876 #>>42950234 #>>42954890 #>>42959467 #
2. wink ◴[] No.42949876[source]
Only guessing but my first thought was about how you have addition and multiplication and they both work for different types of numbers. But not in the generics/C++ template sense, more like working on Sets and Rings and other algebraic structures in the mathematical sense.
3. jghn ◴[] No.42950234[source]
It comes from the FP world. It's one of those things like monads that seem obvious when explained but sound opaque if you're not in on it.

Basically it's saying to create a formal set of types and formal rules about how they interact. If you search for permutations of phrases like "functional programming" "algebra" "data types" you'll turn up some hits. For instance [1]

[1] https://www.turingtaco.com/algebraic-data-types-structuring-...

4. itishappy ◴[] No.42954890[source]
Algebraic structure. It's a fancy way of saying that a system follows certain patterns or rules.

As an easy example, you're probably quite familiar with the algebra of addition over integers. It describes rules like associativity and commutativity that describe some general transformations that are guaranteed to always behave predictably. Contrast this with subtraction over integers, which is associative but not commutative. Programs in general are neither associative nor commutative, so sadly no swapping terms or adding parenthesis willy-nilly.

A slightly more advanced example that you're probably still familiar with is mapping over Functors. A functor is just a thing that contains other things, and it includes collections you're familiar with like lists and trees. Well, the action of taking stuff out of a container, modifying it, and returning the results in their original position turns out to be an incredibly common and useful pattern!

https://en.wikipedia.org/wiki/Algebraic_structure

5. goostavos ◴[] No.42959467[source]
Sandy Maguire wrote a fantastic book on the topic: https://leanpub.com/algebra-driven-design

You can also checkout the work of Conal Elliott: http://conal.net/