Go as a compilation target #1736
Replies: 2 comments 12 replies
-
Could be cool! Go has a lot of nice things about it. Before we implement a backend we would want to hand-compile some Gleam code to Go and other options such as C and ChezScheme and benchmark them to see what the performance is like. I suspect Go will be slower as it is optimised for a low number of allocations and lots of mutation, which is the inverse of Gleam |
Beta Was this translation helpful? Give feedback.
-
👋 I'd like to revive this conversation TL;DR: I think Go is a very good fit to be a backend for Gleam, and there is a real use-case for it in both lightweight, standalone CLIs and long-running applications with smaller footprints than a Javascript runtime or, maybe, the BEAM. Go library support would also improve Gleam library support, which is a pain-point for any young language. I think the following are good reasons to want to use Gleam with a Go backend:
Additionally, the Go runtime has features that would facilitate making sure that existing Gleam code targeting Erlang is also compatible with a Go-based compiler:
Lookig much longer term, further work could unlock value for Gleam:
I understand these would be a much later steps for Gleam, but it is a good example of what Go could potentially open the door to. For completeness, I do think there would be some shortcomings in a Go backend for Gleam:
Addressing @lpil 's comment:
While true, a lot of work can still be done on Gleam's end to make sure it reduces the number of allocations. Specifically, because Gleam does not mutate, functions can share structs between each other, rather than copying them every time. But I do think we'll never know how bad it is until we run some benchmarks! Right now I am writing a very dumb transpiler based on glance, and hopefully I can gather some numbers to make a stronger case. I understand all of this is much easier said than done! It's a big shift and it might not be worth it right now. I am not fluent in Rust (my jobs are usually Go and JVM), but if this is a direction Gleam wants to take, I am willing to get up to speed to help with compiler development or help with the library integration side of things. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions