stevensonmt

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

lpil

Creator of Gleam

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 :slight_smile:

josevalim

josevalim

Creator of Elixir

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. :slight_smile:

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

lpil

Creator of Gleam

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.

Where Next?

Popular in Discussions Top

blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 13924 124
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
New
PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement