←back to thread

873 points belter | 1 comments | | HN request time: 0.231s | source
Show context
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 #
1. 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