Mraiih
Hello people,
I am a junior Rubyist and actually learning Elixir for fun. While I was learning some OOP design patterns for my job, I was wondering: “What about Elixir, functional and concurrent programming?”
I always see things about the Gang of Four, OOP, popular stuffs like that, but for FP, I came across this image:
I know design patterns came to resolve some common problems in OOP, but I suppose FP isn’t perfect and some problems can occur as well
Can anyone shed some light on this subject? And share some resource if needed?
Thanks a lot ![]()
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
There are design patterns, but they are different.
One video I liked when switching from Ruby to Elixir is…
OTP is also a guide to good design with processes. It is worth learning.
The FP side of Elixir and Erlang is pragmatic, You can have side effects everywhere, and You don’t have some tools others FP languages may have, like monad, functor.
UPDATE: Oh, by the way your image comes from this talk
krstfk
I get what you’re saying and you’re not wrong per se, however, these are abstract patterns that one can use in Elixir, they’re not enforced at the type level, nor do we have syntactic sugar for some of them.
Sebb
for the boring real-world software I write I do not feel the need for monads and the other fancy stuff.
reduceandflat_mapand frieds take you a long way.And using lists like
[1,2,3] ++ [] ++ [4]is nearly a monad isn’t it?As for design patterns, the picture you posted is correct (Its from Scott Wlaschin, right? https://fsharpforfunandprofit.com/). But there are some helpful architectural patterns, like
krstfk
Oh don’t get me wrong, I didn’t mean you need them. They may be very useful if it’s your kink, but I wouldn’t dare say one should learn about them to write elixir code. I was just pointing out that the abstractions are usable in Elixir, even without typeclasses and friends, because they are just abstractions.
But yeah, far better to learn OTP concepts, and indeed basics of reduce and friends ans recursive functions, than wasting time on abstract algebra (unless it’s your kink).
Exadra37
This video course really resonates with how like to organize my code in OOP and that I ported to functional Elixir.
My repo from following the course:
https://github.com/Exadra37/elixir-for-programmers-2_learning
So, for design patterns I like to use one that groups things by action performed on a resource, be it in OOP or Functional.
In OOP I was using the Resource Action Pattern, that lends well to functional Elixir, but requiring some adaptations to use distributed Elixir and Elixir processes, that I will borrow from the video course above:
So, @pragdave encourages us to separate the implementation from runtime considerations (OTP), and that was the missing bit in my Resource Action Pattern port to Elixir.
The Resource Action Pattern requires that the code for each resource to be split to his own file by action. For example, if you have the
Productresource, then you will havelib/impl/products/add/product_add.ex,lib/impl/products/modify/product_modify.ex, etc. .This approach as worked very well for me along the OOP years. At a glance I can see which resources a project has, and which actions are performed on them just by opening a folder. No need for reading docs, and it makes easier to onboard new devs to the project.
dorgan
Friendly reminder that while Elixir is considered a functional language, the lack of auto currying makes the majority of functional programming patterns very cumbersome to use and functional composition(h = g ∘ f) is very rare in idiomatic elixir code, and thinking of elixir as a functional language like the others sets the wrong expectations. Sure, they’re good as inspirations, but I don’t find much value in them in Elixir other than having the vocabulary to understand why flat_map is called flat_map.
I find the philosophy of Clojure, ie the idea of data > functions, and thinking of data transformations rather than function compositions, is more helpful(see Ecto’s Changesets, Plug’s Conn, Ecto’s Multi and so on for inspiration). I unfortunately don’t have a list of resources right now, I’d like to compile some at some point or write down my opinions sometime, but I just wanted to point that out
Mraiih
Thanks everybody for your replies
I just finished the video, didn’t understood everything but I keep some keywords and concepts for the future!
Thanks for the link, it took me time to understand the relation between Application, Supervisor, GenServer, and other stuff, I bought Programmer Passport: OTP for that, didn’t finished yet but at least I have some basic to understand what people are talking about.
From what I understand from this conversation is “functional principle” aren’t that important in Elixir and I should focus on OTP then application architecture since all functionals concepts arent “compatible” (sorry for the wording) with Elixir.
Thanks everybody for the conversation and links, I kept some keywords for more research!
al2o3cr
I understand the sense that the image is trying to convey, but I don’t think it’s particularly fair: the left-hand side are concepts and the right-hand side are implementations.
If the left-hand side was also implementations, it would just be “objects, objects, objects, yep objects again, objects etc”.
If the right-hand side was also concepts, it would have lots of things (some of which have already been mentioned) - monads, pattern-matching, etc.
Some of the right-hand side wouldn’t even be different - for instance, it seems totally reasonable to call this an example of the strategy pattern, where
Enum.sortaccepts a module that defines acompare/2:zookzook
Once you understand what a monad is, you can’t explain it.
rvirding
That’s why there are such a enormous number of decriptions of monads