out, and I love thinking about their design and implementation. (I know, it’s sad.) I came across Ruby in 1998 because I was an avid reader of comp.lang.misc (ask your parents). I downloaded it, compiled it, and fell in love. As with any time you fall in love, it’s difficult to explain why. It just worked the way I work, and it had enough depth to keep me interested. ... - Foreword to Programming Elixir Friday, September 6, 13
for something new that gave me the same feeling. I came across Elixir a while back, but for some reason never got sucked in. But a few months ago I was chatting with Corey Haines. I was bemoaning the fact that I wanted to find a way to show people functional programming concepts without the kind of academic trappings those books seem to attract. He told me to look again at Elixir. I did, and I felt the same way I felt when I first saw Ruby. ... - Foreword to Programming Elixir DAVE THOMAS Friday, September 6, 13
Elixir I knew something was happening on the Erlang VM, and I didn’t know about this. Boy am I out of touch.” - Blog Post - http://joearms.github.io/2013/05/31/a-week-with-elixir.html JOE ARMSTRONG Friday, September 6, 13
… It didn’t take long, but pretty soon my gut feeling kicked in. This is good shit.” - Blog Post - http://joearms.github.io/2013/05/31/a-week-with-elixir.html Friday, September 6, 13
surface syntax, inspired by Ruby. What you might call a ‘non-scary’ syntax, and a load of extra goodies.” - Blog Post - http://joearms.github.io/2013/05/31/a-week-with-elixir.html JOE ARMSTRONG Friday, September 6, 13
lot of things right, and the good things far outweigh the bad things.” “This has been my first week with Elixir, and I’m pretty excited.” - Blog Post - http://joearms.github.io/2013/05/31/a-week-with-elixir.html JOE ARMSTRONG Friday, September 6, 13
CONTROLLING A SWITCH OR CONVERTING PROTOCOLS. SERVERS FOR INTERNET APPLICATIONS, E.G. A MAIL TRANSFER AGENT, AN IMAP-4 SERVER, AN HTTP SERVER OR A WAP STACK. TELECOMMUNICATION APPLICATIONS, E.G. HANDLING MOBILITY IN A MOBILE NETWORK OR PROVIDING UNIFIED MESSAGING. DATABASE APPLICATIONS WHICH REQUIRE SOFT REALTIME BEHAVIOUR. HTTP://WWW.ERLANG.ORG/FAQ/INTRODUCTION.HTML#ID49576 Friday, September 6, 13
NONE — OF THE BAD. THAT’S A BOLD STATEMENT, RIGHT? ELIXIR IS WHAT WOULD HAPPEN IF ERLANG, CLOJURE, AND RUBY SOMEHOW HAD A BABY AND IT WASN’T AN ACCIDENT. -- DEVIN TORRES HTTP://DEVINTORR.ES/BLOG/2013/01/22/THE- EXCITEMENT-OF-ELIXIR/ Friday, September 6, 13
do 5 Count.sum(extract_types(get(username))) 6 end 7 8 # With Pipe Operator 9 def get_score(username) do 10 get(username) |> extract_types |> Count.sum 11 end Friday, September 6, 13
json = :jsx.decode to_binary(body) json2 = Enum.map json, fn ({k, v}) -> { binary_to_atom(k), v } end :orddict.from_list json2 end end Friday, September 6, 13
Add to .vimrc nnoremap <leader>e :!elixir %<CR> nnoremap <leader>ee :!iex -r % -S mix<CR> # Use this in shell for repl $ iex -r lib/concurrency.ex -S mix # Use this in shell for tests $ elixir test/concurrency_test.ex $ mix test Friday, September 6, 13
"area" do area = fn(w, h) -> w * h end assert area.(3,5) == 15 end end beastie:concurrency elixir test/concurrency_pre_test.exs . Finished in 0.08 seconds (0.08s on load, 0.00s on tests) 1 tests, 0 failures TESTS (VERSION 1) Friday, September 6, 13
IO.puts “Bye cruel world!” input -> IO.puts Geometry.area(input) area_loop() end end def start do spawn(fn -> Concurrency.area_loop() end) end end defmodule Geometry do def area({ :rectangle, w, h }) do w * h end def area({ :circle, r }) do :math.pi * r * r end def area({ :cone, r, h }) do :math.pi * r * :math.sqrt( r * r + h * h) end end Friday, September 6, 13
# Linked Lists - Yay recursion! [head | tail] # Records - like structs defrecord FileInfo, atime: nil, accesses: 0 # Protocols - for polymorphism defprotocol Blank do @doc "Returns true if data is considered blank/empty" def blank?(data) end # Homoiconic - turtles all the way down Elixir is written in Elixir (esp macros) OTHER GOODIES Friday, September 6, 13