by jinwoo68 · 6y ago · 0 comments
They usually make perfect sense and useful abstractions, but at the same time they scare many programmers away. Especially non-math-savvy programmers will be easily turned away when they see code that is heavily abstracted in a mathematical manner.
I also come from Lisp and Lisp focuses on building a language using the terms/concepts from the given problem domain. And when you do it right, it makes the code very natural in that specific problem domain and any domain experts can understand the code easily.
Haskell communities do it very differently by making everything a mathematical problem, and it's only math experts who feel comfortable with the code.
Many times being in the middle of any two extremes is a pretty bad experience.
If you shy away from math though, you get closer to tapping into the average programmers experience in other languages.
Because of that, it's easier and more familiar.
Those things are good for adoption, but not necessarily a Haskell experience that is so good it's clearly better.
I think the direction Sandy goes in does achieve something objectively better.
My advice is to try it out and don't let the "it's too mathy like Haskell always has been" comments bog you down.
Do be prepared to learn a new paradigm and solicit help from others to be able to learn it in a timely manner.
- A Haskell programmer who never made it past algebra
For example, sure, you can think of a list as a "monoid" where the add operator is concatenation of two list. But adding two lists is not a fast operation even using specialized functional data structures. So making concatenation a primitive for equational reasoning just results in really slow code.
Exactly! The thing is this book gives a method where you care about value semantics, keep the ideal representation, and then care later about how it's realized in the hardware!
For example in mathematics if you write "C = A + B" and then you ask what A is, it's still always going to be the same.
To make this work in programming you basically have to make all your data structures persistent[1]. AFAIK you would need a store the list as a finger tree or something if you need fast concatenation and that will still only be O(log(n)) [2].
[1] https://en.wikipedia.org/wiki/Persistent_data_structure
[2] http://hackage.haskell.org/package/fingertree-0.1.4.2/docs/D...
[3] https://stackoverflow.com/questions/28406512/why-does-concat...
There is a memory issue because of this, but this problem isn't exclusive to FP languages. Many languages solve this with something called garbage collection.
You seem to have an example in mind where this leads to the "making everything a mathematical problem" , can you share it?
> Haskell communities do it very differently by making everything a mathematical problem, and it's only math experts who feel comfortable with the code.
I program in Haskell every day and I have no idea what Haskell code you have in mind.
Also as I've said elsewhere, nearly everyone reading this has more math experience than this Haskell programmer without a degree or calculus class under their belt.
The thing is when you start attacking odd problems you can find solid solutions in 100LoC instead of brittle sandcastles made with 27 classes.
Let's let haskellers go wild in their abstractitis, it's great. Sure it's not important for many cases but let them roll.