pillaiindu

pillaiindu

I know some Elixir and now I’m learning Phoenix, but I want to learn more Elixir, so that for example if I encounter the Ecto.cast somewhere I don’t come to the forum to ask others how this piece of code works but instead I go to changeset.ex:L418 and read the code myself, and know what this function does, how this function is written, how it’s @spec is defined, how a macro somewhere works, etc.

What books and/or tutorials/blogs/youtube-playlists are required to be used to become that fluent in Elixir?

(It’s better if some or all of those resources are free, as I’m a student and here in India one dollar equals to 64 rupees :slight_smile: )

Showing Posts 1 to 6

DevotionGeo

DevotionGeo

You’ll need to start with the official docs, then read some decent book(s) like Programming Elixir (1.3 / ≥1.6), Elixir in Action, Introducing Elixir, The little Elixir and OTP Guidebook etc and a lot of practice.

The above mentioned books won’t make you automagically a master of the language, but you’d need much more practice and time. If you’re already an experienced programmer in some other language, it may take less time to master your next language (which in your case is Elixir), but if you’re not already experienced in other language(s), it may take more time to master it.

The curiosity level you have is enough (which I assumed from your previous questions and replies), but you’d need to give the language more time (more hours everyday, and more months/years in long term).

And I’m sorry that none of the books I mentioned is free (as you asked in the question), some other answers may come with free resources.

grych

grych

Creator of Drab

You will need a practice. Find yourself a project which strongly relies on Phoenix or Ecto, and you will have to learn how to read their source :slight_smile:

pillaiindu

pillaiindu OP

Thank you @DevotionGeo, thank you @grych!

peerreynders

peerreynders

The Elixir documentation links directly to Erlang’s Dialyzer documentation - and as it happens one of the better Dialyzer introductions is found in Learn You Some Erlang - which of course uses Erlang.

So for a quick introduction to Erlang’s syntax go through (the beginning of) Chapter 2. Introducing Erlang included in the free sample of Designing for Scalability with Erlang/OTP: Implement Robust, Fault-Tolerant Systems.

pillaiindu

pillaiindu OP

Thank you @peerreynders, I’ll study the content you linked as soon as I get time! :slight_smile:

peerreynders

peerreynders

For a jumpstart to, for example, Typing Functions.

Create a new project

$ mix new cards
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/cards.ex
* creating test
* creating test/test_helper.exs
* creating test/cards_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd cards
    mix test

Run "mix help" for more commands.
$ cd cards
$ 

In mix.exs change:

defp deps do
  [
    {:dialyxir, "~> 0.5", only: [:dev], runtime: false}
  ]
end

and run

$ mix do deps.get, deps.compile
Running dependency resolution...
Dependency resolution completed:
  dialyxir 0.5.1
* Getting dialyxir (Hex package)
  Checking package (https://repo.hex.pm/tarballs/dialyxir-0.5.1.tar)
  Using locally cached package
==> dialyxir
Compiling 5 files (.ex)
Generated dialyxir app
$

then

$ mix dialyzer
Compiling 1 file (.ex)
Generated cards app
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
Finding suitable PLTs
Looking up modules in dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Looking up modules in dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Looking up modules in dialyxir_erlang-20.2.2.plt
Finding applications for dialyxir_erlang-20.2.2.plt
Finding modules for dialyxir_erlang-20.2.2.plt
Checking 163 modules in dialyxir_erlang-20.2.2.plt
Finding applications for dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Finding modules for dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Copying dialyxir_erlang-20.2.2.plt to dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Looking up modules in dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Checking 163 modules in dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Adding 228 modules to dialyxir_erlang-20.2.2_elixir-1.6.1.plt
Finding applications for dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Finding modules for dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Copying dialyxir_erlang-20.2.2_elixir-1.6.1.plt to dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Looking up modules in dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Checking 391 modules in dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Adding 58 modules to dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt
Starting Dialyzer
dialyzer args: [
  check_plt: false,
  init_plt: '/cards/_build/dev/dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt',
  files_rec: ['/cards/_build/dev/lib/cards/ebin'],
  warnings: [:unknown]
]
done in 0m0.87s
done (passed successfully)
$ 

Change the contents of cards/lib/cards.ex to

# cards/lib/cards.ex
defmodule Cards do
  @type suit() :: :spades | :clubs | :hearts | :diamonds
  @type value() :: 1..10 | :j | :q | :k
  @type card() :: {suit(), value()}

  @spec kind(card()) :: :face | :number
  def kind({_,a}) when a >= 1 and a <= 10,
    do: :number
  def kind(_),
    do: :face

  @spec main(list(binary())) :: :ok
  def main(_argv) do
    :number = kind({:spades, 7})
    :face = kind({:spades, :k})
    :number = kind({:rubies, 4}) # should be :diamonds, not :rubies
    :face = kind({:clubs, :q})
    :ok
  end
end

Now run:

$ iex -S mix
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Compiling 1 file (.ex)
Interactive Elixir (1.6.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Cards.main([])
:ok
iex(2)> 
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
a
$ mix dialyzer
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
PLT is up to date!
Starting Dialyzer
dialyzer args: [
  check_plt: false,
  init_plt: '/cards/_build/dev/dialyxir_erlang-20.2.2_elixir-1.6.1_deps-dev.plt',
  files_rec: ['/cards/_build/dev/lib/cards/ebin'],
  warnings: [:unknown]
]
done in 0m1.01s
lib/cards.ex:14: Function main/1 has no local return
lib/cards.ex:17: The call 'Elixir.Cards':kind({'rubies',4}) breaks the contract (card()) -> 'face' | 'number'
done (warnings were emitted)
$ 

See also Typespecs.

Alternately:

# lib/cards.ex
defmodule Cards do
  @type suit() :: :spades | :clubs | :hearts | :diamonds
  @type value() :: 1..10 | :j | :q | :k
  @type card() :: {suit(), value()}

  @spec kind(c) :: r when c: card(), r: :face | :number
  def kind({_,a}) when a >= 1 and a <= 10,
    do: :number
  def kind(_),
    do: :face

  @spec main(args) :: r when args: [binary()], r: :ok
  def main(_argv) do
    :number = kind({:spades, 7})
    :face = kind({:spades, :k})
    :number = kind({:rubies, 4}) # should be :diamonds not :rubies
    :face = kind({:clubs, :q})
    :ok
  end
end
— All posts loaded —

Where Next? Top

Trending in Discussions Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
jtormey
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

Other Trending Topics Top

KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews