5 ms·
In my opinion, the only type of mathematics that is useful to ALL programmers is discrete math. This is applied math that barely resembles the kind of math that
by andykx 6y ago
In my opinion, the only type of mathematics that is useful to ALL programmers is discrete math. This is applied math that barely resembles the kind of math that you learned in high school, but it’s easy to see how these thoughts lead to the creation of computers.
Other types of math are relevant depending on what you’re interested in, but I think students should learn discrete math before diving into writing any serious code.
- onion2k 6y agoThere's a decent series of "Math for programmers"[1] on YouTube from FreeCodeCamp that covers the basics of discrete math. I've been recommending it to people who want to learn to code for a little while and it seems to go down well. [1] https://www.youtube.com/playlist?list=PLWKjhJtqVAbndUuYBE5sVViMIvyzp_dB1 https://www.youtube.com/playlist?list=PLWKjhJtqVAbndUuYBE5sV...
- eru 6y agoCategory theory is also very relevant to programming. But, curiously enough, learning and practicing programming is probably a better intro to eventually get to category theory, than the more usual approaches mathematicians take. Discrete math is lots of fun, but less applicable to the kind of glue code many people write most often. (Category theory is in some sense exactly the theory of glue code. But it's also generalised abstract nonsense.)
- whytaka 6y ago> Category theory is in some sense exactly the theory of glue code. If you can explain this to the satisfaction of my understanding, I would like to subscribe to your newsletter.
- eru 6y agoFirst a qualification: Category Theory doesn't teach you how to write glue code, but it can be seen as a theory to organizing some of our understanding of glue code. One simple example would just be a discussion around the different use cases of Functor, Applicative Functor, Arrows and Monads. And how they relate to common programming constructs like functions, tuples, arrays, Maybes, futures, whatever's happening in react, etc. Category theory won't help you learn those concepts, but once you know those concepts, even a superficial understanding of some category theory, can help you organize your thoughts. As a genuine application of category theory, whenever you find a useful abstraction (like eg functors or monads again), you can have a look at its dual, and see whether that's another interesting structure you haven't seen yet. Just like tuples and Either are duals of each other. (As an analogy, dualizing is also a concept in linear programming. Linear programming can help solve many interesting algorithmic problems, like sorting or matching or assignment or median selection, basically almost anything that's in P, and if you allow integer linear programming than you can solve what's in NP. However, I wouldn't recommend anyone who wants to learn about algorithms and data structures to start with linear programming. But once you know a bunch of algorithms, you can re-express the problems they are solving in terms of linear programming, and see whether you get anything interesting out of looking at their duals.)
- iambrj 6y agoI disagree, it depends on the kind of programming you do. Build fancy typeclasses to do black magic in Haskell? Then _perhaps_. Write kernel modules for custom functionality in C? Then learning ct is like a fish learning to climb a tree.
- eru 6y agoYes. Though CT can help you with systems programming as well. But you wouldn't want to use C nor Haskell.
- ogogmad 6y agoI don't understand how learning the definition of a limit, colimit, adjunction, pushforwards, pullbacks, equalisers, co-equalisers and the Yoneda lemma, can help you write code. But I'm willing to be enlightened.
- tome 6y agoSome starting points: tuples are categorical products (an example of limits), sum types are categorical coproducts (an example of colimits), effects are often monadic and monads arise from adjunctions, the Yoneda lemma tells you that if you have "f a" and "a -> b" and you know nothing more about the "a" then all you can do is fmap the function over the functorial value. Sure, knowing this doesn't "help you write code" in the same way that knowing "you press the keys on the keyboard to get text to appear on the screen" but I've found this way of thinking to be beneficial to some degree when programming. But I think that eru is trying to emphasise that one should learn how to program first and then use category theory as a tool to organise your understanding.
- cannabis_sam 6y agoDo you think category theory is more useful than type theory or logic? I’ve personally gotten a lot more out of treating tuples as product types or logical AND, and disjoint unions as sum types or logical OR, as opposed to categorical limits. (Basically, what’s the extra value added from Curry-Howard-Lambek, as opposed to just Curry-Howard, in terms of programming?) (I’m not trying to be argumentative, I’m genuinely curious.)
- tome 6y agoI would put category theory very far down the list of things a programmer should learn. Once a programmer has learned a lot of other things about programming, category theory can act as a good organisational and explanatory tool.
- eru 6y agoYes, that was what I was going for. For what it's worth, https://bartoszmilewski.com/2015/09/01/the-yoneda-lemma/ https://bartoszmilewski.com/2015/09/01/the-yoneda-lemma/ does a pretty good job of explaining the Yoneda lemma in a programming context. Look for the section "Yoneda in Haskell". As I also tried to say earlier, in practice I suggest learning programming first, and then using the likes of category theory to organise your understanding.
- justinmeiners 6y agoCategory theory is mostly useful for modeling computation theoretically and thus designing languages. It's also not that helpful to learn unless you already know a lot of deeper math, like introductory algebraic topology, etc.
- eru 6y agoI suspect the relation with algebraic topology is mostly an artifact of history.
- justinmeiners 6y agoThat is true, but it still provides tons of examples of functors such as fundamental group and homology. These sorts of interesting functors are not common outside of graduate math.
- eru 6y agoYes. I think programming provides a lot of interesting examples of eg functors and other such structures. Enough to build your intuition at least, and then start learning category theory from there. (And then try to use that knowledge to kick off some further investigation into the other areas of math that category theory historically comes from, if you are so interested.) I think it's a bit like learning Spanish first and then Latin later. Vs learning Latin first and then some romance languages.
- tchalla 6y ago> In my opinion, the only type of mathematics that is useful to ALL programmers is discrete math. If we were to think there exists a subset of programmers who don't find Discrete Math useful, what would those programmers look like?
- mhh__ 6y agoWeb developers, or at least the folks who just do A->B frontend stuff. Without being elitist, I've done some of it and the only stress I felt mentally was due to the baggage of learning the frameworks and things (I might have used an integer or two but nothing more)
- twic 6y agoMore generally (and less insultingly!), any programmers who mostly work with frameworks, rather than writing solid chunks of their own code. I had a job building e-commerce websites on top of a framework. Our code was a thin layer invoking and customising the framework. It was difficult work that we charged a lot for, because it required extensive knowledge of the framework (which was badly designed and poorly documented). But it never involved thinking really hard about programming itself. I would imagine most Rails programmers are in a similar place.
- AnHonestComment 6y agoI think a lot of people really liked discrete math, which is awesome. My experience in industry suggests probability, linear algebra, and category theory are all more useful in practice.
- joppy 6y agoI strongly disagree. Having taught mathematics to many computer science students, virtually any mathematics course in which students need to write a proof is invaluable, regardless of content. While I agree that discrete mathematics is more applicable than some other parts of mathematics, I think that the real value mathematics provides to programmers is the skill to think through and reason out complicated problems. Teaching a mathematically literate student about a discrete mathematics concept when they need or want to know it is quick and easy. Forcing students to take subjects they may not find interesting is a sure way to set them up for failure.
- zozbot234 6y ago> Having taught mathematics to many computer science students, virtually any mathematics course in which students need to write a proof is invaluable, regardless of content. Discrete mathematics also makes it easier to introduce rigorous proof. Calculus courses are not even "proof-based", compared to real analysis which is the actual level of proof you'd get in discrete math.
- joppy 6y agoRigorous proofs can be introduced in many courses. Personally, my first course making a large emphasis of proof was real and complex analysis (which was the calculus course), then linear algebra. I also took “discrete mathematics for computation”, a course specifically aimed towards computer science students, but that course was so chock-a-block full of content that there was no time for proofs. I find discrete mathematics proofs very doable and useful, but pretty boring compared to analysis and algebra, and I very much enjoyed practicing mathematics skills in the latter rather than the former. (This is coming from someone who has published papers in combinatorics).
- publicola1990 6y agoAtleast till some years ago Queuing Theory was considered fundamental for CS, and certainly statistics and probability and spatial geometry is very important for CS, apart from discrete math. Also entirely another kind of math is also used often by CS, the "numerical methods", and also the fundamental arithmetic on digital domain, which also is usually treated separate from discrete math.