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 so ware domain. From elixir-lang.org
programming language created at Ericsson in the mid 80'ies as a new language for programming phone switches Designed by Joe Armstrong, Robert Virding, and Mike Williams
(a) -> a * 2 end two_times_two = times_two.(2) # But there is also a shorthand notation using the & times_three = &(&1 * 3) three_times_three = times_three.(3)
fields defmodule Book do defstruct title: "", author: "" end # Create a book iex>the_trial = %Book{title: "The Trial", author: "Franz Kafka"} %Book{author: "Franz Kafka", title: "The Trial"} # Access fields iex>the_trial.title The Trial # In fact structs are just maps with a special property __struct__ iex>the_trial.__struct__ Book
equals sign in Erlang to that used in algebra. When you write the equation x = a + 1, you are not assigning the value of a + 1 to x. Instead you’re simply asserting that the expressions x and a + 1 have the same value. If you know the value of x, you can work out the value of a, and vice versa.” from "Programming Elixir 1.3"
of F# defmodule Humanize do def join(list) do case list do [] -> "" [head | []] -> head [head | [tail | [] ]] -> head <> " and " <> tail [head | tail] -> head <> " , " <> join(tail) end end end
features that is stolen from another language (F#) The pipeline operator pipes the result of one function onto the first parameter od the next function in the pipeline (2..11) |> Enum.map(&(Integer.to_string(&1))) |> Enum.map(&(&1 <> " cases of beer")) |> Enum.map(&(IO.puts &1))
unlike OS processes Processes are isolated from each other Communicates with other processes through messages Start new process with spawn Can be linked to process by link or spawn_link
(current: "mix run") mix app.start # Starts all registered apps mix app.tree # Prints the application tree mix archive # Lists installed archives mix archive.build # Archives this project into a .ez file mix archive.install # Installs an archive locally mix archive.uninstall # Uninstalls archives mix clean # Deletes generated application files mix cmd # Executes the given command mix compile # Compiles source files mixie deps # Lists dependencies and their status ... mix run # Runs the given file or expression mix test # Runs a project's tests iex -S mix # Starts IEx and runs the default task