The following is a guide to help compare Elixir and Ruby syntax and implementations.

</tr> </tr> </tr>
Ruby Elixir
Characteristics Object-oriented, Imperative, Metaprogramming Functional, Actor Concurrency, Macros
Typing Dynamic Dynamic
Concurrency N/A Lightweight Processes
Static Analysis Not Available Optional Typespecs
Interfaces Duck Typing Behaviours & Protocols
Package Manager RubyGems Hex
Task Runner rake mix
Interactive Shell irb iex
Testing RSpec, test-unit, minitest ExUnit
Web Framework Rails Phoenix
Virtual Machine YARV BEAM
Distributed Computing N/A Open Telecom Platform (OTP)
Define a method/function
def hello
  "result"
end
def hello do
  "result"
end
Variable assignment/Capture
#
a = "hello"
# match operator
a = "hello"
Hash/Map Syntax
{a: 1}
%{a: 1}
Array/Tuple
[1, 2, 3, 4]
{1, 2, 3, 4}
List Syntax
# Not Available
[1, 2, 3, 4]
Map an Array/List
[1, 2, 3, 4].map { |x| x * x }
Enum.map([1, 2, 3, 4], &(&1 * &1))
Range Syntax
1..4
1..4
String Interpolation
"#{2 + 2}"
"#{2 + 2}"
Reverse a String
"hello".reverse
String.reverse("hello")
Define a class
class Hello
end
# Not Applicable
# Modules, Structs, Protocols are used
Anonymous Functions
square = lambda { |x| x * x }
square = fn(x) -> x * x end
Call Anonymous Function
square.call(2)
square.(2)
square.(2)
Define Module
module Example
end
defmodule Example
end
Atoms
#
:one
# not garbage collected
:one
Division
#
5 / 2 == 2
# use div/2 for integer division
 5 / 2 == 2.5
If
if true
end
if true do
end
Else If
result = if 0 > 1
           "No"
         elsif 0 > 2
           "Nope"
         else
           "fallback"
         end
result = cond do
           0 > 1 -> "No"
           0 > 2 -> "Nope"
           true  -> "fallback"
         end
#
#
Printing
puts "Hello World"
IO.puts "Hello World"
Looping
[1, 2, 3, 4].each { |i| puts i }
Enum.each([1, 2, 3, 4], &(IO.puts &1))
Pattern Matching
# Not available
#
#
#
#
[a, b] = [1, 2]
%{a: value} = %{a: 1}
# pattern matching can match against literals
# and be used in function definitions,
# case statements, list comprehensions and more
Guard Clauses
# not available
#
def hello( v ) when is_atom(v) do
end
Metaprogramming
method_missing
define_method
# et al
# Macros
#
#