Hacker News new | past | comments | ask | show | jobs | submit login

I do not quite understand that it runs on BEAM and Javascript with runtime.

Most of the great things I like about Elixir is tied to feature native to BEAM. (I think).

And I would expect that BEAM has not been ported to a Javascript runtime?

I would also expect at Gleam for Javascript can use and interact with Javascript libraries and what not, not possible under the regular version.

I would also expect that it is possible to write useful code that mill work on both platforms. but with a lot of limitations.

Do I have this completely wrong?




Most Gleam code is backend agnostic, but code that does something BEAM specific like OTP or Erlang FFI is only available when targeting the BEAM and JS ffi is only available when targeting JS. You can also provide two implementations of a function, one for each backend if you want to target both.


Erlang FFI? Doesn’t the Erlang Virtual Machine run the Gleam code? How is calling Erlang functions FFI?


I just mean FFI in the general sense, that you're interfacing with a non-Gleam language. What's the word for that? Bindings?

I guess if you've transpiled Gleam to JS then is calling a JS function even FFI anymore?


Yeah this is one of the typical mistakes of guest languages, they start by offering something that the platform language is missing out on, and eventual in the pursue for greater mindstart try to expand elsewhere, however by doing so, they lose the capabilities that made the original target platform special, and eventually become their own thing, if they survive beyond the typical adoption curve.


It's useful because you can write back-end and front-end code with the same language. Code sharing should work, as long as you don't use runtime-specific features blindly. All basic language features seem to work the same regardless of runtime.


Yup that's right, you can't use Erlang code on JS runtimes or JS code on Erlang runtimes. Most library code doesn't use either, so it's usable on both.

Elixir is also quite a lovely language even when not using any BEAM specific functionality! I used it a lot for writing regular sequential programs.


I think it might help to start with a baseline assumption: newer high-ish level languages (or any such language looking to expand mindshare) will inevitably be asked “[how] can I run code written in this language in a browser?”


The benefit is you can write JS by writing the same language as the rest of your app. I wish I could do that with Elixir. Not run the app on a javascript runtime but write frontend code that will transpile to JS.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: