Elixir Language

Topics related to Elixir Language:

Getting started with Elixir Language

Elixir is a dynamic, functional language designed for building scalable and maintainable applications.

Elixir leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain.

Operators

Lists

IEx Console Tips & Tricks

Pattern matching

Data Structures

As for which data structure to us here are some brief remarks.

If you need an array data structure if you're going to be doing a lot of writing use lists. If instead you are going to be doing a lot of read you should use tuples.

As for maps they are just simply how you do key value stores.

Built-in types

Nodes

Conditionals

Note that the do...end syntax is syntactic sugar for regular keyword lists, so you can actually do this:

unless false, do: IO.puts("Condition is false")
# Outputs "Condition is false"

# With an `else`:
if false, do: IO.puts("Condition is true"), else: IO.puts("Condition is false")
# Outputs "Condition is false"

Sigils

Functions

Stream

Streams are composable, lazy enumerables.

Due to their laziness, streams are useful when working with large (or even infinite) collections. When chaining many operations with Enum, intermediate lists are created, while Stream creates a recipe of computations that are executed at a later moment.

Strings

A String in Elixir is a UTF-8 encoded binary.

Maps and Keyword Lists

Elixir provides two associative data structures: maps and keyword lists.

Maps are the Elixir key-value (also called dictionary or hash in other languages) type.

Keyword lists are tuples of key/value that associate a value to a certain key. They are generally used as options for a function call.

Doctests

Erlang

Debugging Tips

Modules

Module Names

In Elixir, module names such as IO or String are just atoms under the hood and are converted to the form :"Elixir.ModuleName" at compile time.

iex(1)> is_atom(IO)
true
iex(2)> IO == :"Elixir.IO"
true

Processes

Protocols

A note on structs

Instead of sharing protocol implementation with maps, structs require their own protocol implementation.

Behaviours

ExDoc

ExUnit

Mix

BEAM

Metaprogramming

Installation

Optimization

basic use of guard clauses

Basic .gitignore for elixir program

Ecto

Basic .gitignore for elixir program

Note that the /rel folder may not be needed in your .gitignore file. This is generated if you are using a release management tool such as exrm

State Handling in Elixir

Constants

So this is a summary analysis I've done based on the methods listed at How do you define constants in Elixir modules?. I'm posting it for a couple reasons:

  • Most Elixir documentation is quite thorough, but I found this key architectural decision lacking guidance - so I would have requested it as a topic.
  • I wanted to get a little visibility and comments from others about the topic.
  • I also wanted to test out the new SO Documentation workflow. ;)

I've also uploaded the entire code to the GitHub repo elixir-constants-concept.

Task

Better debugging with IO.inspect and labels

Only works with Elixir 1.4+, but I can't tag that yet.

Join Strings

Polymorphism in Elixir

Functional programming in Elixir

Tips and Tricks

Getting help in IEx console