Hello, World
The classic first program: print the line Hello, BEAM!. Notice how the BEAM languages diverge already on day one - Erlang and LFE reach for io:format, Elixir has a friendly IO.puts, Gleam routes everything through its typed gleam/io module, and Luerl runs plain Lua's print. Watch the surface syntax (S-expressions vs. pipes vs. ML-style) while the underlying runtime stays the same.
-module(hello).
-export([main/0]).
main() ->
io:format("Hello, BEAM!~n").Erlang wraps code in a -module/-export pair and prints with io:format/1, where ~n is the format control sequence for a newline.
defmodule Hello do
def main do
IO.puts("Hello, BEAM!")
end
end
Hello.main()Elixir's IO.puts/1 writes a string and appends the newline for you; modules and functions are defined with defmodule and def.
import gleam/io
pub fn main() -> Nil {
io.println("Hello, BEAM!")
}Gleam keeps side effects explicit: you import gleam/io and call io.println, which returns Nil - the empty type that the public main function also yields.
(defmodule hello
(export (main 0)))
(defun main ()
(io:format "Hello, BEAM!~n"))Lisp Flavoured Erlang expresses the same module in S-expressions, calling the very same io:format BEAM function with Erlang's ~n newline directive.
local function main()
print("Hello, BEAM!")
end
main()Luerl runs standard Lua on the BEAM, so the idiomatic choice is Lua's built-in print, which writes its arguments followed by a newline.