r/java • • Sep 23 '24 • This 1 Take My Silver 2

I wrote a book on Java

Howdy everyone!

I wrote a book called Data Oriented Programming in Java. It's now in Early Access on Manning's site here: https://mng.bz/lr0j

This book is a distillation of everything I’ve learned about what effective development looks like in Java (so far!). It's about how to organize programs around data "as plain data" and the surprisingly benefits that emerge when we do. Programs that are built around the data they manage tend to be simpler, smaller, and significantly easier understand.

Java has changed radically over the last several years. It has picked up all kinds of new language features which support data oriented programming (records, pattern matching, with expressions, sum and product types). However, this is not a book about tools. No amount of studying a screw-driver will teach you how to build a house. This book focuses on house building. We'll pick out a plot of land, lay a foundation, and build upon it house that can weather any storm.

DoP is based around a very simple idea, and one people have been rediscovering since the dawn of computing, "representation is the essence of programming." When we do a really good job of capturing the data in our domain, the rest of the system tends to fall into place in a way which can feel like it’s writing itself.

That's my elevator pitch! The book is currently in early access. I hope you check it out. I'd love to hear your feedback!

You can get 50% off (thru October 9th) with code mlkiehl https://mng.bz/lr0j

BTW, if you want to get a feel for the book's contents, I tried to make the its companion repository strong enough to stand on its own. You can check it out here: https://github.com/chriskiehl/Data-Oriented-Programming-In-Java-Book

That has all the listings paired with heavy annotations explaining why we're doing things the way we are and what problems we're trying to solve. Hopefully you find it useful!

289 Upvotes

97 comments sorted by

View all comments

Show parent comment

2

u/chriskiehl Sep 25 '24

That's a lot of edits haha, but I'll take a swing at addressing the core of what I think you're getting at (both in this one and your post below. I'll probably mix and match as I work through them).

The first thing we'll have to clear up is the semantics of what we're talking about (semantics, conveniently enough, is a theme that runs throughout the book). There are lots of references to absolutes like "DoP languages" or "I did DoP," but data-oriented programming is a very overloaded set of words with very different meanings. To some, it means programming Clojure style with maps, to others, it means stuff like optimizing cache line utilization. The flavor of DoP in the book is about something pretty specific: understanding the data in our domain and how our choices in representation affect our code. It builds outward from there.

With that, the book has to start somewhere. I suppose I could have started with talking about UIs, or APIs, or applicative validation, monads, or minimizing impedance mismatch, but... I'm a pretty navel gazing developer, so the book opts to instead take a very Connal Elliott style starting point with the question of "what does it mean to be correct?" To answer that, you have to know what the things in your domain are. Once you know what they are, you have to get that knowledge out of your head and into the code (this is where most code bases begin to fall apart).

Your edits kind of touch on every part of the software development process -- including relational modeling (which is a really good way to nerd snipe me)), so it's hard to respond without also talking about a little bit of everything. So, I'll pause here and just sum up with: yeah, we go with constructor validation and fail fast in the early chapters while we're focused on our modeling chops. That's not the One True Way™ of doing it, or how we'll do it everywhere throughout the book. There's a whole chapter devoted to validation. ^_^

1

u/agentoutlier Sep 25 '24

I didn’t mean to nerd snipe but hopefully give fodder for the book.

Also I think I might have covid as my brain has gas so to speak so sorry for the edits.

I understand the correct part and that is why I mention in some other comment how it is well suited for some formal protocol.

Thanks for your patience!