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 :-).

Where Next?

Popular General Dev topics Top

PragmaticBookshelf
Computer security is a complex issue. But you don’t have to be an expert in all the esoteric details to prevent many common attacks. Atta...
New
PragmaticBookshelf
Don’t engineer by coincidence—design it like you mean it! Grounded by fundamentals and filled with practical design methods, this is the ...
New
PragmaticBookshelf
Great programmers practice to keep their skills sharp. Get sharp and stay sharp with 57 practice exercises rooted in real-world scenarios...
New
PragmaticBookshelf
The Cucumber Book showed you how your team can work together to write executable specifications—documents that tell a clear story and als...
New
PragmaticBookshelf
Get ready to kick some software project butt. By learning the ways of the agile samurai you will discover: how to create plans and sched...
New
PragmaticBookshelf
As a techie, you have a tougher time finding and winning the right job. Companies are more demanding. Just like you, your competition is ...
New
PragmaticBookshelf
Success in today’s IT environment requires you to view your career as a business endeavor. In this book, you’ll learn how to become an en...
New
PragmaticBookshelf
Many books and articles have been written describing agile, adaptable approaches to writing software. But somehow, reading about software...
New
CommunityNews
This book has been taken out of print by W. H. Freeman. You are welcome to use it if you like. We believed in 1992 it was the way to intr...
New
First poster: davearonson
This book provides a broad introduction to algorithms for decision making under uncertainty. We cover a wide variety of topics related to...
New

Other popular topics Top

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
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1142 25765 758
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
New
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New