Hacker News new | ask | show | jobs
by tathougies 3337 days ago
> They're very useful, but try to avoid code that requires your coworkers to know abstract algebra and category theory in order to contribute to a project.

Have you ever learned a 'design pattern' in Java, Python, C++, etc? What's the difference between learning this and learning about monoids (for example). Monoids are super easy and actually compose, unlike the majority of design patterns. In my experience, learning OO design patterns was substantially more difficult than learning algebra, but I think this is mainly due to how CS education is carried out in many universities. I feel if people start with mainly FP, then OOP is what seems odd and necessitating learning odd, abstract concepts, except there's the added bonus that all the abstractions are leaky.

Ultimately though, you don't even need to learn any algebra or category theory. It was multiple years after I had already learned and started using Haskell that I even began to become interested in these topics. My interest was mainly piqued by a desire to not duplicate code -- it certainly isn't required to learn algebra to understand Haskell, in the same way it's not required to understand machine assembly to program in C++, or GPU transistor layout to understand OpenGL.

> a general sense often require more cryptic constructs as scaffolding.

My professional experience is mainly as a Haskell dev. What is 'scaffolding'. I don't think I've ever used such a thing.

4 comments

A monad is just a monoid in the category of endofunctors, what's the problem?
Design patterns are usually taught by describing several example problems, and then introducing the design pattern as something to solve all of them. The value of the abstraction is obvious. Haskell is more often taught as though flexible abstraction is an end in itself, and practical uses for it are somehow distasteful. This teaching style only appeals to people who think mathematics is "elegant" or "beautiful" instead of just a useful tool.
Perhaps you're reading the wrong documentation. I've personally never found it that way. Most documentation on hackage is very concrete, and for the ones that aren't (i.e., lens), there are plenty of tutorials.

I've definitely encountered the abstraction-for-the-sake-of-abstraction types, but those are mainly academics, in my experience.

I mean, monads are (for some reason or the other) the killer feature of Haskell abstraction, and their use case is extremely concrete. map, fold, etc are also motivated by very concrete desires.

Even more advanced concepts, like zippers, generics, lenses, ftpe, etc are all motivated by extremely concrete problems.

"All non-trivial abstractions, to some degree, are leaky." - Joel Spolsky

> In my experience, learning OO design patterns was substantially more difficult than learning algebra, but I think this is mainly due to how CS education is carried out in many universities.

You supported my argument. In addition to this, there are many code academies that pump out graduates with almost no mathematical foundation work. Until that changes, functional languages will always take the back seat.

> "All non-trivial abstractions, to some degree, are leaky." - Joel Spolsky

If you learn Haskell you will see this is total bollocks.

What's the Haskell code for preventing me touching the power switch?
I think you fundamentally misunderstand what the word abstraction means and the point of it.
Touching the power switch will not lead to an incorrect result being returned.
A late result is an incorrect result in real-time systems. And if time isn't an issue, what's the Haskell code that stops me overclocking the CPU enough to make it unreliable?

All software is leaky abstraction because it doesn't run on abstract mathematics, it runs on hardware. I can literally smash it with a hammer and then all the "guarantees" are worthless.

> All software is leaky abstraction because it doesn't run on abstract mathematics, it runs on hardware. I can literally smash it with a hammer and then all the "guarantees" are worthless.

Man, if that were the only thing that could make software go wrong, we would live in a much better world.

If the CPU violates its spec then the code will violate its spec, sure. That's not an abstraction leak though - if the CPU violates its spec then hand-crafted assembly would also go wrong.
> it's not required to understand machine assembly to program in C++

Yes, it is. If you don't get this, you'll be a lousy C++ programmer.

> Yes, it is. If you don't get this, you'll be a lousy C++ programmer.

Hmmm.... I mean I understand assembly, and did before I was a C++ developer, but really, you don't need to understand assembly to program C++ anymore than you need to know java bytecode to program java. If you stick to defined behavior, the program will work the way you expect it.

Perhaps you mean you need to understand assembly to debug C++ performance issues? I mean that's true of basically any language compiled to native code.