ryanwold.net

A civic-minded citizen seeking the singularity

Back to Entries

Up and Running with Elixir

release
Date: 2017-01-17
Tags: elixir programming experience-report

I've heard good things about Elixir and its web framework, Phoenix.

Getting Started

I'm using MacOSX, so I had to do a few things to get started:

  • run brew install elixir to install Elixir, which also installs Erlang git clone the phoenix repo. now you have a /phoenix directory within their, install dependencies create a new Phoenix app called splurty cd into /phoenix/splurty, and run mix phoenix.server, which starts a web server on port 4000

I'm running Elixir 1.8.1.

Terminology

Elixir, like most languages, has distinct names to represent common programming language concepts. This Terminology section is to track and define these concepts like a glossary.

  • module - is like a class in Ruby
  • application -
  • OTP framework -
  • processes
  • Phoenix framework - provides an HTML frontend
Other words
  • concurrent programming
  • functional language
  • application state

Commands

  • run mix local.hex to install hex, which is a package repository, like Ruby .gems or Python eggs. More can be found at https://hex.pm
  • run iex to start an elixir interpreter. This is like Ruby's irb
  • press ctrl + c twice to exit iex
  • type h to see Help
  • try h IO.inspect or any method name instead of inspect to see a function's documentation
  • use v 1 or v 2 or v etc to reference a certain iex value
  • use iex:break if you need to get back to a clean iex prompt
  • mix new codinggnome to create an application called codinggnome in /codinggnome - source code will live in /codinggnome/lib
  • type mix to compile the app's code
  • elixir -h and iex -h to show help
  • iex -S mix - run iex with mix - within the session, type r Module to reload a module, or c lib/module_name.ex to recompile the modulef

Examples

  • irb

2* 12 24

  • type String. then press tab to see a list of functions for the String module

``` File.read("words.txt")

returns

{ :ok, :binary } - a binary "string-like" object (but not a string) ```

By Ryan Wold · © 2017–2026 Ryan Wold

Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.

Enjoyed this? — any BSV wallet, HandCash, or plain old dollars.

Leave a tip

Tips go directly to a Bitcoin SV address I control — peer to peer, no platform in between. A few thousand satoshis is a fraction of a cent; it's the gesture that counts.

From any BSV wallet

Scan the QR code with your wallet's camera, or copy the address.

177DwUfSTW8RkFBJzYYcgr1YB8ngbhTYAc

With HandCash or any paymail wallet

Paymail is an email-style address for Bitcoin wallets. Send any amount to afomi@handcash.io

First time using Bitcoin? Yours Wallet is an open-source browser extension wallet, and HandCash is an easy mobile wallet — either takes a minute to set up.

Prefer regular money? Support via OpenCollective.