typestar

Language basics

27 steps in 9 sets of Elixir.

Elixir is a functional language that compiles to the Erlang virtual machine, which has been keeping telephone switches and message brokers alive since the 1980s. Jose Valim gave that machine a modern face in 2012: Ruby-flavored syntax, first-class tooling, and macros, on top of immutable data, pattern matching everywhere, and processes so cheap you spawn one per job without thinking.

This tour covers the language core: modules and function clauses, the match operator and its pin, lists, tuples, maps and structs, the pipe and capture operators that give Elixir code its shape, strings and sigils, the with chains that tame ok-and-error plumbing, and finally real processes — spawn, Task, and Agent. The encore ships complete programs. Every seed runs warning-free under elixir.

Start this tour

Modules & functions

  • Modules and defThe smallest Elixir program: a module of named functions and two calls at the top level.
  • One-liners and defpTwo function shapes: the one-line do: body and the private helper only its module can call.
  • Module attributesCompile-time constants for a radio-delay calculator, declared once with @ and read anywhere.

Pattern matching

  • The match operatorThree matches: destructuring a tuple, splitting a list, and pinning a bound value.
  • Function clausesA launch countdown written as clauses: patterns and a guard pick the line, recursion drives the loop.
  • case and guardsOne case expression sorts sensor readings into three outcomes by shape and size.

Lists & tuples

  • Lists and consBuilding a shipping route by prepending, splicing, and walking head and tail.
  • Tuples and :ok pairsThe {:ok, value} and {:error, reason} convention, spoken here by a stubborn vault.
  • RangesTwo endpoints and a step stand in for a whole list of numbers.

Maps & structs

  • MapsOne exoplanet record read four ways: dot, brackets, Map.get, and a pattern.
  • Updating mapsImmutable updates: every change to the score hands back a new map and leaves the original alone.
  • Structsdefstruct gives the kayak shop a fixed shape with defaults and checked keys.

Enum & pipes

  • Anonymous functionsfn builds function values: a tip calculator, a twice-applier, and one passed to Enum.map.
  • The capture operatorThree spellings of the & shorthand, from named-function capture to inline fragments.
  • The pipe operatorA honey harvest flows through map, filter, sum, and round without a nested call in sight.

Strings & sigils

  • String interpolationBakery arithmetic dropped straight into strings with #{} and <>.
  • The String moduleSix transformations of a workshop motto, one String function at a time.
  • SigilsThree sigils: ~w for word lists, ~s for quote-heavy strings, ~D for real calendar dates.

Control flow

  • if and condBoth conditionals return values: if for two branches, cond for a ladder of tests.
  • with chainsA launch checklist: with walks the happy path of ok tuples and else catches the first miss.
  • for comprehensionsTwo comprehensions: a hand of cards from two generators, a map from a filter and into:.

Processes

  • spawn and receiveOne worker process, one message home: the mailbox model in thirteen lines.
  • Task.asyncThree reef surveys run in parallel processes and finish in the time of one.
  • AgentsA note jar kept by an Agent: state lives in a process, not in a variable.

Encore

  • word_freq.exsA word-frequency table built by one pipeline: downcase, split, count, rank, chart.
  • grade_report.exsQuiz scores fold into averages and letter grades, then into a formatted class report.
  • temp_stats.exsA week of daily highs reduced to low, high and mean, with a scaled bar per day.

The other Elixir tours