r/functionalprogramming • • Aug 03 '24

Question What's the benefit of learning Elixir?

I'm currently learning Haskell (and F#), but I also look around to other languages.

One language that is often mentioned is Elixir. Do I have any benefit if I learn Elixir? It is dynamically typed, but I think strong static typing is a better choice to write more robust software. But maybe I'm wrong at this point and someone can clarify that for me.

47 Upvotes

45 comments sorted by

View all comments

Show parent comment

4

u/Voxelman Aug 03 '24

I have some experience with C and Python and also F# and Rust. I constantly shoot myself in the foot, both in Python and C and since I replaced them with F# and Rust my foot is safe again.

I want to know how much better Elixir is compared to Python's duck typing?

I don't want to ignore the benefits of BEAM, but I think Gleam would be the better BEAM language for me, but it is less mature than Elixir and lacks documentation.

6

u/a3th3rus Aug 03 '24 edited Aug 03 '24

In my opinion, Python's (and Ruby's) problem comes from OOP, not from duck typing. Why do I say so? Because Python's duck typing focuses on what an object can do instead of what data an object carries. That's exactly the opposite of Elixir's duck typing.

In Elixir, data is just data. They can do nothing by themselves. To do something, you need to call functions, and functions are separate from data.

6

u/jasonpbecker Aug 03 '24

I would confidently answer this the same way as the post you’re replying to— you’ve developed a very strong opinion here without having actually tried something with different trade offs. A ton of the benefits you get from static typing you may find matter less or can be achieved other ways. Use Elixir with dialyzer and typespecs, learn idiomatic ways of using pattern matching and guards, and see where that takes you.

Writing Elixir is nothing like Python or C.

You keep repeating the same strongly held opinion about typing based on Python and C. I don’t really think you have the experience to hold such a strong opinion based on how you’re wiring it. And you’ll only learn the differences by building a meaningful project and trying it.

0

u/[deleted] Aug 17 '24

[removed] — view removed comment

2

u/jasonpbecker Aug 17 '24

I’m all for the effort going into gradual typing and look forward to seeing how far they can take it and what benefits it will bring.

There are a lot of people who don’t write Elixir who will tell you it’s non-viable because it’s dynamic. I’m saying being that dogmatic, especially coming from someone without a ton of experience (based on comparisons that aren’t really meaningful), can steer you wrong.

Sometimes things you think will matter a lot end up not. Sometimes things you don’t even think about or know about become deal breakers. I think it’s worth using something before having a strong opinion, and I think the OP comparing to C or Python suggests that static v dynamic is not the most important axis of comparison to know if Elixir will work for their problem space and how it’ll fit into their preferences.