Qqwy

Qqwy

Algebra Driven Design (self-published) (leanpub)

Hey all! I came across this book yesterday, and bought the full version after reading the sample; currently roughly halfway through the book.

It seems very interesting: ‘discover’ a library by starting with a couple of simple datatypes and relationships (‘laws’) between them by first finding more laws, then creating a naive (slow but trivially correct) implementation which is then used to parity-test the final optimized implementation.


Hi there! My name is Sandy Maguire — you might know me from my work on Polysemy and Thinking with Types.

One of purely functional programming’s greatest strengths is its powerful abstraction capabilities. We proudly exclaim that our functions are referentially transparent, and because of that, our bugs will always be shallow. And this is often true.

10x is often cited as the magic number beyond which technology is good enough to overcome network effects. I’m personally convinced that functional programming is 10x better than any other paradigm I’ve tried. But if functional programming is so good, why hasn’t it yet taken over the world?

This is a very serious question. If we’re right about this, why haven’t we won?

Algebra-Driven Design is my answer to this question. Functional programming hasn’t taken market share because we collectively don’t yet know how to write real applications with it. Abstraction is our language’s greatest strength, but all of our “best practices” evangelize writing the same procedural code and use the same techniques as we would anywhere else.

Instead of giving up, this book encourages us to take a heavy focus on designing leak-free abstractions, on understanding programs so well that the code and tests can be largely generated automatically, and on finding performance improvements not via intuition, but through algebraic manipulation of the program’s underlying equations. Functional programming affords us so many new possibilities for designing and testing better code, but this information is scattered and lost in ancient journals. I’d like to change that.


https://reasonablypolymorphic.com/blog/algebra-driven-design/

Most Liked

Qqwy

Qqwy

Read the second half of it (It’s ~370 pages including appendices), and loved it!

In a nutshell, the idea behind Algebra-Driven Design is:

  • Programming should not be code-centric; computer programs should be (only) the result of thinking about problems.
  • So program source code itself is the wrong level of abstraction when thinking about solving most problems.
  • Instead:
    1. Create a structured model of understanding. (An algebra, if you will).
    2. Check your model using e.g. QuickSpec to find out if your reasoning is correct, and what other laws might hold true to further refine it.
    3. The output of the previous step can be codified as a rigid set of properties which any implementation of your abstraction must adhere to to be correct.
    4. Only now we create an actual implementation based on the properties we’ve found. At every step of the way we can see whether we are on the right track because we have this clear suite of property-testing-properties available. This also means that refactoring and optimizing can be done fearlessly by anyone in the future.

Whenever we find a flaw in our reasoning, we can backtrack to an earlier step and continue from there.
And this is cheap since we haven’t committed hours or days to writing an implementation before finding out that the underlying concepts were incomplete or broken.


I think this workflow is beautiful. The one thing I am not entirely sold on yet, is on how widely it can be applied:
The book itself already states that this design flow is more ‘library-centric’ than ‘application-centric’,
although it also states that a concrete application ought to only be a thin wrapper around a group of reusable libraries (which I agree with).
However, while the two examples chosen in the book: ‘Functional Geometry’ and ‘Scavenger Hunt’ work really well for this technique,
there might be some survivorship bias here (these two examples might be chosen exactly because they work well).

I’ll have to try to apply Alg-DD to the ideas of me and my coworkers to see where its limits truly are.


In any case, I very much enjoyed the book, and whole-heartedly recommend it to people who want to learn a new technique for structuring their code.
The book explains the concepts it covers very well.
It should be easy to pick up for people who have a little functional programming skills.
It should also be possible to learn from it for people who do not have these skills yet (the book has a great appendix in which all the features the book uses are explained from the ground up), but it will definitely be a bit more challenging.

I do not think the techinques in the book are hard to learn; I do think that some of this knowledge goes ‘against the grain’ of current conventional Computing Science education,
which means that you might need some ‘un-learning’ if you’ve only encountered e.g. OOP with OOP-centric software design patterns so far.

Very much worth the price! :+1:

SmithyTT

SmithyTT

Going to be interesting hearing whether you thought it was worth the money :crazy_face:

Qqwy

Qqwy

Some background in functional programming will help a lot (and it is probably the reason I was able to read through the book so quickly) but as bare prerequisite high-school math (i. e. working with equations involving variables and solving simple proofs with them) should be enough :-).

Popular General Dev topics Top

brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
Please share your favourite Vim tips here :nerd_face:
New
ohm
I just switched jobs to tech lead with a small team of about 6 other developer. This is my first tech lead job. What do I need to know? A...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
OvermindDL1
Yet another rust-made text editor, though I’m really liking the looks of how this one works!
New
CommunityNews
Christian Mills - Testing Intel’s Arc A770 GPU for Deep Learning Pt. 2. This post covers my experience training image classification mod...
New
CommunityNews
The Definitive PHP 7.2, 7.3, 7.4, 8.0, and 8.1 Benchmarks (2023). We tested the performance of 14 PHP platforms (WordPress, Drupal, Lara...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
AstonJ
Or looking forward to? :nerd_face:
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New