19 ms·
Why I am learning category theory
- adamddev1 4y agoBartosz Milewski's series of lectures on YouTube is a really engaging and enjoyable introduction to category theory. These are really helping me get it. https://www.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_ https://www.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI...
- routerl 4y agoBartosz's teaching/explanation style does not work for me. I have no formal critique of him, or even concrete things to point at to say why it doesn't work for me, but I wanted to add my comment in case someone else was also feeling discouraged by not taking much away from the writings/lectures of an often and highly recommended person. I generally learn very well from lectures/essays, but that hasn't been true for me re: his work.
- larve 4y agoI really like the "Programming with categories" lecture because you basically get 3 teaching styles for the same material. Brendan Fong is very straightforward "definition lemma definition lemma", Spivak is slightly more example-oriented, and then Bartosz is... bartosz. The juxtaposition helps to unstick me. I do use Eugenia Cheng's Catsters video to complement as well. If I had to chose one personal favourite, it would be her for sure.
- routerl 4y agoI've gotten a lot more out Spivak than Bartosz. It might just be a stylistic thing. I can't quite pinpoint it. Edit: Eugenia Cheng also makes more sense to me than Bartosz.
- rslice 4y agoI strongly recommend this presentation: "John Baez: "Symmetric Monoidal Categories A Rosetta Stone"[0]. It is easy to get lost in the ocean of theorems and definitions and overlook some powerful core concepts. [0]https://www.youtube.com/watch?v=DAGJw7YBy8E https://www.youtube.com/watch?v=DAGJw7YBy8E
- nnoitra 4y agoWill it make you a better React dev tho?
- larve 4y agoAuthor here, I actually think so. The rendering of the virtual DOM as well as hooks are fairly interesting mathematical constructs. A pattern I use a lot in web applications is the state reducer, which is really a fold over events and state. Seeing the functional nature of it (and reactive programming in general) can make for quite composable react code, while it is easy to make either a verbose mess of propdrilling or do a lot of tricky context mixing.
- tunesmith 4y agoI'd love to see some examples of your diagrams. Are they all hand-written or do you use online tools for them? I do quite a bit of graph diagramming but not for detailed planning of implementation. Best example I've seen along those lines are the xState tools for state charts (https://stately.ai/viz https://stately.ai/viz).
- larve 4y agoI love xstate! I do use plantuml a lot for sketching, but most is done on paper or whiteboards and is quite transient in nature. I must have hundreds if not thousands of sketchbooks pages that look like this: https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b5918f9973e/Attachments/image/Sketchbooks-1657980036255.jpeg https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b... https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b5918f9973e/Attachments/image/Sketchbooks-1657980046129.jpeg https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b... https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b5918f9973e/Attachments/image/Sketchbooks-1657980062475.jpeg https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b...
- tunesmith 4y agoThese are great. You could probably get a lot of mileage out of a post that explores how to model a react component functionally in diagrams.
- aleyva 4y agoSuper cool-- love the discussion around diagrams and why they're so critical to humans
- Tainnor 4y agoAs someone with a maths degree, yet who admittedly hasn't looked into category theory beyond some basic notions, I still don't quite understand why anyone would want to learn category theory before e.g. abstract algebra or even just fundamental mathematical reasoning (definition, theorem, proof). Maybe I'm missing something but it seems to me that all you can study monads in programming languages without having to also learn the category theory abstraction of it. The same goes for semigroups, monoids, folds, functors, ... I'm sure there's a benefit in category theory once you want to unify all these abstractions and talk about all of them together, but I see so many people who think they have to learn CT before they can understand monads in e.g. Haskell, and I don't really understand why.
- larve 4y agoauthor here, for context, I do have a reasonable background in maths (algebra, analysis, statistics) at a CS master-ish level (self-taught and a long time ago, though), as well as spent quite some time with programming language / type theory when I was younger, and I do use monads quite a bit in my day to day programming. In fact, the fundamental algebra concepts (rings, groups, etc...) as well as fundamental CS theory (grammars, proof theory, semantics, ...) were the only maths I felt reasonably comfortable with, compared to say, calculus or statistics which really did my head in and ultimately caused me to drop out of university.
- Karrot_Kream 4y agoHow much do you think your predilection for algebra affected your interests? Most folks who do CT as a hobby that I know are much weaker in analytical concepts than any working mathematicians that I knew.
- larve 4y agoHonestly I'm pretty weak in both, but they seem to reflect my intuitions, if that makes sense? I'm nowhere near a working mathematician, and proofs usually bore me. I prefer writing code.
- charcircuit 4y agoHonestly, this is a waste of time and is not going to help as much as the author thinks it is. There is no secret from category theory that will make one's design 10x better. Not everything is even applicable. >I hope that category theory will allow me to formalize my intuitive understanding of abstraction, put words to it, and use those words (or, better, words others have written) to explain my thinking. Note how this goal doesn't include anything about improving the author's software engineering ability. The goal is to be able to use category theory to describe existing concepts. Why not us just describe it in ways that 99% of software engineers already understand? Why not learn good software design directly instead of through a subset of category theory which you have to translate?
- larve 4y agoauthor here, the way I see it is that nothing about my software per se will change. I do indeed like to write things in a "plain" fashion instead of littering my code with high-level constructs that only a few people understand. However, it is "generative" knowledge. Having a good intuition for monads is what allows me to break down a fair amount of the mundane tasks I have to do (say, breaking down and migrating infrastructure configuration) in steps that work and stand the test of time. That's the thing about say, monad. An applied monad just looks utterly trivial, because, really, they are. If they weren't they wouldn't be worth using. It also allows me to mine the literature or reuse things I've worked out in the past, for example exploiting monoidal structure for optimizing computation by leveraging associativity, for example.
- larve 4y agoAlso, this is very much what works for me. I love to think in "structure" and patterns, and category theory diagrams and the way concepts are formulated brings me "joy", if that makes sense. It resonates with my cognition in the way say, common lisp, does, and that makes it quite fun and enjoyable. Does it for everybody? Most certainly not.
- charcircuit 4y ago>It also allows me to mine the literature or reuse things I've worked out in the past, for example exploiting monoidal structure for optimizing computation by leveraging associativity, for example. This is an algebraic concept and it is possible to learn this idea directly in a software engineering context than a mathematical one.
- WFHRenaissance 4y agoAs a former category theorist: don't learn category theory unless you're already rich or want to do it for fun. It will be a lot less rewarding than you expect RE: your engineering ability/understanding.
- Koshkin 4y agoBut how do you know (being a theorist)?
- mark_l_watson 4y agoCool, I am also spending a little time on this. I bought a CT book by Emily Riehl but I am finding it rough going. I find her YouTube talks and lectures to be easier to follow.
- codekilla 4y agoTry Eugenia Chang’s new book, The Joy of Abstraction. Riehl’s book is very technical.
- mark_l_watson 4y agoThanks I will look at it.
- Twisol 4y agoI second this recommendation; Cheng's book is probably the most approachable of the recent wave of category theory texts which does not assume the whole edifice of abstract algebra as a starting point. Most CT texts introduce categories around page 1, and the Yoneda lemma a handful of pages in. Cheng's book builds up intuitions until chapter 8, where categories are defined over the course of several pages, and supposedly (I'm not there yet) ends the book with the Yoneda lemma. You might think this means the book is mostly fluff. First: if you read it and think that, you're probably a more advanced reader than she's targeting. Second: goodness no, it's packed to the brim with categorical intuitions; there's a whole way of thinking that she's trying to motivate. Categories are just a formalization of this way of thinking; if you're not onboard with the thinking, the formalization is going to be hollow to you no matter what. Do recommend.
- i_am_toaster 4y agoI would be willing to drink the kool-aid if I saw it being used in a practical way. I always feel these posts are filled with category theory jargon without ever explaining why any of the jargon is relevant or useful. I’ve even watched some applied category theory courses online and have yet to feel I’ve gained anything substantive from them. However, as I started off with, I’m always willing to try something out or see the reason in something. Can anyone give me a practical applied way in which category theory is a benefit to your design rather than just creating higher level jargon to label your current design with?
- jerf 4y ago"I’ve even watched some applied category theory courses online and have yet to feel I’ve gained anything substantive from them." To understand category theory's appeal in a programming context, you must understand the duality of power in programming languages. Some people call a language "powerful" when it lets you do whatever you want in the particular scope you are currently operating in, so, for instance, Ruby is a very powerful language because you can be sitting in some method in some class somewhere, and you can reach into any other class you like and rewrite that other class's methods entirely. Some call a language powerful when the language itself is capable of understanding what it is your code is doing, and further manipulating it, such as by being able to optimize it well, or offer further features on top of your language like lifetime management in Rust. This type of power comes from restricting what a programmer is capable of doing at any given moment. If your idea of "power" comes from the first sort of language, then category theory is going to be of very little value to you in my opinion. You pretty much have to be using something as deeply restrictive as Haskell to care about it at all. I am not making a value judgment here. If you never want to program in Haskell, then by all means keep walking past category theory. Haskell is very much a language that is powerful in the second way. It restricts the programmer moreso than any other comparable language; the only languages that go farther essentially go right past the limit of what you could call a "general purpose language" and I daresay there are those who would assert that Haskell is already past that point. Category theory then becomes interesting because it is simultaneously a set of deeply restricted primitives that are also capable of doing a lot of real work, and category theory provides a vocabulary for talking about such restricted primitives in a coherent way. There is some sense in which it doesn't "need" to be category theory; it is perfectly possible to come to an understanding of all the relevant concepts purely in a Haskell context without reference to "category theory", hence the completely correct claim that Haskell in no way necessitates "understanding category theory". You will hear terminology from it, but you won't need to separately "study" it to understand Haskell; you'll simply pick up on how Haskell is using the terminology on your own just fine. (Real mathematical category theory actually differs in a couple of slight, but important ways from what Haskell uses.) So, it becomes possible it Haskell to say things like "You don't really need a full monad for that; an applicative can do that just fine", and this has meaning (basically, "you used more power than was necessary, so you're missing out on the additional things that can be built on top of a lower-power, higher-guarantee primitive as a result") in the community. This mindset of using minimal-power primitives and "category theory" are not technically the same thing, but once you get deeply into using minimal-power primitives pervasively, and composing them together, you are basically stepping into category theory space anyhow. You can't help but end up rediscovering the same things category theorists discovered; there are a hundred paths to category theory and this is one of the more clear ones of them, despite the aforementioned slight differences. I'd say it's a fair thing to understand it as this progression; Haskell was the language that decided to study how much we could do with how little, and it so happens the branch of math that this ends up leading to is category theory, but as a programmer it isn't necessary to "study" category theory in Haskell. You'll osmose it just fine, if not better by concretely using it than any dry study could produce. To be honest, I'm not even convinced there's that much value in "studying" category theory as its own thing as a programmer. I never studied it formally, and I wrote Haskell just fine, and I understand what the people using category theory terms are talking about in a Haskell context. If nothing else, you can always check the Haskell code. There is a nearby parallel universe where the Haskell-Prime community in the late 1990s and early 2000s was otherwise the same, but nobody involved knew category theory terminology, so "monad" is called something else, nobody talks about category theory, and nobody has any angst over it, despite the language being otherwise completely identical other than the renames. In this universe, some people do point out that this thing in Haskell-Prime corresponds to some terms in category theory, but this is seen as nothing more than moderately interesting trivia and yet another place where category theory was rediscovered. But I bet their Monad-Prime tutorials still suck.
- edgyquant 4y agoI’ve become increasingly obsessed with set theory. I think we can derive set theory from Turing machines and basically “solve” incompleteness.
- trenchgun 4y agoUh... how?
- oxff 4y agoTo obviously debunk any and all FP autism coming at your way. To give credit where credit is due, most of the time some application functionality being described through FP jargon gives a better spec of its behavior than the same through OOP jargon.
- dboreham 4y agoThis is exactly why I learned about it.
- schwurb 4y agoI find CT highly fascinating, worked through parts of 7 Sketches in Composability and have a functional programming background. I see the appeal, but I came to the conclusion that my time is better spent observing, learning about and designing with abstractions like monads, applicatives and so on rather than to learn the theory behind it. There seems to be a tiny handful of people that can use category theory as a resource to craft something relevant to software (the stereotypical example in my mind being Edward Kmett of Haskell Fame), but I am certainly not one of them, and that is not something that would change with learning more Category Theory (whatever that might mean: Proving some theorems, discovering more categories, ...) To the author: I am looking forward to a retrospective at a later time. I wish you a good journey, happy diagram-chasing!
- qubex 4y agoAs opposed to “why am I learning category theory”, which is usually screamed deep in the night before an exam.
- yodsanklai 4y agoReading at the comments, people confuse concepts like monoids and functors with category theory.
- larve 4y agoThey're concepts in category theory? Since category theory's goal is to find common abstractions behind concepts from other fields (mathematics or otherwise), it makes sense some of those concepts appear in other fields. Their definition in a category theory context is different, usually, since you can only express them using morphisms between objects in a category. (edit: typo)
- mrkeen 4y ago> functor Google search first result: Functor - Wikipedia https://en.wikipedia.org › wiki › Functor In mathematics, specifically category theory, a functor is a > monoid https://en.wikipedia.org/wiki/Monoid_(category_theory) https://en.wikipedia.org/wiki/Monoid_(category_theory)
- yodsanklai 4y agoYes, these words do have a meaning in category theory. But for a haskell programmer, a functor is a type with a map operation, for a ocaml program it's a module parameterised by a module signature. A monoid a type with a function T x T -> T. That's it. You can know these things and still know nothing about category theory.
- Twisol 4y ago"Functor" has been used in multiple ways in different fields. It's apparently a term of art in linguistics; we call C++ classes implementing `operator()` "functors"; Prolog terms have parts called "functors" (apparently imported from linguistics); and of course category theory has them. As far as mathematics is generally concerned, I think the category theory concept is the origin. Monoids, on the other hand, did exist before category theory; the modern conception as one-object categories is nice, but it's definitely an import.
- khazhoux 4y agoAs a programmer and hobbyist math reader, I found category theory to be very unrewarding (and I gave up on it) because of the lack of interesting theorems and lemmas. My takeaway was that there's Yoneda lemma and really nothing interesting before you reach that. Like, CT describes a set of rules but very little emerges from those rules. My complaint has nothing to do with whether CT is useful or practical. By contrast, abstract algebra can be taught (e.g., in Herstein's books) as pure abstraction (very dry and without presenting any real-world connections), but you reach Lagrange's theorem right away -- which is an simple-but-awesome result that will wake up your brain. You reach Cayley's theorem and others quickly, and each is more exciting that the last. And this is all while still in the realm of purely-abstract math.
- solomatov 4y ago> As a programmer and hobbyist math reader, I found category theory to be very unrewarding (and I gave up on it) because of the lack of interesting theorems and lemmas. My takeaway was that there's Yoneda lemma and really nothing interesting before you reach that One of the most interesting things in CT are adjoints. They happen literally everywhere. For example, static analysis via abstract interpretation is an example of adjoint (which in this case is called Galois connection). Free structures also give rise to adjoints.
- Koshkin 4y agoSure, but what does the knowledge of something being an adjoint give you?
- larve 4y agoHere's a talk I'm chewing on right now: https://www.youtube.com/watch?v=TNtntlVo4LY https://www.youtube.com/watch?v=TNtntlVo4LY as with every abstraction, its value is in the value it brings you. That sounds a bit tautological, but I think that's the crux of the matter. If you like abstraction, and abstractions help you think, you are going to find value in them. If you feel they bring you nothing, then there is no need for you to use them.
- thr3ads 4y agoI became very interested in CT from a biological perspective. The work originates from Robert Rosen who describes how biological/complex systems are not (completely) reducible to formal systems (aka any model of a natural system will always be incomplete+it is impossible to explicitly list out all the rules governing the system) because they "contain a model of themselves" to which they anticipate the future and act on towards their benifit. Many relate his work as closely tied to Gödel's incompleteness theorem but for biology. The purpose of using category theory is that it is general enough to not talk about specific parts of an organism's construction, but rather how their general functional parts relate to each other.
- xupybd 4y agoI tried this a couple of years ago. However it went over my head I think I need more fundamentals before I can approach this again.
- chowells 4y ago> Category theory is really the mathematics of abstraction Mathematics is the mathematics of abstraction. That's all you're doing in math, from the beginning to the end. What's the same between "I have two sheep in this pen and five in that one" and "I have two apples in this basket and five in that one"? Hmm, you can abstract out 2+5=7, since it works the same in both contexts. Everything in math is creating and exploring abstractions. The good ones tend to stick around, the bad ones tend to be forgotten. Category theory is the mathematics of composition. How much knowledge can you throw away and create reusable patterns of composition? How many interesting things can you find by adding back the smallest bits of additional structure on top of that minimum? How well do those things compose together, anyway?
- Twisol 4y ago> Mathematics is the mathematics of abstraction. > Category theory is the mathematics of composition. I don't know why you're being downvoted (tone?) but you're right. Categories formalize exactly and only the notion of composition; its power is that this notion appears everywhere when you know what to look for. Most mathematical abstractions have composition baked in at one level or another, so I think the author should be pardoned for their phrasing; but I find yours more enlightening.
- larve 4y agoOh gosh, I did in deed make a brainfart, and meant to write "category theory is the mathematics of composition". Thanks for bringing it up!
- Iceland_jack 4y agoalgebra of typed composition, a discipline for making definitions, study of universal properties, theory of duality, formal theory of analogy, mathematical model of mathematical models, inherently computational, science of analogy, mathematical study of (abstract) algebras of functions, general mathematical theory of structures,
- criloz2 4y agoI am also in the process of learning cat theory, I don't have a cs background, but I ending working as full-stack developer because it was economically more rewarding, I will recommend to programmers to have a good understanding of set theory, binary relations and order theory (linear orders, partial orders, lattices), it gives you very powerful abstractions that allow you to write new algorithms about anything.
- Koshkin 4y agoI think graph theory covers all this at a reasonable level of abstraction.
- kevinventullo 4y agoThis crowd may not want to hear this, but as a former mathematician, the DS/Algorithms knowledge I gleaned from Leetcode grinding has been far more useful in my day-to-day work than any of the category theory I once used on a regular basis.
- Twisol 4y agoI think learning the essentials of another field can be more valuable than expected, whether it's a mathematician learning to program or a software engineer learning patterns of abstraction. When you've gone deep on one field, going even deeper has diminishing returns. Software engineers and (non-categorical) mathematicians are both forced to deal with patterns of abstraction on a regular basis, so they naturally pick up a lot of what category theory concerns itself with. This can make category theory sound like quite a lot of words for very little gain. But I do think that formalizing one's intuition -- taking something understood implicitly and giving it explicit form -- can be a useful tool in its own right. Most of the material out there on category theory attempts to formalize the algebraist's intuition. Software engineers then have to learn algebra just to learn category theory. I don't think that's essential to category theory, and I think we're starting to see more and more "elementary" category theory that doesn't take some other whole edifice as given. The fact that so many software engineers exist who do find value in a categorical perspective (it's more than you'd expect!) suggests that we'll get there eventually.
- antimora 4y agoI recommend "how to bake pi" by Eugenia Cheng for a high level introduction, followed by her in-depth (but still approachable) book "The Joy of Abstraction"
- IntFee588 4y agoYou learn category theory for intellectual curiosity. I learn category theory to pass a Haskell course. We are not the same.
- OgAstorga 4y agoRelated discussion. https://news.ycombinator.com/item?id=33740089 https://news.ycombinator.com/item?id=33740089
- presheaf 4y ago
- Twisol 4y ago> Category theory is literally the mathematics of boxes (objects), arrows (morphisms), and composition. As I've learned more about category theory (and its applications), I've found string diagrams to be a really nice tool. But string diagrams flip the above around -- morphisms are boxes, and objects are wires. A wire is just a point-to-point link; it doesn't do anything on its own, it just connects a port of one type with a matching port on another site. It's the graphical realization of the composition operation itself. Meanwhile, morphisms are the things that actually have behavior and real identities, so we draw them as boxes with inputs and outputs and give them names. This lines up with my understanding that in category theory, it's the morphisms that matter; the objects are no more than labels governing how you can stick the morphisms together. You may as well call the morphisms "widgets" or "components", and call the objects "interfaces", because that's literally correct. This ends up really nice in the context of distributed systems, where concurrency gives you a monoidal category. In string diagrams, concurrently is quite literally the result of putting two diagrams side-by-side, rather than connecting them end-to-end. It's lovely, and some of the research I'm doing right now is actually founded on formalizing the message-passing causal diagrams distsys researchers and practitioners use every day, and using them as a vehicle for building programs that are more amenable to being proven correct. (Distributed systems are hard to verify for both humans and computers; I'd like to think that what I'm doing will be just as good for giving human practitioners a good framework for convincing themselves their code is correct -- or better, making bugs more obvious.)
- Koshkin 4y agoIndeed, category theory is as much about “boxes” and “arrows” as astronomy is about telescopes!
- donkey-hotei 4y agoMy professor told me that learning category theory would make me a better person but not a better programmer
- Throwaway23459 4y agoI worked through a popular Introductory Category theory text. Did all the problems and made sure I understood everything in there really. It became clear by the end why some mathematicians like category theory. It lifts some results in certain areas to a higher level of generality. As for me it helped me with understanding some of what was being discussed on r/haskell. It didn't help one iota getting me a Haskell job though, failed every Haskell code pairing I've done.
- sargstuff 4y agoCategory theory is very helpful when looking a programming from a metadata / multi-domain interactions perspective aka (interaction between different abstraction layers / non-linear scip ) Although, applying CT to lisp ( . ) bit more handy (to quot(.) or quote()
- sargstuff 4y agoFor algol language inclined, lot less shell sourcing/chaining before waterfall of understanding.
- justinhj 4y agoCategory theory? Learning something when you don’t absolutely have to in order to write code? Sure it might be fun and expand your mind but I’ll have none of it you understand! Bah humbug!