for Boston's Elixir Women
Elixir - April 2016: Assess → November 2016: Trial
Phoenix - First Appearance → November 2016: Trial
Websocket Client Concurrency Performance
Web Framework Performance
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}Scala
module Main where
main = putStrLn "Hello, World!"Haskell
fn main() {
println!("Hello World!");
}Rust
(ns helloworld.core)
(defn -main []
"I can say 'Hello World'."
(println "Hello, World!"))Clojure
defmodule HelloWorld do
def hello do
IO.puts "Hello World"
end
endElixir
It's heavily inspired by Ruby.
# Create nodes
neuron = Neuron.start_node(bias: 10, activation_function: function(identity/1))
sensor = Sensor.start_node(sync_function: fake_sensor_data([[1, 1, 1, 1, 1]]))
actuator = Actuator.start_node([])
# Wire up network
connect(from: sensor, to: neuron, weights: [20, 20, 20, 20, 20])
connect(from: neuron, to: actuator)
# tap into actuator for testing purposes
NodeProcess.add_outbound_connection(actuator, self())
# feed input into sensor
NodeProcess.sync(sensor)
# verify actuator output
assert actuator_next_output() == 110| Name | Example | Kind of Like |
|---|---|---|
| Atom | :foo | Symbols in Ruby |
| Lists | [:item, 30, "hat"] | Arrays |
| Tuples | {:ok, "It the was the best of times..."} | Objects + Pointers (stored contiguously) |
| Maps | %{:first => "Bob", :last => "Barker} | Objects, Key-Value Stores |
| Keyword Lists | [age: 40, gender: "F"] | [{:age, 40}, {:gender, "F"}] |
# The equal sign is a Match Operator
# It binds when empty
iex> x = 1
1
# It fails on mismatches
iex> 2 = x
** (MatchError) no match of right hand side value: 1
# It can match simple values, data structures, and functions
iex> {:ok, result} = {:ok, 13}
{:ok, 13}
iex> result
13
iex> greeter = fn -> "Hey Buddy" end
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> greeter.()
"Hey Buddy"Functions can be assigned to variables
iex> apply.(minus_2,6)
4Functions can be passed to other functions
Functions can return functions
inception_greeter = fn ->
fn ->
"Hiya"
end
end
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> inception_greeter.()
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> greeter = inception.()
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> greeter.()
"Hiya"name_greeter = fn name ->
fn ->
"Hiya #{name}!"
end
end
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> tiff_greeter = name_greeter.("Tiff")
#Function<20.52032458/0 in :erl_eval.expr/5>
iex> tiff_greeter.()
"Hiya Tiff!"Functions carry with them the bindings of variables in the scope they're defined (closures).
It's a modern, functional language! Huge libraries of functions are built-in and the convention is to use them.
Pipelines!
people = DB.find_customers
orders = Order.for_customers(people)
tax = sales_tax(orders, 2016)
filing = prepare_filing(tax)filing = DB.find_customers
|> Orders.for_customers
|> sales_tax(2016)
|> prepare_filingdefmodule Butler.Tableflip do
@moduledoc """
Flip some tables
"""
use Butler.Plugin
@usage """
tableflip - replies with a flipped table
"""
def flip_table do
:random.seed(:os.timestamp)
table_list = [
"(╯°□°)╯︵ ┻━┻",
"(╯°□°)╯︵ <ǝlqɐʇ>",
"the table flipped you! ノ┬─┬ノ ︵ ( \o°o)\ ",
"┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻"
]
Enum.random(table_list)
end
hear ~r/tableflip/, conn do
reply conn, flip_table
end
endBooks
Screencasts
Exercises
Newsletters
More...
Talk / Lightning Talk Ideas