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 calledsplurty
cd into/phoenix/splurty
, and runmix 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 installhex
, 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'sirb
- press
ctrl + c
twice to exitiex
- type
h
to see Help - try
h IO.inspect
or any method name instead ofinspect
to see a function's documentation - use
v 1
orv 2
orv etc
to reference a certainiex
value - use
iex:break
if you need to get back to a cleaniex
prompt mix new codinggnome
to create an application calledcodinggnome
in/codinggnome
- source code will live in/codinggnome/lib
- type
mix
to compile the app's code elixir -h
andiex -h
to show helpiex -S mix
- runiex
withmix
- within the session, typer Module
to reload a module, orc lib/module_name.ex
to recompile the modulef
Examples
irb
2* 12
24
- type
String.
then presstab
to see a list of functions for theString
module
``` File.read("words.txt")
returns
{ :ok, :binary } - a binary "string-like" object (but not a string) ```