TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Please Don't Learn Category Theory (2013)

54 pointsby psibiover 11 years ago

11 comments

jfarmerover 11 years ago
The problem with being a programmer and learning category theory is two-fold.<p>First, category theory is very abstract. Indeed, mathematicians often jokingly refer to category theory as &quot;abstract nonsense.&quot; The story goes that Norman Steenrod, one of the creators of category theory, coined this term himself. So, category theory can be abstract <i>even for mathematicians</i>.<p>Second, the &quot;stuff&quot; that category theory was built to abstract is highly mathematical and foreign to virtually every programmer who doesn&#x27;t have a math background. What&#x27;s worse, the bits of category theory that Haskell uses most frequently are typically <i>not</i> the bits of category theory that mathematicians use most frequently.<p>When you put these together, it&#x27;s very hard to connect the dots between &quot;category theory&quot;, &quot;category theory as Haskell uses it,&quot; and &quot;Haskell as a typical Haskell programmer uses it.&quot; To build up to the bits of category theory that Haskell uses requires understanding things like categories, morphisms, functors, adjoint functors, natural transformations, adjunctions, and commutative diagrams, to name seven. Trying to understand these without understanding their (inherently mathematical) motivations would be a tiny nightmare — they&#x27;d feel like a bunch of disjoint facts and diagrams that are supposed to mean who-knows-what.<p>And even if you get there, the categorial nature of monads in Haskell is not exactly apparent on the surface. Haskell exposes more programmer-friendly interfaces like &quot;bind&quot; that take some effort to translate into the language of category theory.<p>A major motivator in the development of category theory, for example, was as a tool to explore the relationship between topological spaces and groups, a field of mathematics called <i>algebraic topology</i> (<a href="http://en.wikipedia.org/wiki/Algebraic_topology" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Algebraic_topology</a>).
评论 #7067033 未加载
评论 #7066822 未加载
评论 #7066670 未加载
tikhonjover 11 years ago
A bit of a link-baity title. It&#x27;s not that you <i>shouldn&#x27;t</i> learn category theory, it&#x27;s that you don&#x27;t <i>have</i> to. Even if you want to program in Haskell.<p>But is it worth learning on its own? Probably. At least the basics are. You&#x27;ll get more insight into the design of languages like Haskell and ML and acquire a bunch of new abstractions which have a very good &quot;power-to-weight&quot; ration: that is, abstractions which are surprisingly general and expressive but also simple. The compromise, of course, is that these abstractions are <i>really</i> abstract--they do not admit good concrete explanations. At first, thinking about this sort of abstraction is difficult, but they become extremely powerful and convenient once you get used to them.<p>Category theory also helps people design libraries. In a sense, category theory is focused on <i>composition</i>, which is obviously integral to writing good code. Additionally, some extremely useful constructs--like prisms from the lens library--were discovered largely thanks to category theory.<p>Finally, category theory gives you a <i>new perspective</i> on programming. I find this very valuable because it gives me more than one way to think about whatever I&#x27;m working on. It&#x27;s useful in the same way Curry-Howard is useful--in fact, there&#x27;s a very natural extension of Curry-Howard to include categories with certain structure.<p>So yeah: please don&#x27;t feel you <i>have</i> to learn category theory, but consider learning it anyway.
评论 #7067040 未加载
评论 #7067112 未加载
rtfeldmanover 11 years ago
&gt; the people who designed Haskell decided they weren’t going to pretend they didn’t use math<p>This is almost certainly the decision that has kept the most people from successfully learning Haskell.<p>If you write &quot;Appendable&quot;, many programmers go &quot;oh, okay, got it.&quot; If you write &quot;Monoid&quot;, many programmers go &quot;yeeeah, I don&#x27;t know if I have time to learn all this.&quot;<p>This is either a perfectly acceptable cost of avoiding redefining the wheel, or a cautionary tale for future language developers, depending on your perspective.
评论 #7066619 未加载
评论 #7066693 未加载
评论 #7066810 未加载
评论 #7066680 未加载
评论 #7066762 未加载
评论 #7066617 未加载
评论 #7066823 未加载
评论 #7066899 未加载
saosebastiaoover 11 years ago
I call mega-exponential-factorial-to-the-n-bullshit. I tried doing exactly that. You can&#x27;t learn Haskell beyond superficial hello world apps without learning what a monad or functor are, because there aren&#x27;t any substantial teaching materials that don&#x27;t force you to understand it in order to continue learning, and all the common libraries require you to know how to use them because they are undocumented and have no examples.<p>Can you use Haskell without understanding how those things work? Sure...if by &quot;use&quot; you mean you are limited to copied and pasted code snippets without an ability to understand what your code is doing, with the slightest change causing unintelligible compile errors.
评论 #7066758 未加载
评论 #7067138 未加载
评论 #7066972 未加载
ekiddover 11 years ago
This is a nice, short article which basically says, &quot;You don&#x27;t actually need to go learn a bunch of category theory if you want to learn Haskell, so please don&#x27;t stress about it.&quot; Despite the title, it&#x27;s not any kind of general argument that no programmer should learn category theory.<p>Category theory is a strange branch of math—it&#x27;s almost entirely definitions, with only a handful of interesting theorems. As far as I&#x27;ve been able to understand, category theory is a very abstract analogy between very different branches of math: abstract algebra, topology, mathematical logic and (here&#x27;s the interesting part) the lambda calculus, via Cartesian closed categories.<p>This analogy has interesting payoffs, especially for programming language designers and people trying to do seriously weird stuff. For example, let&#x27;s imagine you have a value of type A, a function from type A to type B, and another function from B to C. But if you squint at these types right, it&#x27;s the same as a logical system where A is given, A implies B, and B implies C. Now, it turns out we have automated theorem proving software that can take statements like this and figure out how to get from A to C (even in much more complicated situations). And it turns out the analogy between types and logic is sufficiently strong that you can actually use a theorem prover to write certain kinds of programs without any human intervention, given nothing but the type signatures of your functions.<p>And this is not the only clever analogy lurking here: My favorite is the way that probability distributions can be mapped onto the lambda calculus.<p>So, no, you don&#x27;t need to know all this math to write Haskell programs. (Although some library authors are a little nuts, generally in a good way.) And yes, category theory is a weird branch of scarily-abstract math without many theorems, and Haskell only uses certain corners of category theory. Still, there are times when category theory will allow you to see how far-flung branches of math can be mapped tidily onto the lambda calculus. And that should be of interest to Lisp developers, at least.
lmmover 11 years ago
You need the words to be able to use Haskell. There are too many of them to learn otherwise. I have a similar experience with scalaz, where I tend to only spot useful things in the library after I&#x27;ve reimplemented them, because they don&#x27;t have names that let me find them based on what they do.<p>(Possibly the only benefit of a previous company that wouldn&#x27;t let me use scalaz was that, in reimplementing it myself, I got to give the typeclasses sensible names like &quot;CanFlatMap&quot;)
bonemachineover 11 years ago
Finally someone has the courage to tell the Truth about CT.<p>Next up: the idea that the notions of Monad, Functor, and Category (in whatever guise) are even needed or helpful to do strong FP.
评论 #7066518 未加载
评论 #7066536 未加载
评论 #7066987 未加载
评论 #7067063 未加载
评论 #7066902 未加载
badman_tingover 11 years ago
Makes sense if your goal is to use some particular language (in this case Haskell). But a lot of us don&#x27;t necessarily need yet another programming language, whereas adding to our theoretical knowledge can be beneficial no matter what environment we&#x27;re programming in.
rschmittyover 11 years ago
Side note from this submission is that I did learned you can host html like github<p><a href="https://confluence.atlassian.com/display/BITBUCKET/Publishing+a+Website+on+Bitbucket" rel="nofollow">https:&#x2F;&#x2F;confluence.atlassian.com&#x2F;display&#x2F;BITBUCKET&#x2F;Publishin...</a><p>Nifty!
orlandobover 11 years ago
Linkbait trash.<p>&quot;Don&#x27;t do this thing everybody says you should do. But I do and I like it.&quot;
评论 #7066628 未加载
guard-of-terraover 11 years ago
With such a great number of people around me dabbling in Category Theory, I&#x27;m not sure it&#x27;s worthwhile anyway. I don&#x27;t like crowded areas. Maybe learn something useful but less hot - cryptography perhaps?
评论 #7066862 未加载