mkellyxp
Im an “old school” PHP developer working in the traditional LAMP stack for years now. I’m ready for something new and have projects that need to scale. So naturally I’ve landed here.
I’ve purchased some elixir / Phoenix books and have the boot camp course on Udemy and about to really dive in.
But I have to admit, my brain is having a really hard time with the syntax! The functional programming part is fine grasping. But all the bizzare symbols everywhere just totally looses me. I don’t find it readable at all.
I know most of this is because it’s new, but even so, it looks so cryptic. Any tips on getting comfortable or understanding these basics. Sure I can copy and paste from a book or course, but I really want to understand what on earth I’m looking at.
I’ve heard amazing things about this community and excited to be here!
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
axelson
Welcome to Elixir and the forum
!
Hmm, since the books seem like they aren’t working to well for you right now I’d recommend some more practical practice. I really like Exercism for that Elixir on Exercism because they’re nice little self-contained projects so they will help to get you familiar with reading and writing some elixir code.
If you haven’t already done it I would also recommend the official Getting Started guide: https://elixir-lang.org/getting-started/introduction.html
trarbr
I would also recommend the Getting Started guide. I also struggled with the syntax in the beginning, and I learned it by going through that guide. You should not just read it though - if you force yourself to type it all into IEx / .exs-files, your brain will eventually grok it.
When you’re done with the Getting Started guide I suggest also going through the Mix and OTP guide, just to get some experience with Mix.
mindok
A lot of developers learn most efficiently by doing, preferably with something useful at the end of doing, so if you have a small personal project to work on that can be a great platform for learning.
Feel free to ask questions on here. I think it’s fair to say that there’s a high proportion of enthusiasts who love the language, libraries and runtime after earning too many grey hairs from other platforms, and are more than happy to help beginners get going providing they are making some effort to self-learn along the way.
In terms of weird symbols etc, here are a couple of pointers to things that I found to be very different in the early days:
|>- pipe the output of one function into another as the first argument - pretty much like unix-style command line pipes.:an_atom- this got me at first becomes I didn’t come from the school of Ruby - it’s basically a constant, but there are a few little tricks - you can google these. Here’s a starting point: https://stackoverflow.com/questions/32261500/why-is-useful-to-have-a-atom-type-like-in-elixir-erlang~s(something or other)- a sigil - basically the contents within the brackets are processed in a special way depending on which sigil is used. Well documented in the language guide: https://elixir-lang.org/getting-started/sigils.html<-and->are just part of syntax incase&for- you’re just going to have to practise with thoseThere’s some really tight syntax for in-line defined functions can be super-confusing at first. For example (from https://elixir-lang.org/getting-started/enumerables-and-streams.html):
This means, for each value between 1 and 100,000, multiple by 3.
The
..between 1 and 100_000 indicate the generation of a range. That range is passed in toEnum.mapas the first argument by the|>, and an in-line function is passed in as the second argument.&(&1 * 3)is the in-line function defined in place rather than being defined elsewhere and referenced. The&at the beginning indicates the start of the function definition and the&1indicates the first (and only) variable passed into the function. There’s a little bit of discussion of this syntax here: https://elixir-lang.org/getting-started/modules-and-functions.html#function-capturingWhile it seems overly terse at first, it turns out to be really useful as a way to define a simple transformation to apply to a list of data.
Finally, the whole pattern-matching thing is confusing if you haven’t come across it before. I tried to understand it by reading about it, but in the end I got my head around it by playing in the interactive shell. It’s like a combination of equality-checking and assignment depending on what elements of a match expression are able to be assigned to. Once you do grok it, pattern-matching is one of the language features that makes Elixir super-readable.
Again, feel free to ask about specific things…
hauleth
Funny thing to hear from PHP developer.
mindok
But you have to admit
1..10 |> Enum.map(&(&1 + 2))is a bit special when you first see it.derek-zhou
You don’t have to use all of them. Find a subset that you are comfortable with, and stick with it for a while. I’ve been writing elixir for a year and I still steer clear from
withor list comprehension.Exadra37
I also come from PHP, and the only thing that clicked to me was this book:
or if you prefer the equivalent video course:
The hardest thing for me is to always understand what is compiled time, boot-time, and runtime, especially when it comes to configuration and to some macros and functions that are only called at compile time, and for us coming form languages like PHP keeps biting us over and over, but I am more aware now… with time you get better at spotting them
Another thing that is hard to grasp is the Dyalizer type specs, and this may be the symbols that you are complaining about, because they also puzzled me in the begin, but nowadays I learned to “ignore” them, and I just use the Domo library that hides their complexity from being everywhere in my code.
mkellyxp
Thanks so much! I actually just discovered Exercism and joined the Elixir and Rust tracks, and will likely be a PHP mentor there as well! So this is a great tip.
To be fair, I wouldn’t say the books aren’t workign.. i’m positive I can get things working by following the books. It was more wishing there was some kind of cheat sheet for the syntax. But perhaps i’m putting the cart before the horse here. I got a Phoenix / Elixir book. Maybe I need to dive into elixir itself first
mkellyxp
I was going through some basic Phoenix examples last night and saw this:
Most of that isn’t words at all. What on earth is \ and %{}? Thats the stuff i’m talking about. A similar function in my php app is:
Short of the $ symbol.. it’s all humanly readable. Trust me, i’m not saying PHP is better.. but I do feel like it’s less cryptic, even if that means it’s less functional.
mkellyxp
Thanks! I actually had a demo of this book, but then picked up the Pragmatic Programmers Programming Phoenix > 1.4 book. And i’m starting to see that, this is the issue. I might have to spend some more time in elixir itself before diving into phoenix, plugs and web routing.
Thanks for the reminder about this book!