HN Books @HNBooksMonth

The best books of Hacker News.

Hacker News Comments on
Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#

Scott Wlaschin · 6 HN comments
HN Books has aggregated all Hacker News stories and comments that mention "Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#" by Scott Wlaschin.
View on Amazon [↗]
HN Books may receive an affiliate commission when you make purchases on sites after clicking through links on this page.
Amazon Summary
You want increased customer satisfaction, faster development cycles, and less wasted work. Domain-driven design (DDD) combined with functional programming is the innovative combo that will get you there. In this pragmatic, down-to-earth guide, you'll see how applying the core principles of functional programming can result in software designs that model real-world requirements both elegantly and concisely - often more so than an object-oriented approach. Practical examples in the open-source F# functional language, and examples from familiar business domains, show you how to apply these techniques to build software that is business-focused, flexible, and high quality. Domain-driven design is a well-established approach to designing software that ensures that domain experts and developers work together effectively to create high-quality software. This book is the first to combine DDD with techniques from statically typed functional programming. This book is perfect for newcomers to DDD or functional programming - all the techniques you need will be introduced and explained. Model a complex domain accurately using the F# type system, creating compilable code that is also readable documentation---ensuring that the code and design never get out of sync. Encode business rules in the design so that you have "compile-time unit tests," and eliminate many potential bugs by making illegal states unrepresentable. Assemble a series of small, testable functions into a complete use case, and compose these individual scenarios into a large-scale design. Discover why the combination of functional programming and DDD leads naturally to service-oriented and hexagonal architectures. Finally, create a functional domain model that works with traditional databases, NoSQL, and event stores, and safely expose your domain via a website or API. Solve real problems by focusing on real-world requirements for your software. What You Need: The code in this book is designed to be run interactively on Windows, Mac and Linux.You will need a recent version of F# (4.0 or greater), and the appropriate .NET runtime for your platform.Full installation instructions for all platforms at
HN Books Rankings
  • Ranked #12 this year (2022) · view

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this book.
Funny enough someone actually wrote a book on it.

Data Modeling Made Functional

It's one of the better and more useful software engineering books I've read. Even if you don't use a functional programming langauge. It's about using Algebraic Data Types do model common problems in the day-to-day business domain (not typical academic problems).

It's a really simple and awesome presentation, and by the end you're dying for the ability to use this more so in the day to day job. Honestly after reading through it, trying to model problems in OOP just seems so unnecessarily obtuse.

The Scott Wlaschin also runs - a link to a talk on it which is decent, but the book is much better.

Thanks. I was asking specifically about accomplishing this in Python.
So, this is going to be an uphill battle for you. I suggest you actually learn Haskell first, and then you'll be able to apply its lessons to TypeScript.

Its tricky because these are patterns that are familiar in Haskell but are not really taught in other settings.

Additionally, to really learn these, you need to experiment with them. Use them. etc. That's pretty hard to do if the learning resources are mostly in haskell and you don't really understand it.

Alternatively, this might help:

Also alternatively, what I would do is just go slowly through the fp-ts code. Look at it a piece at a time and slowly grow your understanding.

This may also help

Mar 02, 2021 · stepbeek on DDD Is Overrated
I haven't, is this the one?
That is the one. It's also an introduction to structuring an F# application so it might not be for everyone but it's an easy read.

Also I'd recommend getting it from here.

Just because I personally like the pragprog site.

I’ll give it a shot - I’ve done some FP so I’m not put off by F#.


Speaking of domain-driven design, the author of this article wrote a great book called 'Domain Modeling Made Functional', which I heartily recommend (even if you don't have a specific interest in learning F#)
An excellent book and one that I used together with Stylish F# and F# Deep Dives to get my current job. Been writing F# full time now for over a year and I must say that it's nothing short of a brilliant language.

Came here from 10 years of Scala with no .NET experience what so ever.

Just overall one of the nicest experiences so far. 9/10, would recommend!

What kind of problems do you solve in your line of work? At what scale, is it performance critical? I love F#, but around six-eight years ago it was not a good fit for solutions to soft real-time problems.
if I might ask, where do you work? and/or in what domain?
Work at a large:ish private bank i Sweden basically doing "digitization" of all customer processes.
I have been debating whether to learn Scala or F# in my spare time. F# seems to be the more pragmatic choice. Doesn't go the insane way of FP that Scala does with complicated libraries or convoluted inheritance hierarchies. The Scala community seems more divided than the F# one with multiple competing ecosystems/libraries for achieving the same thing. My interest lies in webdev/backend and F# seems to be an obvious choice with and it's supplanting libraries. Not sure how Scala fares, but i guess it's not the primary use case for it. On the surface I kind of like the syntax of Scala, it's very familiar but I fear that I would get more frustrated the deeper I would dig because eventually you have to integrate other people's code and the way most of it is written looks to be like haskell in disguise. Not really sure about the pros/cons.
Veteran Scala dev here. I'm not here to convince you to choose it over F# but I can tell you that it's a beautiful language. Scala is used heavily for backend web dev, in fact, it's all I use it for.

Don't worry about advanced concepts, you'll get to those when / if you need them. They have their uses but it depends on what you're working on. I think many people just succumb to the blub paradox too quickly with these sorts of languages. It's a real shame.

It's honestly overstated how hard it is. I started as a junior dev with Scala and was highly productive within months. I don't think there's anything special about me. I was highly motivated by my love for the language I guess.

I've used Scala, Clojure, Haskell, and F#. I'd say F# does a great job of providing a happy middle path between the strict side effect management of Haskell and the advanced OOP features of Scala. It also brings the well-designed ASPNET CORE stack.

If I was starting from scratch and just wanted to learn, I'd say you'll learn plenty from any of them. Haskell has the most to teach about purity in FP, Scala the most about OOP, and Clojure the most about metaprogramming.

F# has the most to offer for just getting things done quickly. It is a language of practical compromises. It's not the most pure, it doesn't bring the most advanced OOP, and it's metaprogramming is tricky. However F# is what I grab first when I want to build production software quickly and safely.

I like your approach to problem solving - it's very similar to mine and in domains I also think about.

Your syntax is very convenient thanks for sharing.

And finally, I assume you're familiar with Scott Wlashin (of F# for fun and profit & "Domain Modeling Made Functional")[1][2]. If not you 100% should read it as it is right up your alley. It's the intersection of Functional Programing and DDD/EIP. (I have no affiliation).



[3] (Railway oriented programming)

Thanks, for the compliment and for the links. I wasn't aware of him until now. I've little experience with the X# family, other than some Mono hacking on an OpenSim clone. Sounds interesting and will definitely read at least the Domain Modeling one, possibly the F#s too (never too late to add a piece of kit to your toolbox).
So I didn't include it in the original link, but he has a book he wrote under the same title (Domain Modeling Made Functional). I've been going through it now. It's a much more in-depth treatment of the same topics. He walks through a small product from start to finish.

Additionally he does a really great job of walking through two things that I don't think are covered well enough at all for beginning and intermediate programmers (and even experienced ones like myself may have missed parts of along the way).

1. How to effectively gather customer requirements, what questions to ask, what things to dig into, how to organize them. A simple walk through, better than the hand-wavy stuff most people do when requirements gathering.

2. How to model a domain / problem space before implementing. How to effectively reason about your entities, services and actions. And iterate on these with your customer before coding.

I seriously wish I had run across this when I first started coding. A really great collection of tangible, actionable advice.

I've never done it in javascript so won't try to guess, but the first two parts of the three part book are really applicable regardless of the language. Will have to finish the third to see how it is.

Domain Modeling Made Functional - Scott Wlaschin
(I have zero affiliation with the author and get nothing from any links)

His blog

Thanks! I bought the book.
HN Books is an independent project and is not operated by Y Combinator or
~ [email protected]
;laksdfhjdhksalkfj more things ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.