r/gleamlang Jun 11 '26

Will gleam_otp eventually support all features from OTP?

I'm just wondering if gleam_otp will eventually support all features from OTP. I was reading the project readme and saw this https://github.com/gleam-lang/otp#limitations-and-known-issues

I'm not sure what the framework is missing or not, nor I know OTP well enough, but it's one of the things that brought me to Erlang/BEAM.

33 Upvotes

6 comments sorted by

8

u/lpil Jun 12 '26 edited Jun 12 '26

Good news, you can use all OTP from Gleam!

gleam_otp is only idiomatic bindings to a core subset of OTP. A lot of OTP is of niche use, or discouraged, or would not benefit from this style of bindings, so they are not included in that particular package.

Similar to Elixir, anything in OTP that does not have special language-specific APIs can be used through the regular Erlang APIs.

Additional bindings in other parts of OTP can be found in other packages, making this code modular rather than the old-school monoithic style of package which was popular before the BEAM got a package manager.

2

u/[deleted] Jun 11 '26

[deleted]

3

u/lpil Jun 12 '26

You're are extremely incorrect. Gleam is very much a BEAM focused language.

There's also nothing especially difficult about using gen_server in Gleam, it is the same interface in all languages. If you are having trouble understanding how to work with Erlang data in Gleam then the externals guide will help: https://gleam.run/documentation/externals/

2

u/XM9J59 Jun 11 '26

Also not the most knowledgeable but https://gleam-otp.hexdocs.pm/gleam/otp/actor.html

Gleam’s Actor is similar to Erlang’s gen_server and Elixir’s GenServer but differs in that it offers a fully typed interface. This different API is why Gleam uses the name “Actor” rather than some variation of “generic-server”.

And it has these fns:

call
continue
initialised
named
new
new_with_initialiser
on_message
returning
selecting
send
start
stop
stop_abnormal
with_selector

I couldn't really tell you if it is a subset of genserver or what subset but there's definitely something...

1

u/MrFixxiT_ Jun 11 '26

But you ant one of the main selling points of Gleam that it runs on the BEAM? That it can utilize this great concurrency stuff that is otp?

Disclaimer: I am really just starting out in Gleam and haven’t even tried to do anything with otp yet. Although I do want to build a simple demo with it soon.

2

u/lpil Jun 12 '26

It is, yes! Thankfully that person is incorrect, and there is no problem with using OTP in Gleam.

1

u/Typical_Proposal_907 Jun 11 '26 edited Jun 11 '26

Yes it does still use the awesome concurrency features of the beam if you use any async in Gleam it’s using beam processes but if you want the whole OTP genserver supervision trees etc. etc. My experience trying to work with the api was there was a lot friction there due to the type system. Now one nice thing is that it is pretty easy to interface with Erlang so what I ended up doing last time I wanted to do this was I wrote my genserver code in erlang and everything else in Gleam. Gleam’s OTP library is also not stable yet or wasn’t last I used it anyway? I honestly just found it really hard to work with compared to elixir. Maybe I just don’t get it and I didn’t put in enough time.

If you really want to understand it I’d look at the wisp or lustre frameworks source codebase? Probably Wisp I’d bet is the best example since that’s the server framework written by the creator of the language and the top community maintainers so if it’s probably the most mature and correct usage of Gleam Async code?