r/erlang • • 8h ago

libtmux-erlang 0.1: tmux client library for Erlang / BEAM

Thumbnail
github.com
6 Upvotes

Hi all, I maintain libtmux, the Python library for tmux. I've been bringing the same sessions, windows and panes to Erlang. The core application is on Hex; it's still an early release.

It wraps tmux's CLI. Here I'm starting a server, finding a pane, sending some text and checking its screen. There's also an operation you can start and await separately, including a wait that times out while the work remains pending.

Compared with the released Python library, this has owned asynchronous operations, explicit cancellation, and query plans you can inspect before fetching. The objects are still tmux's sessions, windows and panes. I'm interested in how that fits Erlang's processes and ownership model.

A word on AI: It's experimental, and I used LLMs extensively to create this. Parts of this post were also drafted and tested with AI. My AI policy has more on that.

libtmux_erlang: tmux from Erlang

Hex · GitHub · Docs · API · Installation guide

Use a current Erlang/OTP 29 release, Rebar3, Linux and tmux 3.3a–3.8. Native records are experimental in OTP 29. You'll also need make and a C11 compiler. Installation builds an external helper for owning and retiring subprocesses; it isn't a NIF.

Start in an empty directory. Save as rebar.config; Rebar3 resolves this from Hex:

{deps, [libtmux_erlang]}.
rebar3 compile

Keep the resulting rebar.lock to retain the resolved package version and checksum.

Save as demo.erl. with_owned (source) starts a separate daemon and checks its cleanup, including when the callback raises.

-module(demo).
-export([run/0]).

run() ->
    {ok, _} = application:ensure_all_started(libtmux_erlang),
    Executable = list_to_binary(os:find_executable("tmux")),
    {ok, ok} = tmux_server:with_owned(#{executable => Executable},
        fun(Server) ->
            {ok, _} = tmux_session:create(Server,
                #{name => <<"demo">>, window_name => <<"editor">>,
                  launch => #{argv => [<<"/bin/cat">>]}}),
            {ok, Initial} = tmux_server:snapshot(Server),
            First = tmux_select:one_or_error(tmux_select:panes(Initial)),
            {ok, Title} = tmux_command:raw(<<"select-pane">>,
                [<<"-t">>, tmux_model:get(id, First), <<"-T">>, <<"build">>]),
            {ok, _} = tmux_server:command(Server, Title, #{}),

            {ok, Snapshot} = tmux_server:snapshot(Server),
            Sessions = tmux_select:where(#{name => <<"demo">>},
                tmux_select:sessions(Snapshot)),
            Windows = tmux_select:where(#{name => <<"editor">>},
                tmux_select:windows(Snapshot)),
            Session = tmux_select:one_or_error(Sessions),
            Window = tmux_select:one_or_error(Windows),
            Panes = tmux_select:where(#{title => <<"build">>,
                window => #{is => #{name => tmux_model:get(name, Window)}}},
                tmux_select:panes(Snapshot)),
            Pane = tmux_select:one_or_error(Panes),
            io:format("~ts / ~ts / ~ts~n", [tmux_model:get(name, Session),
                tmux_model:get(name, Window), tmux_model:get(title, Pane)]),

            {ok, _} = tmux_pane:send_text(Pane, <<"build: complete">>),
            {ok, _} = tmux_pane:send_keys(Pane, [enter]),
            Deadline = erlang:monotonic_time(millisecond) + 5000,
            ok = await_line(Pane, <<"build: complete">>, Deadline),
            io:format("output: build: complete~n")
        end),
    ok.

await_line(Pane, Line, Deadline) ->
    {ok, Bytes} = tmux_pane:capture(Pane, #{}),
    case lists:member(Line, binary:split(Bytes, <<"\n">>, [global])) of
        true -> ok;
        false ->
            case erlang:monotonic_time(millisecond) < Deadline of
                true ->
                    receive after 20 -> await_line(Pane, Line, Deadline) end;
                false -> error(output_timeout)
            end
    end.
erlc -pa _build/default/lib/libtmux_erlang/ebin demo.erl &&
erl -noshell -pa . _build/default/lib/libtmux_erlang/ebin \
    -eval 'demo:run(), halt().'
demo / editor / build
output: build: complete

tmux_select:where (source) filters the captured graph. It doesn't contact tmux again. The pane example sends text to cat and reads the terminal's screen; it isn't isolated command stdout. Other clients can contribute output in a shared pane.

P.S. Change the window query from <<"editor">> to <<"editor2">>, keeping the creation name as it was. Compile and run it again. one_or_error raises:

no_match

one (source) instead returns a tagged result when you'd rather handle that branch yourself.

There is one core OTP application here. Persistent control attachments currently establish identity and manage the client lifetime. Sending commands and streaming pane output through that connection are still implementation work.

Query chaining and source plans

where (source) adds conditions to an immutable query. explain does no I/O; fetch is the point where the reads happen.

Save as query_demo.erl:

-module(query_demo).
-export([run/0]).

run() ->
    {ok, _} = application:ensure_all_started(libtmux_erlang),
    Executable = list_to_binary(os:find_executable("tmux")),
    {ok, ok} = tmux_server:with_owned(#{executable => Executable},
        fun(Server) ->
            {ok, _} = tmux_session:create(Server,
                #{name => <<"query-demo">>, window_name => <<"editor">>,
                  launch => #{argv => [<<"/bin/cat">>]}}),
            Q0 = tmux_query:panes(Server),
            Q1 = tmux_query:where(#{active => true}, Q0),
            Q2 = tmux_query:where(
                #{window => #{is => #{name => <<"editor">>}}}, Q1),
            Query = tmux_query:pushdown(true, Q2),
            Plan = tmux_query:explain(Query),
            true = maps:get(pushdown, Plan),
            complete_graph = maps:get(hydration, Plan),
            io:format("native candidate filtering: ~p~n",
                [maps:get(pushdown, Plan)]),
            io:format("hydration: ~p~n", [maps:get(hydration, Plan)]),
            {ok, Panes} = tmux_query:fetch(Query),
            io:format("active editor panes: ~p~n", [tmux_select:size(Panes)])
        end),
    ok.
erlc -pa _build/default/lib/libtmux_erlang/ebin query_demo.erl &&
erl -noshell -pa . _build/default/lib/libtmux_erlang/ebin \
    -eval 'query_demo:run(), halt().'
native candidate filtering: true
hydration: complete_graph
active editor panes: 1

Native filtering is opt-in. It can add a candidate scan; the full graph is still read and the complete predicate is checked locally. So I wouldn't describe this as fewer subprocesses. Text and relationship conditions stay local, and reads of a changing server aren't atomic. The current snapshot path groups fields into framed entity scans; that is separate from grouping mutation commands.

Submit an operation, then await it

tmux_operation lets a process keep an operation handle while it does other work. An await timeout ends that wait, not the operation. This uses tmux's wait-for signal so there's something specific to await.

Save as operation_demo.erl:

-module(operation_demo).
-export([run/0]).

run() ->
    {ok, _} = application:ensure_all_started(libtmux_erlang),
    Executable = list_to_binary(os:find_executable("tmux")),
    {ok, ok} = tmux_server:with_owned(#{executable => Executable},
        fun(Server) ->
            {ok, _} = tmux_session:create(Server,
                #{name => <<"operation-demo">>,
                  launch => #{argv => [<<"/bin/cat">>]}}),
            {ok, Wait} = tmux_command:raw(<<"wait-for">>, [<<"build-done">>]),
            {ok, Operation} = tmux_operation:start(Server, Wait,
                #{deadline_ms => 5000}),
            {error, #{code := await_timeout}} =
                tmux_operation:await(Operation, 0),
            io:format("wait: pending; operation retained~n"),
            {ok, Signal} = tmux_command:raw(<<"wait-for">>,
                [<<"-S">>, <<"build-done">>]),
            {ok, _} = tmux_server:command(Server, Signal, #{}),
            {ok, #{exit_status := 0, cleanup := complete}} =
                tmux_operation:await(Operation, 5000),
            io:format("signal: received; client cleaned up~n")
        end),
    ok.
erlc -pa _build/default/lib/libtmux_erlang/ebin operation_demo.erl &&
erl -noshell -pa . _build/default/lib/libtmux_erlang/ebin \
    -eval 'operation_demo:run(), halt().'
wait: pending; operation retained
signal: received; client cleaned up

This proves that the signal arrived. It doesn't prove a build ran: a real job needs to send its own completion signal and provide whatever result you need to check. Operations currently use bounded one-shot clients. Cancellation can leave an already-sent command's outcome unknown.

Control connection lifetime

The current control API owns an attachment and checks identity on that connection. It doesn't yet offer command submission or an output-event stream. Save as control_demo.erl:

-module(control_demo).
-export([run/0]).

run() ->
    {ok, _} = application:ensure_all_started(libtmux_erlang),
    Executable = list_to_binary(os:find_executable("tmux")),
    {ok, ok} = tmux_server:with_owned(#{executable => Executable},
        fun(Server) ->
            {ok, Session} = tmux_session:create(Server,
                #{name => <<"control-demo">>,
                  launch => #{argv => [<<"/bin/cat">>]}}),
            {ok, Control} = tmux_control:attach(Server, Session, #{}),
            try
                {ok, #{phase := open, identity := same_connection}} =
                    tmux_control:status(Control),
                {ok, Attached} = tmux_session:get(Server,
                    tmux_model:get(id, Session)),
                io:format("attached clients: ~p~n",
                    [tmux_model:get(attached_count, Attached)])
            after
                ok = tmux_control:close(Control)
            end,
            {ok, #{phase := closed, cleanup := complete}} =
                tmux_control:status(Control),
            io:format("control client: closed~n")
        end),
    ok.
erlc -pa _build/default/lib/libtmux_erlang/ebin control_demo.erl &&
erl -noshell -pa . _build/default/lib/libtmux_erlang/ebin \
    -eval 'control_demo:run(), halt().'
attached clients: 1
control client: closed

The attachment is closed before its parent server. We own this server and its session; attaching to somebody's existing session can also trigger their configured hooks.

I'd be interested in feedback on the operation handles and cleanup API from people using Erlang.


Related, I also released an elixir package for tmux as well!


r/erlang • • 2d ago

Nera - Erlang that ships like Go

Thumbnail
process-one.net
23 Upvotes

r/erlang • • 2d ago

Should an agent be a process or a data structure?

4 Upvotes

In Jido 2.0, an agent is a validated struct and the process is a separate layer. Mike Hostetler got there after two early mistakes. The first was a private queue in GenServer state that let actions skip ahead of the mailbox. The second was making every agent a DynamicSupervisor.
Now the top-level GenServer only takes in a signal, hands the work to short-lived tasks and child processes, and saves the result back to its state. He also tried OTP 28 priority messages for reentrancy, and that work is feeding into Jido 3. Francesco compares the 2.0 rewrite to the first OTP release, where only the behaviours that cleanly separated the generic from the specific lasted.

https://youtu.be/OTZezdLLuqU


r/erlang • • 3d ago

F3 file format for Beam languages

4 Upvotes

I've started following the F3 project. F3? It's a columnar research file format: the file stores columns, and a footer at the end holds an Arrow schema plus where those columns live. A file can also embed a Wasm decoder next to the data. The spec is still a prototype. This library speaks wire version 0.1 only.

I published f3 0.1.0 so you can open one of those files from Elixir, print the schema and footer, and read or write rows when the native decoder is loaded. Wasm stays off unless a read passes wasm: :sandbox, which runs that embedded module in a Wasmtime sandbox. A Hex install downloads precompiled builds for Apple silicon and Linux x86_64.

The longer version is in my write-up. The API is on Hexdocs, and the code is on GitHub.


r/erlang • • 3d ago

I compiled Gleam's BEAM bytecode to WebAssembly so it runs on edge workers

Post image
19 Upvotes

afterglow is a compiler I've been writing. It compiles BEAM bytecode to WebAssembly ahead of time and links it with a small runtime written in Rust, so a Gleam app built for the Erlang target runs as an edge worker. It's experimental and runs a subset of OTP. Repo (GPL-3.0): https://github.com/withgiolt/afterglow · docs: https://docs.giolt.com/afterglow/about · live example: https://gote.giolt.app

Against the same app on Erlang/OTP 28, on one machine: startup 8.6 ms vs 175 ms, memory 0.5 MiB vs 29.9 MiB, and a warm request 10.7 µs vs 3.4 µs, so it's slower once warm. The script that reproduces this is in the repo.

Missing today: ETS, regular expressions, crypto hashing, and processes that outlive a request. You know the BEAM better than I do, so I'd like to hear which parts of OTP you'd expect to need first, and where my approach is naive. If you'd rather fix one than tell me, the build lists the missing functions, and PRs are very welcome.

And a broader question: afterglow works on BEAM bytecode, not Gleam source, so plain Erlang apps aren't out of reach. Would you deploy an Erlang app this way, and what kind? It's a question, not a promise.

I built it for Giolt, my host for Gleam apps (waitlist: https://giolt.com/waitlist).


r/erlang • • 3d ago

Call for Talks and Call for Training for ElixirConf EU 2027 (Lisbon, 22-23 April), BEAM topics welcome

Post image
5 Upvotes

Hi all!

ElixirConf EU takes place in Lisbon and online on 22-23 April 2027, with a training day on 21 April. The Call for Talks and the Call for Training are open until 15 December.

Talk topics are not limited to Elixir code. If you work with Erlang/OTP or the wider BEAM (runtime, OTP design, tooling, production stories, distributed systems), a proposal is welcome. We have two tracks with 20- and 40-minute slots: https://sessionize.com/elixirconf-eu-2027/

We are also looking for trainers for a full-day Elixir or BEAM training on 21 April: https://forms.gle/YY3cJJpt9fYaMPQ46

Event site: https://www.elixirconf.eu/

Questions are welcome in the comments :)


r/erlang • • 16d ago

What does a 33.3 ms tick do to an Erlang timer?

8 Upvotes

It rounds to 33. Hernán Rivas Acosta's multiplayer game AstroBeam ran a 30 Hz server tick on a timer that only accepts whole milliseconds, and the drift showed up as lag that grew steadily through each match. Short playtests hid it completely. Moving to 40 Hz, a clean 25 ms, fixed it.
Also from the conversation: his first Erlang game server, around 2010, held 50,000 concurrent TCP connections per machine, limited only by file descriptors; the Java option would have managed a few thousand. And he chose WebAssembly over a NIF so a simulation crash kills one match process, not the node.

https://youtu.be/XubYVNbehYc


r/erlang • • 25d ago

https://eyg.run/guides/embedding-eyg-in-erlang-programs

0 Upvotes

r/erlang • • 26d ago

Code Beam Europe 2026

3 Upvotes

Code BEAM Europe 2026 starts tomorrow.

On Wednesday 21 and Thursday 22 October, the Erlang, Elixir and Gleam communities meet at PHIL in Haarlem and online for two days and two tracks of talks.

This year's programme covers:
- Type systems: José Valim on set-theoretic types, Roberto Aloi (WhatsApp) on Erlang typing in the prompt era
- AI and the runtime: finding vulnerabilities with AI, and whether language or runtime matters more when AI writes the code
- Production stories: distributed Elixir at NetzeBW, self-healing systems, ATProto on Elixir
- The runtime itself: Native Records from the OTP team, BeamAsm JIT on ARM32, AtomVM
- Keynotes from Sam Aaron, José Valim and Brooklyn Zelenka

Not in Haarlem? Join online with 15% off a virtual ticket using code 15FORYOU.

Your virtual ticket includes:
- Both tracks live, on both days
- Live Q&A with speakers
- Online networking through the conference app
- 3 months of exclusive access to the recordings

Tickets: https://codebeameurope.com/#register

See you tomorrow!


r/erlang • • 26d ago

Voyager v0.2.0 - ETS Tables, Processes and more!

12 Upvotes

r/erlang • • 27d ago

Running a subset of Erlang/Elixir on bare metal - Parallax Propeller 2

11 Upvotes

First preview with pre-built binaries available at https://github.com/modernc-org/obeam

BSD-3 License


r/erlang • • Oct 16 '26

ejabberd 26.09 / ProcessOne - Erlang Jabber/XMPP/Matrix Server - Communication

Thumbnail
process-one.net
9 Upvotes

r/erlang • • Oct 16 '26

The BEAM Book came from a production outage caused by a function that used only 20 reductions - what does that tell us about reduction accounting?

8 Upvotes

New BEAM There, Done That with Erik Stenman (Happi) - Erlang researcher since 1994, BEAM Book author, former architect of Klarna's payment core.

The scar is worth dissecting for this community: on Christmas Eve, Klarna's BEAM scheduler throttled to a single active scheduler due to low overnight traffic. A large batch job arrived. An XML-to-binary serialization function used only 20 reductions per call regardless of input size. It ran on the single scheduler, never yielded, and Heart (the external watchdog process) couldn't get a response from the VM. Heart killed the system. The failover node hit the same condition. So did the third. Half-hour outage on Christmas Eve.

The fix required going deep into runtime behavior - understanding the relationship between reductions, yielding, and scheduler availability under load. That diagnostic process is directly what motivated the BEAM Book.

The current work (Eldrim - sovereign AI compute routing) applies the same principle at a different layer: you need to know where resources actually run, not where you've been told they run.

https://youtu.be/afRZmYXwukg


r/erlang • • Oct 07 '26

Code BEAM Europe 2026 (21-22 Oct, Haarlem + online): OTP team update, Native Records, doctests, WhatsApp on Erlang DevX

10 Upvotes

Disclosure: I'm on the Code BEAM Europe organising team. The programme is final and there's a lot of Erlang in it this year.

From the Erlang/OTP team

More Erlang

Tutorial on 20 October: Gnome Village: Understanding the BEAM Through Processes, Flows, and Runtime Behaviour, a full day with Erik Stenman (author of The BEAM Book) and Måns af Klercker.

Informal Space: the community-run third room includes an open ELP clinic. Bring your own project and the tool authors will help you set it up. See the lineup

Practical

  • PHIL in Haarlem, 15 minutes by train from Amsterdam Centraal

  • Online ticket €146 + VAT with recordings

Programme and tickets: codebeameurope.com


r/erlang • • Sep 24 '26

WebAssembly on the BEAM: Building erlang_wasm in Erlang by Benoit Chesneau at Func Prog Sweden

Thumbnail
youtube.com
18 Upvotes

r/erlang • • Sep 21 '26

Just released Rheo a broker less consumer group library

Thumbnail
reddit.com
1 Upvotes

r/erlang • • Sep 18 '26

The Schedule | Code BEAM Europe 2026!

Thumbnail
gallery
22 Upvotes

Hey everyone, the full Code BEAM Europe 2026 schedule is up! Two days, two tracks, 21-22 October in Haarlem (and online), with a training day on 20 October.

One update worth flagging: Frank Hunleth and Omer Kilic won't be giving keynotes this year, but José Valim is stepping in with a keynote, "Set-Theoretic Types from Scratch," and he is sticking around for extended Q&A, so bring your questions. Alongside José, we have Sam Aaron (twice, including the interactive Phone Orchestra evening session) and Brooklyn Zelenka closing things out.

Check the full schedule here: codebeameurope.com/#schedule

Come for the talks, stay for the hallway track. Use the code 10FORYOU and get additional -10% off your ticket! Register for the event here: codebeameurope.com/#register

See you there!


r/erlang • • Sep 18 '26

Is your Elixir benchmarking actually telling you the truth -or are you measuring the wrong thing?

Thumbnail
reddit.com
7 Upvotes

r/erlang • • Sep 15 '26

Everything you missed at ElixirConf US 2026

Thumbnail
youtube.com
9 Upvotes

Hi There!

That's a wrap on ElixirConf US 2026, and what a two days it was. Some of the talks are already public (https://www.youtube.com/playlist?list=PLVqsKC3zWaDc) + here's a quick recap of what you missed:

  • Many jokes from the stage - including the room shouting out their country out loud at the end of every day. You had to be there. (Or, you know, watch it back.)

  • Even more jokes from Aaron, our Track host, who kept the energy high between sessions.

  • Roundtable sessions - which turned out to be overpopulated by 300%!

  • The Bingo Bard game - a full board of squares we prepared for you to play throughout the event. Shoutout to the one person who completed the entire thing in the first two hours. We know who you are… (No, we don't. But we're impressed.)

And of course, two full days of talks, keynotes, lightning talks, and roundtables from across the Elixir community.

Want to see all of the talks? Grab the video pass

  • It's 3 months of access to the recorded sessions after the conference (edited, ready-to-watch session videos)

Grab the video pass for $199 HERE.

Craving more Elixir?

Join us at Code BEAM Europe 2026! Expect 30+ talks from José Valim & many others, across the Erlang, Elixir, and Gleam communities, informal zone sessions, and two days of the same great people, ideas, and energy - this time in Europe, Haarlem, NL, 21-22 October. 

Register for it here.

See you at the next ElixirConf (or Code BEAM event :))

The Code Sync Team


r/erlang • • Sep 13 '26

Just released ExArrow v0.9.0

Thumbnail
reddit.com
4 Upvotes

r/erlang • • Sep 10 '26

Gleam Gathering 2027 next Feburary in London

Thumbnail reddit.com
2 Upvotes

r/erlang • • Sep 10 '26

My reproducible Erlang playground with Nix

Thumbnail
elmwithdwayne.dev
14 Upvotes

r/erlang • • Sep 06 '26

Erlane web eco-system

14 Upvotes

I still here quite a lot when I am at conferences or work that you can't build erlang web systems compared to Elixir. Here I will share some tools that I have been using that are similar to Elixir:s eco-system. Sure we are probably lacking some parts but I would say we are in a good fit.

Web framework: novaframework/nova: Web framework for the BEAM — Erlang, Elixir, and LFE

Postgres job queue (Similar like oban): Taure/shigoto: PostgreSQL-backed background job processing for the Nova ecosystem
ORM db ecto style: Taure/kura: Database layer for Erlang

circuit breaker, rate limit library: Taure/seki: Resilience library for the BEAM — circuit breaking, rate limiting, bulkheads, and retry

Rebar3 plugins:

audit for vulnerabilities: Taure/rebar3_audit: Audit rebar3 dependencies for known vulnerabilities (GitHub Advisory Database)

mutation testing: Taure/rebar3_mutate: Mutation testing plugin for rebar3

only run tests for affected code changes: Taure/rebar3_stale: Rebar3 plugin for running only stale tests affected by changed modules


r/erlang • • Sep 06 '26

Become part of a mesh of AI agents

Thumbnail reddit.com
0 Upvotes