From me, it’s to learn about the equals sign = first. It isn’t the assignment operator as you might expect!
It can do assignment, but it can do a lot more too! Think of it more like the equals sign you learned about in your maths lessons - where the formula on both sides actually match by ending up being equal, for example, a = b + 3 if you know the value of a you can work out the value of b, and if you know the value of b you can work out the value of a. This allows you to do stuff with the values when they do, or don’t, match.
Programming Elixir has a really good section on this
For me, this has huge ramifications for concurrency. No need for slapping on a mutex or critical section, etc. If you’re dealing with a resource that would require locking, then very likely you should have a process that governs that resource. The BEAM can do millions of processes, but each one will execute in a single thread. Amazingly elegant.
New to Elixir and programming:
Use double-quotes " for strings.
Single-quoted char lists are for interfacing with Erlang libs.
OTP, Supervisors, Genservers etc. are great… but you don’t NEED to be fluent in them to write your first production application. If you write a Phoenix application, for instance, basic supervisors are already taken care of for you.
(I feel like a lot of talks focus on these topics, and they are great and interesting and mind expanding but can be intimidating to newcomers especially)
Read info/tutorials/docs and other linked sources available in official site.
Search at this forum for categories and threads that you are interested in. Be sure to check also our wiki tag.
If you don’t understand something then don’t feel stressed to ask here, you are welcome .
Universal tip: Try always plan your free time
Read other projects
Start from something simple, don’t try to modify elixir source, but if you have idea then feel free to write in this thread.
Use forum or other communication sites for developers before creating issue(s).
If you find a bug then be sure to check it twice and create an issue with good description (list to reproduce your problem).
Read forum every day - we are creating lots of interesting threads!
Use tools to easily manage your code. I suggest you Atom editor and it’s packages (also for Elixir). Credo which style guide I already mentioned is also really helpful.
Help yourself, help others, ask and answer questions - live and forgot about brutal world (at least to midnight ).
The FIrst Immediate thing is stop using the functions out put like this final(Math.round(getValue(x)))
That Looks Really Weird to read and understand what is happening here
getValue
|> Math.round
|> final
Did you see how the beautiful the code looks
Start using the Pipe |> operator, this where the Elixir differ and stand unique besides the light weight Process Mechanism.
For me, it was to remember to use pattern matching! At first, I was using lots of if/else clauses and equality tests, because that was what I was used to. Many programmers will come from languages without pattern matching (or at least with much less powerful pattern matching).
e.g. I like this example from an Exercism solution:
@doc """
Return the kind of triangle of a triangle with 'a', 'b' and 'c' as lengths.
"""
@spec kind(number, number, number) :: { :ok, kind } | { :error, String.t }
def kind(a, b, c) do
case Enum.sort([a, b, c]) do
[x, _, _] when x <= 0 -> { :error, "all side lengths must be positive" }
[x, y, z] when x + y <= z -> { :error, "side lengths violate triangle inequality" }
[x, _, x] -> {:ok, :equilateral}
[x, x, _] -> {:ok, :isosceles}
[_, x, x] -> {:ok, :isosceles}
_ -> {:ok, :scalene}
end
end