stevensonmt
Gleam v Elixir interop with BEAM
From the Gleam website FAQ regarding comparison to elixir:
- Elixir code can be difficult to use from other BEAM languages, Gleam code is designed to be usable from all BEAM languages.
Is that true that Elixir interop is one-way? I know that it is very easy, for instance, to call on Erlang modules in Elixir code but does the converse not hold? What would be the reason for that difference with Gleam, both technically and pragmatically?
Most Liked
lpil
I will say I get asked quite frequently about both how to use Elixir macros in Gleam and how to use Gleam to type check Elixir code. I think it can be hard to understand what the limitations of languages are.
I think there’s still plenty of improvements we can make without any disruptive changes to Elixir. Interop will continue to get better over the coming years ![]()
josevalim
In addition to what was said, it is worth pointing out this is not exclusively an issue with Elixir. For example, Erlang has parse transforms and some libraries may need to work with Erlang AST, therefore any BEAM language that chooses to compile to Core Erlang, such as LFE, do not have access to tools like the GUI debugger or cover in OTP. Erlang parse transforms and features such as qlc are also incompatible with Elixir (and I assume with Gleam too).
However, Elixir macros are more common than parse transforms, so the issue is definitely more prominent. I am only mentioning this to give examples that interop is not always possible, even without macros. ![]()
EDIT: I would also add that macros are not such a big issue, because macros are Elixir features, and therefore it is expected you have to write Elixir in other to use them. It is like wanting to use Gleam type system from Elixir/Erlang. If you want types, then it is expected you are writing Gleam code. I believe the issues mentioned by @lpil are probably trickier for reusing Elixir in other languages.
lpil
Another thing that makes it tricky to use Elixir from other languages is the way that the compiler and standard library is distributed. They are not part of the OTP distribution or a hex package, so if you ever add an Elixir package to your Erlang, Gleam, LFE, etc project you will then need to use the operating system package manager or similar to install the Elixir standard library and compiler.
The Gleam standard library is a hex package, and Gleam modules are pre-compiled before being uploaded to hex, so no additional tools or plug-ins need to be installed to use a Gleam package from other languages.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








