How has Elixir blown (or expanded!) your mind? Please tell us here!
Can be something that’s unique to Elixir, or just something that it introduced to you. Can be something you discovered a while ago… or something you just come across - whatever it is, please share
Well it was mind blowing enough when I first came across recursive functions, but I’m just reading Learn Functional Programming with Elixir (Pragprog) and I’ve just met a recursive function …inside a recursive function
This might be a little bit tangential. Finding this in the OTP source really blew my mind. Make me realise even the most impressive software is made by normal people
Things that I had heard of but I was scared to try. Recursive functions. Enum.reduce and Enum.map functions. I have seen those in javascript but I was avoiding them over for loops.
This talk by Saša Juric is one of my go-to’s when trying to get people interested in Elixir. Being able to attach a REPL to a running production system and having all of these introspection capabilities at your disposal is something I don’t think any other runtime offers (or if they do it likely isn’t as deeply integrated with the runtime as you get with elixir/erlang).
which is a bit easier to understand (at least for me, since I can’t think of a function which would handle both an empty list and a list with a single element in it the same way), and probably slightly faster.
Haha new to the forum so I’m not used to where everything is and I definitely thought your username was the opening to your comment for a second or two
Not just Elixir, but because of it I would say the runtime and otp, to think that a bunch of tech were already there and nobody saw it is at least intriguing and now I barely need a bunch of infrastructure libraries, proccess is there, cache is there, kv storage is there even a database, and nodes without all of the complexity.
otp(supervisor trees/ genservers) is what blew my mind about the language. Completely changed how I wrote my code. Much stuff I was using other services for like Redis or sqs I do all in code now and its great!
Definitely pattern matching. It truly changed the way I think about code and it’s the kne thing I wish I had in every other programming language going forward.
Second to that railway oriented programming with the with expression
It’s interesting that pattern matching in Elixir is such a primitive notion (just like in erlang, of course). Actually, Elixir could have implemented pattern matching with macros. I have implemented a special form of “pattern matching” myself in my megadef library. It shows how easy it would have been to implement other forms of pattern matching inside elixir
EDIT: There are very good reasons not to do what I’ve done in my package by default, of course. It’s good for some situatuons but a disaster in others.
In terms of syntax, nothing in Elixir really blows my mind, no… seriously, everything is expected. Just functions and more functions and pipe of functions and more functions, some with syntax, some comprehensions, yeah nothing really fancy. No pointers, no instance variable (that can be changed on other methods/functions). Just modules of pure functions. Protocol and behaviour are a bit harder to think about though.
Phoenix is a bit more surprising, because it has some itty bitty magic on the MVC thing. Other than that, nothing really surprises me.
It is pretty different when I code in Javascript, like everyday, something surprises me out of nowhere.
“How does it work like that?”
In terms of performance and especially concurrency, Elixir really blows my mind.