A question about the composability of Elixir

Hello everyone!

I have a non-FP programming background (C++, Swift, Javascript) and started to learn Elixir/Phoenix a while ago. As I prefer to play with the technology while learning it, I built my first Flutter app (a messenger app) that uses Phoenix channels, and it even made its way to the App Store! So far, I love the developer experience I had with Elixir/Phoenix, and there were a few occasions the FP nature of Elixir helped me write some of my programming logic elegantly.

However, I’m still far from being comfortable and confident with my FP and Elixir language skills. Although I’ve managed to write what I need so far, I still have the doubt that, at some point, I will run into an occasion where I cannot compose certain business logic that I would have managed to do with an imperative style programming language.

This is where I need the opinion of those who are well versed in the Elixir language. Do you think Elixir lacks the composability certain other languages like Javascript/C++ may have? Or do you think the same business logic written in Elixir will end up having more lines of code/functions?

Sorry for the noob question and your time spent on writing answers is much appreciated!

Number of lines of code is pretty dumb metric there. It is not number of lines that is important but how easy it is to debug, maintain, and evolve of the codebase. You can write Game of Life in APL like that:

      life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}

Do you even know where start to read that?

So as you can see, LOC is quite dumb metric there.


But does Elixir will have the meaningful metrics on the more positive side? IMHO yes, but from the place where I write it, you may reduce, that I am pretty biased there.

2 Likes

I think a really eye opening book was Designing Elixir Systems with OTP: Write Highly Scalable, Self-Healing Software with Layers by James Edward Gray, II and Bruce A. Tate. Coming from OO Development, it helped show me the power of separating out data and functions to build composability between modules.

It might have more lines of code in the end, but the benefit is everything has a place to grow and become more nuanced.

May I ask what you mean exactly by “composability” ?