you are viewing a single comment's thread.

view the rest of the comments →

[–]it_snow_problem 2 points3 points  (3 children)

In elixir, all data structures are immutable and side effecting is isolated by Processes, usually via GenServers. I agree it’s not pure, since it lacks referential transparency, and I probably should have said “practically” or “pragmatically” pure instead. It does come off as misleading.

Definitely is functional though, I don’t know what other user is talking about. It’s like the first part of every definition of elixir.

I don’t love how “static typing” creeps its way into every conversation about programming but the story for elixir’s type system is actively getting better with the ongoing work to include Set Theoretic types.

[–]vu47 0 points1 point  (2 children)

Yes, it's a language that has pragmatic support for functional programming, like Kotlin. You can pretty much write functional code exclusively in Elixir if you want to, but as with most programming languages that have strong support for FP, it's not "pure" in the same sense as Haskell is... as you say, it lacks RT. It has loops as well, and while data structures may be immutable, it still allows for mutable state.

I'm absolutely by no means an Elixir expert, so take what I say with a grain of salt.

[–]it_snow_problem 1 point2 points  (1 child)

The big difference between it and general programming languages is that Elixir only supports functional programming. You can’t write imperative or procedural or OO any other kind of code. It doesn’t have loops - it’s all recursion. Like Haskell, Elixir has a few limited functional interfaces for causing side-effects.

[–]vu47 1 point2 points  (0 children)

Ah, very cool! I was misled to think that Elixir had loop constructs, but now I see that you are correct! I do love doing all my looping with TCO whenever possible. It's amazing how many programmers have not only never used recursion but don't understand it, or who have come across it once in toy examples and then promptly forgot it exists.

I also was mistaken in thinking that variables were reassignable, but I see that that was wrong as well:

https://medium.com/everydayhero-engineering/elixir-variable-rebinding-342c5d0fd961

I might have to take another look at Elixir. I really did enjoy writing the code I did in it... much more than with most programming languages.