AstonJ

AstonJ

Functional Web Development with Elixir, OTP, and Phoenix (Pragprog)

by Lance Halvorsen

Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web applications. Make the most of them as you build a stateful web app with Elixir and OTP. Model domain entities without an ORM or a database. Manage server state and keep your code clean with OTP Behaviours. Layer on a Phoenix web interface without coupling it to the business logic. Open doors to powerful new techniques that will get you thinking about web development in fundamentally new ways.


Don’t forget you can get 35% off the ebook using the code ‘devtalk.com:023:

Can’t wait :003:

460 27163 124

Most Liked

redrapids

redrapids

Author of Adopting Elixir

This is a very good post. This is why I love the Elixir community.

Lance and I are working with some great reviewers to make sure we address this feedback. We’re going to shift the approach for the two chapters in question, the chapter on modeling and the chapter on wrapping the result in OTP.

As a popular book in the community, we want to make sure that the guidance we give is sound.

Thanks again for a great post.

lance

lance

Author of Functional Web Development with Elixir, OTP, and Phoenix

Thanks for the hat-tip! I’m beyond excited for the beta launch. :grinning:

17
Post #2
mjadczak

mjadczak

I grabbed the book and had a (virtual) leaf through, and I would have two main comments:

First, perhaps I didn’t read the book page properly, but I had the impression going in that this was going to be much more advanced than it was. The PragProg page shows the skill level as “intermediate to expert”, and while I agree that it is not a beginner book, I would not call it expert-level either. By “have previous experience with Phoenix and Elixir” I took “have built complete, if maybe simple, applications with them” rather than “know how the syntax works and how a Phoenix interface is structured”. I think clarifying exactly the target audience of the book may be beneficial.

Second, I take issue with the way that the entire game state is represented in a bunch of processes referring to each other by holding PIDs. I think the best way to say what I mean is to simply refer to this great article by Saša Jurić. The way this is implemented in the book smells really strongly of trying to make Agents behave like objects, which is a common mistake for those moving over from OOP, but should in fact be explicitly called out in a book like this, instead of impliedly encouraged.

I think at a certain point you mentioned that “trying to store the whole game state in a functional tree structure is a recipe for bugs because coordinates can belong to both islands and board and we’d have to update them in both places”. The answer to that problem is to normalise the way you’re storing the coordinate data, so you’re only storing it once. It’s certainly not to make each little piece of your state be a separate process!

As has been discussed many times over on this forum, separate processes should be used when a separate concern, either separate in time or separate in failure domain, is present.

Further, what happens when these processes die? They are all linked it seems, so one failure will take down the entire system. If you insist on using them to model the state, perhaps it is at least an opportune time to put them into a custom Supervisor and use Registry to register them with the coordinate/board they represent?

I’m sure it is not the intention of the book to do so, but while I applaud the decoupled, “Phoenix is not your app” approach, I feel it either itself falls or encourages people to fall into common traps when structuring Elixir apps and modelling their domains therein.

I don’t mean to be too negative—I think the concept of the book is great, and a practical walkthrough of how to build something fun but useful is a great way to convey the concepts, but I also think it’s crucial that the approaches set by the book are 100% defensible (to avoid saying “right”) and push people towards actually using the great many tools Elixir gives us in the way they were designed to be used.

peerreynders

peerreynders

Wow - this is just above and beyond. Drastic “mid-voyage course correction” despite the consequences, dedication to a quality product, you have to respect that!

So - don’t bother with any more errata?

Sometimes, beta happens. We just got some great technical feedback from people we trust in the Elixir community. Since the book is so far along, the feedback was especially painful, but we have decided to incorporate it before we go forward with the rest of the book. We chose to use Agents as a way to approach OTP, but we overused them. Unfortunately, that sent the wrong message about good application design in Elixir, and we sincerely apologize for that. The next beta will put functional principles front and center. We’ll use separate processes only when the design calls for them, and we’ll stick to plain modules and functions when it doesn’t. So you’re getting a better book. The downside is that it will take some time. You won’t see the next beta version until approximately mid-May. Know that we have your best interests in mind. As one of the more popular Elixir books right now, we want our guidance to be rock solid, so we’re enlisting some great talent in our review process to improve the book. Since it’s delaying our betas, we wanted you to know.

Thanks for your readership and your patience.

lance

lance

Author of Functional Web Development with Elixir, OTP, and Phoenix

Thanks so much for your support @peerreynders!

I’ll be honest, rewriting chapters is no fun, but what would be worse is releasing a book that isn’t the absolute best it can be.

For your errata question, if you have any for chapters 6 and 7, send them along. I would say it’s probably better to hold off on any for the other chapters for now.

Where Next?

Popular in Books Top

PragmaticBookshelf
Kevin Hoffman edited by Kelly Talbot @KellyTalbot Reality is event-sourced; your mind processes sight, sound, taste, smell, and touch to...
New
PragmaticBookshelf
Bruce A. Tate @redrapids and Sophie DeBenedetto @SophieDeBenedetto edited by Jacquelyn Carter @jkcarter The days of the traditional requ...
New
New
PragmaticBookshelf
Rebecca Le and Zach Daniel @zachdaniel _edited by Kelly Lee @k.lee _ Ash Framework is the game-changing toolkit for Elixir developers. W...
New
vincentvanbush
Hey! Happy to announce the Elixir Adoption Guide by Curiosum, announced during this year’s ElixirConf EU, is out to the public now :slig...
New
mchean
By @emadb OVERVIEW Author Emanuele DelBono guides readers along the first steps of mastering the Elixir programming language in Elixi...
New
AstonJ
Classing this as a free online book :003: By Sean Callan with help from the community Lessons about the Elixir programming language...
New
AstonJ
by Benjamin Tan Wei Hao The Little Elixir & OTP Guidebook gets you started programming applications with Elixir and OTP. You begin w...
New
peerreynders
Don’t forget you can get 35% off the ebook using the code: devtalk.com :023: Note: Check out this thread for help running code in lat...
New
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement