Re:Basic Category Theory for Scala Programmers
by networked on Sunday September 24, 2017 @03:05AM
(#15323662)
Bartosz Milewski has a series of posts (a book, really) and recorded lectures that teach category theory with Haskell and C++ as reference points. HN discussion: https://news.ycombinator.com/item?id=14026360.
Re:Basic Category Theory for Scala Programmers
by yaseer on Sunday September 24, 2017 @08:25AM
(#15324421)
This is a great set of articles, thanks for sharing.
I place category theory within the same realm as the lambda calculus. Understanding category theory will enrich your understanding of the underlying computer science concepts, particularly with respect to functional programming. However, it's far more in the realms of computer science than software engineering. Software engineers can benefit from a conceptual overview, which this blog post provides in excellent form.
Unless your work involves formal proofs, I can't see many software engineering use cases where a more in-depth exposition would carry significant utility.
Re:Basic Category Theory for Scala Programmers
by alextheparrot on Sunday September 24, 2017 @01:37AM
(#15323488)
Scala’s category theory faculties are so incredibly awkward without an outside library like Cats, I never thought I was writing “good code” in the functional style in Scala until I started using Monads et al via Cats/Scalaz. Don’t get me wrong, I could compose my function A then B then C, but now I’m passing around these awkward Function1 instances that are hard to reuse and honestly just look unstructured. It feels like fighting against a tide instead of riding it to shore.
The utility also doesn’t necessarily come from the ability to transform A => B, as this is often provided by the user, but from being able to maintain the context while doing so (Mapping over a future should maintain the asynchronous context, mapping over a try should maintain the error capturing context). I understand the author appears to know much more, but I also don’t accept that they’ve contributed anything to a novice reading and attempting to improve/modify their Scala code via an improvement to their category theory knowledge.
Re:Basic Category Theory for Scala Programmers
by gclaramunt on Sunday September 24, 2017 @10:17PM
(#15327650)
You're right and I struggled with the idea to add more in the first post, but I've decided to leave the more interesting stuff (Functors!) for the next part.
Re:Basic Category Theory for Scala Programmers
by ivanhoe on Sunday September 24, 2017 @06:02AM
(#15324130)
My understanding is that, just like the abstract algebra, category theory is a useful tool to help you recognize patterns and provide you some level of certainty about their behavior. Rather than figuring out yourself if you should do something one way or the other, you can say: Hey, I know it's X, and people smarter than me have proven that X will behave in a certain way and that I can do certain stuff with it. When building complex systems this can save you a lot of time and nerves. However, with a common, simpler software that most of us build, it's more about writing the eloquent and stylish code, than an absolute necessity for a programmer. You definitely can work in scala for years without knowing anything about it.
Re:Basic Category Theory for Scala Programmers
by giomasce on Sunday September 24, 2017 @02:51AM
(#15323616)
Basing on how much it is important to understand categories to know mathematics or to know other languages, I would say nothing. But probably it can be fun, and definitely you can then brag about it.
However, if you still have to learn X, don't try to learn categories to learn X. First learn X decently, then if you want learn categories (or any algebraic abstractions that people say it is useful) and you have some hope that categories will give you some additional insights on X.
Re:Basic Category Theory for Scala Programmers
by bad_user on Sunday September 24, 2017 @02:54AM
(#15323626)
You can get by with Scala, or Functional Programming in general, without an understanding of category theory, although naturally some CT concepts will creep into your understanding without you realizing it.
Category Theory basically provides a framework for talking about composability in rigorous language. It's important if you want to grok Functional Programming concepts, but you can get by without it just fine.
Re:Basic Category Theory for Scala Programmers
by usrusr on Sunday September 24, 2017 @05:26AM
(#15324050)
Not at all or absolutely essential, depending on wether or not you work with developers (or with their libraries) who use this as the language to talk about code.
Re:Basic Category Theory for Scala Programmers
by yuvalitzchakov on Sunday September 24, 2017 @04:32AM
(#15323891)
Since Scala is a hybrid language, you can still program in it and do things as you would do in Java, for example. You will see common patterns emerging, such as seen a `map` method on List, Option, Try, etc.. Now, you could ask yourself "What is this pattern and why do I see it everywhere?", or you can just continue with your life being satisfied with what you know today, and no harm will be done.
I've been doing Scala for the past two years, and the amount of things I've learned feels amazing. I've watched (and still am watching) Bartosz Milewskis
"Category Theory for Programmers" which takes you from the very fundamentals of CT all the way to things like Adjunctions and Kan Extensions. I find it fascinating.
Re:Basic Category Theory for Scala Programmers
by kailuowang on Sunday September 24, 2017 @09:45AM
(#15324667)
I wrote introductory blog post answer that.
https://tech.iheart.com/why-fp-its-the-composition-f585d17b0...
TLDR; It's about the ability to compose. Category theory enables more general and powerful composition of components. That is not to say that without CT you won't be able to compose, it's just more cumbersome and less flexible.
I place category theory within the same realm as the lambda calculus. Understanding category theory will enrich your understanding of the underlying computer science concepts, particularly with respect to functional programming. However, it's far more in the realms of computer science than software engineering. Software engineers can benefit from a conceptual overview, which this blog post provides in excellent form.
Unless your work involves formal proofs, I can't see many software engineering use cases where a more in-depth exposition would carry significant utility.
The utility also doesn’t necessarily come from the ability to transform A => B, as this is often provided by the user, but from being able to maintain the context while doing so (Mapping over a future should maintain the asynchronous context, mapping over a try should maintain the error capturing context). I understand the author appears to know much more, but I also don’t accept that they’ve contributed anything to a novice reading and attempting to improve/modify their Scala code via an improvement to their category theory knowledge.
Does that answer the question?
However, if you still have to learn X, don't try to learn categories to learn X. First learn X decently, then if you want learn categories (or any algebraic abstractions that people say it is useful) and you have some hope that categories will give you some additional insights on X.
Category Theory basically provides a framework for talking about composability in rigorous language. It's important if you want to grok Functional Programming concepts, but you can get by without it just fine.
I've been doing Scala for the past two years, and the amount of things I've learned feels amazing. I've watched (and still am watching) Bartosz Milewskis "Category Theory for Programmers" which takes you from the very fundamentals of CT all the way to things like Adjunctions and Kan Extensions. I find it fascinating.