Any tips on coming from PHP?


HAHAHAHAHAH… And just like that, I became an Elixir dev…


welcome home :wink:

1 Like


1 Like

Having a console is a game changer, and having the observer is just awesome :slight_smile:

That’s why I find it complicate to use languages without console (like Rust).


Same here. But I found that this forced me to write much more – and more detailed – tests. Which turned out surprisingly good.


Yes, that’s a common experience when delving into a different programming language. But, I can only say, give it some time before concluding that the syntax is “objectively” unreadable. Usually, what you are seeing is familiarity bias.

Long ago, I remember seeing LISP and thinking that “this cannot possibly be readable by a human”. As soon as I got familiar with it though, I just started to LOVE its simple syntax. What was an unreadable cluster of symbols was then a clearly readable computation.

Same with JavaScript arrow functions: I just love them nowadays, but I used to think that it was much harder for the eyes to parse than the old school function keyword. Or Python’s semantic indentation: I found it hard to digest, until I got used to it.

In each of those cases I tought that my preference was objective, but it really turned out to be just familiarity. I learned that syntax preferences are mostly a matter of getting used to.

So, my suggestion, is to temporarily suspend the judgement on syntax, and just spend time reading and writing code on something that you enjoy. You might be surprised by how your taste could change quite quickly, as your brain gets used to the different syntax :slight_smile:


Good advice… thank you. I’ve already closed the phoenix book and purchased and reading the Programming in Elixir 1.6 book. I’ll spend some time getting to know Elixir properly and write more code to get used to it. It’s already easing up a little. Was just quite shocking at first.

I’m also realizing, in my 20+ years as a developer, this is the biggest change/shift I’ve embarked on… so I should expect some WTF. But it’s also what’s exciting about it.

Really appreciating the supportive community here and the potential for this new to me language


If you want to to learn Elixir (without Phoenix) which seems a good idea to me: you might want to try

I do it every year and it’s a perfect & really fun way to improve your Elixir. You’ll find a lot of adventofcode discussions on this very forum (one per challenge), and by reading other’s code you’ll want to revisit your own solution :slight_smile:

(I also wrote a blog post about it)

1 Like

So the biggest tip that I can give you is on all of the different symbols because I came from a PHP background as well.

One thing I missed from PHP everywhere that I went afterwards was the that super data structure for associative arrays / hash maps which can have keys or not, maintains order, etc. You’ll miss that in most other languages, including Elixir. I’ll explain why in a second.

The other thing that goes along with that is the lack of operator overloading in Erlang/Elixir, so you can’t just combine two arrays with a + sign.

Now, the flip side of that is that while Elixir isn’t statically typed, it is strongly typed. If the compiler sees a + b it knows that both a and b must be numbers and can do a lot of inferred checking from that without you ever having to actually define them as numbers. Same with using different symbols for combining strings, etc.

It frustrated me a lot at first until I saw a talk on Dialyzer at Elixir Conf in Orlando that made it all click and helped me to realize all the benefits that come from the approach.

I wrote a bit about it here. Understanding Elixir Types

Here’s the talk that helped me so much. ElixirConf 2016 - Dialyzer: Optimistic Type Checking for Erlang and Elixir by Jason Voegele - YouTube


That’s true, but Elixir also doesn’t have arrays :slight_smile:

The closest you can see is that Elixir provides the ++ and – to manipulate lists:

iex> [1, 2, 3] ++ [4, 5, 6]
[1, 2, 3, 4, 5, 6]
iex> [1, 2, 3] -- [2]
[1, 3]

And also access them in the iex shell, even if offline, and the iex shell docs are exactly the same provided


Screenshot from 2021-03-31 20-44-14


Definitely true. Just trying to explain it from a PHP perspective.

1 Like

And as of recently, erlang docs as well.

1 Like

I started using Elixir full time in 2018, coming from a JS and PHP background. I got a job working with Elixir and Phoenix full time. The first month was really hard, I felt like my head was going to explode from all the new concepts I had to take in at once.

One mistake that I kept making was forgetting to re-assign to variables, for example writing:

conn |> put_flash(:info, "You must log in to access the page")
# and more code after this

Which should have been

conn = conn |> put_flash(:info, "You must log in to access the page")

… because a variable is never modified in place, it needs to be reassigned explicitly. And there are no methods on data, it’s just data.

I love Elixir today, and after learning all the syntactic sugar and main concepts, it’s a joy to work with. Like the comments mention above, I think it’s really important working your way into it. It takes effort and some months to get good at it. I would recommend doing some projects in it, or completing some Advent of Code tasks. And if you can, get feed back and read other people’s code.

Some of my favourite features:

  • Pattern matching :heart:. Once you get that, you’ll miss it everywhere else.
  • Great tooling out of the box
  • Immutability :heart:
  • That everything is modules and functions. It’s a simple concept.

@brightball do you want to take your video notes on the video and share them with us?

Screenshot from 2021-03-31 21-39-50

That’s basically what the blog post is. It’s a good overview of dialyzer and how it works. The thing that most stuck out to me was being able to use different symbols for specific types of primitive data types rather than overloading plus for multiple data types. Just helped me to see the purpose behind it.


On macOS there is even more awesome thing - Dash which is offline documentation browser with support for Erlang, Elixir, and Hex. So you can locally install documentation for packages that you use and easily search them all at once (so you do not need to remember whether given function is part of ecto or ecto_sql, you can search them both at the same time).


You also have it in Linux, I installed it once, several years ago, but didn’t like it.

Maybe I need to give it another try :slight_smile:

I love dash so much! :heart:

There is also a vscode extension that allow to select any text and open its documentation in Dash with cmd - H shortcut

1 Like