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

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1016 16836 371
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
The reviews are coming in - if you spot any or have a review of your own, please add it :nerd_face: @ohm will be pleased, they seem to b...
New
AstonJ
Please share your favourite Vim tips here :nerd_face:
New
DevotionGeo
The version of Java installed with Android Studio on my Mac is the following (when I run java -version) openjdk version "1.8.0_242-relea...
New
herminiotorres
Someone where use Doom Emacs right now? I like to starting this topic to discuss it and learn a little bit more, not just only the emacs ...
New
OvermindDL1
What shell(s) do you use, why do you use them, and how do you have them configured? Note, this is about shell’s, not terminals, terminal...
New
AstonJ
I love my Kindle Oasis for reading, but unfortunately it’s not great for technical books as you often need to click on a link or do a qui...
New
hskohli
We are looking to hire a freelancer to design the complete pipeline for the following problem statement: Hardware to be used: Jetson Na...
New
First poster: OvermindDL1
Using Zig to Build Native Lua Scripts. Using Zig to Cross compile a Lua script for multiple arches
New

Other popular topics Top

AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
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