Live data from Hacker News

Basic Category Theory for Scala Programmers

blog.scalents.com

1–10 of 18 posts

Re: Basic Category Theory for Scala Programmers

#3
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

#5
post #4

How important is this to understand in practice for a Scala programmer?

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

#6
post #4

How important is this to understand in practice for a Scala programmer?

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

#8
post #4

How important is this to understand in practice for a Scala programmer?

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.

Post reply on HN