Elixir
v1.11.3
Elixir
v1.11.3
Elixir is a dynamic, functional language created by José Valim and first released in 2011. It runs on the Erlang virtual machine (BEAM), inheriting decades of battle-tested support for low-latency, fault-tolerant, distributed systems. Elixir offers a friendly, Ruby-inspired syntax while keeping Erlang's concurrency model based on lightweight processes that communicate by message passing.
Built around immutability and pattern matching, Elixir uses the actor model and OTP behaviors like GenServer and supervisors to build resilient applications. It powers high-throughput web services through the Phoenix framework, real-time systems, and embedded software via Nerves. Its metaprogramming with macros and a polished tooling experience, including Mix and Hex, make it productive and approachable.
IO.puts("Hello, World!")name = IO.gets("") |> String.trim()
IO.puts("Hello, #{name}!")[1, 2, 3, 4]
|> Enum.map(fn x -> x * x end)
|> IO.inspect()defmodule Math do
def add(a, b), do: a + b
end
IO.puts(Math.add(2, 3))defmodule Demo do
def classify(n) do
case n do
0 -> "zero"
n when n > 0 -> "positive"
_ -> "negative"
end
end
end
IO.puts(Demo.classify(5))
IO.puts(Demo.classify(-3))person = %{name: "Alice", age: 30}
IO.puts(person.name)
updated = %{person | age: 31}
IO.inspect(updated)
ages = %{"bob" => 25, "carol" => 28}
IO.inspect(Map.put(ages, "dan", 40))defmodule Factorial do
def of(0), do: 1
def of(n) when n > 0, do: n * of(n - 1)
end
IO.puts(Factorial.of(5))result =
1..10
|> Enum.filter(&(rem(&1, 2) == 0))
|> Enum.reduce(0, &+/2)
IO.puts(result)defmodule User do
defstruct name: "", age: 0
def adult?(%User{age: age}), do: age >= 18
end
u = %User{name: "Alice", age: 30}
IO.puts(u.name)
IO.puts(User.adult?(u))squares = for x <- 1..5, do: x * x
IO.inspect(squares)
evens = for x <- 1..10, rem(x, 2) == 0, do: x
IO.inspect(evens)
pairs = for x <- [1, 2], y <- [:a, :b], do: {x, y}
IO.inspect(pairs)Yes. CompileBytes runs your Elixir code on the BEAM in the browser, so there is no need to install Erlang or Elixir locally.
The compiler reports Elixir 1.11.3 running on the Erlang/OTP virtual machine.
Use IO.gets/1 to read a line of text, then trim or parse it, for example String.trim(IO.gets("")).
Yes, running Elixir on CompileBytes is free, and Elixir itself is open-source under the Apache 2.0 license.
Elixir uses lightweight BEAM processes that communicate by message passing, enabling massive concurrency and fault tolerance through OTP supervisors.