Writing Python like it’s Elixir (or Erlang)

David Delassus
11 min readFeb 11, 2024

Elixir must be one of my favorite language, both in terms of feature-set and philosophy. I consider the BEAM (the Erlang VM) to be one of the best piece of technology we have, that is my entirely subjective opinion and nothing you can say will ever change it 🙂

I have this opinion because of 3 things mainly:

  • the concurrency model, often wrongly called Actor model¹
  • the ability to interoperate with every language compiling to the BEAM bytecode²
  • the OTP framework, the set of tools that allow you to build your distributed system³

Notes:

  1. For more informations, see: https://softwareengineering.stackexchange.com/a/277469
  2. Erlang, Elixir, Gleam, etc… You can call code written in each of those languages, from each of those languages.
  3. It’s important to note that OTP doesn’t give you a distributed system, but only the tools to build one (those tools are great though).

Designing the architecture of a system by splitting it into multiple, simple components that can talk to each other via message-passing makes each of those components easily testable, and generally easier to reason about.

Learning Erlang and Elixir made me rethink how I would design software even in other languages. This is even a source of inspiration for my own programming language Letlang.

This is what I will talk to you about in this article, how can you take inspiration from Erlang / Elixir, and apply their philosophy to another programming language. Let’s chose another one I’m fond of: Python.

Why Python?

Python evolved a lot in the last 10 years, it now has:

  • concurrency (with async and await keywords)
  • pattern matching (with the match statement)
  • annotations, used for dependency injection, or type hinting
  • a great ecosystem

While not on par with their Erlang/Elixir equivalent, the concurrency and pattern matching of Python are tools that I require for this endeavor. In fact, those are tools I now expect to find in every language I want to use.

--

--