Remix.run Logo
▲ subarctic 2 days ago

I have a web app i've been using regularly and develop regularly with gleam on the frontend and backend. I have written very little of the code by hand and use claude to implement everything, open PRs and stuff and it works well. I like that it's typesafe and you can share code between the frontend and backend so easily, and you don't have to get a bunch of config right like you do if you want an all-typescript application. If I was writing it by hand I think I would find there's an annoying amount of boilerplate, but since ai is writing the code for me it's not a big deal.

Overall, I recommend it.

▲doomspork 2 days ago | parent | next [-]

What framework did you use for Gleam? I feel the last time I looked that was one of the big absent libraries.

▲whalesalad a day ago | parent [-]

this is what grinds my gears with gleam. afaik its not really possible to interact with elixir libraries? A project exists to try to make this 'easier' but the fact that it was not baked-in as first class is a huge smell to me https://github.com/gleam-lang/mix_gleam/

Perfect example: Clojure. Clojure is the textbook esoteric programmers dream... but it's SUPER easy to sell and integrate in a typical Java shop. Why? Clojure is Java. You can use everything on Maven. You can interop with any Java tooling. No hacks or BS required... it's a native compatibility. The fact that the Gleam did not opt for this level of congruence is mind boggling to me.

I could be wrong btw so please correct me if I am. I am genuinely interested in using Gleam in place of Elixir (I think they nailed syntax and got rid of a lot of bullshit) but it is unfortunately not a drop-in replacement. It should be.

▲Ndymium 19 hours ago | parent | next [-]

There are two sides to compatibility with Elixir: using Gleam in Elixir and using Elixir in Gleam. The former is harder, the latter is easier (with caveats).

Using Gleam in an Elixir project did/does rely on mix_gleam. I've used it some years ago and it worked then, but I haven't had recent experiences. There is a pull request[0] to Elixir to add built-in support for Gleam and as I understand it the Gleam team have made several changes to Gleam tooling to facilitate it, but it's unmerged as of now.

Using Elixir in a Gleam project is just an external function away, just like using Erlang or JavaScript (when using the JS target). E.g.

  @external(erlang, "Elixir.Some.Module", "my_fun")
  fn my_fun(some_arg: Wibble) -> Wobble
You can also write .ex files in your codebase and use functions from them as externals and they'll be compiled by Gleam.

The two main issues on that side are macros and structs. Since Gleam doesn't know about Elixir source or Elixir macros, you can't use them directly. But you can have an .ex file that uses macros and then you can call functions from that file. Structs are trickier, because they're just dynamic maps with a special key-value pair, and maps in Gleam (called Dict) have fixed types for the keys and values. That means you can't model a struct as a Dict. Gleam uses records for its own custom types, so what you can do is either use records on the Elixir side (with the Record module or by hand), or map the Elixir side data structures to be more palatable for Gleam (and vice versa) in your external functions --- which is what you generally do with externals anyway. Of course, if you only intend to pass the Elixir structs around and then back to Elixir, you can model them as external types that are then opaque to Gleam.

[0] https://github.com/elixir-lang/elixir/pull/14262

▲jjtheblunt a day ago | parent | prev [-]

is this not adequate?

https://gleam.run/frequently-asked-questions/#Can-I-use-Elix...

▲mono442 2 days ago | parent | prev | next [-]

if the ai is writing everything wouldn't it be better to choose a more popular language?

▲benzible a day ago | parent | next [-]

Another BEAM-based language, Elixir, came in first in a recent agentic coding study: https://dashbit.co/blog/why-elixir-best-language-for-ai

▲sczi a day ago | parent [-]

In that Tencent study less common languages got easier problems. Which explains why racket also performed suspiciously well in it. The authors recognize the problem themselves. I like elixir, but it's imo embarrassing how often elixir people cite that study despite it not actually supporting what they claim.

A much more recent and imo more realistic comparison of different languages with ai, is openai's study reimplementing sqlite in different languages: https://openai.com/index/low-resource-programming-languages/

That showed about what we expect, that popular languages like python, javascript, java, C#, etc do best, while less popular languages like Common Lisp, Ocaml, Zig, etc do slightly worse. But the difference is small enough I'd still just choose whatever language and ecosystem I know best that is appropriate for a project.

▲yladiz a day ago | parent | next [-]

I would definitely be skeptical of a study that finds using an LLM/agent to write sqlite in JS being better than writing in Zig, but it strongly depends on what “better” or “worse” mean.

▲sczi a day ago | parent [-]

It means how much of the sqlite test suite it passed. They were just measuring correctness, not performance or memory consumption, where of course Zig should win.

But the aim of that experiment was measuring correctness of llm written code in different languages, so used sqlite as a benchmark considering it's fairly complex software with a comprehensive test suite. It is not suggesting that because a language scores better on that benchmark it'd be better suited to writing the next sqlite, due to obvious other factors like performance...

▲ a day ago | parent [-]
[deleted]
▲ModernMech a day ago | parent | prev [-]

What they did is they gave the AI a huge pile of docs and said "implement this". But they didn't give the AI any tests as part of its objective. I was under the impression it's generally common practice to use a test-driven development approach with AI, so I think it would have been more representative for them to have split their test corpus in half: one half it could see during implementation, and then the could test on the other half.

Also, they restricted access from the internet, so I think this would have disadvantaged less popular languages.

▲ModernMech a day ago | parent | prev | next [-]

Exactly the opposite -- in a lot of ways, mainstream languages represent a compromise that gives the worst of all worlds for the benefit of popularity. With AI, you can take advantage of unpopular esoteric languages that have measurable advantages over mainstream languages. Before, the choice for a mainstream language was too strong because of network effects. Now with AI those effects don't matter as much, so being mainstream isn't as much of an advantage.

The copious training data on mainstream languages doesn't really translate as a network effect, and therefore is kind of a red herring because the AI can use all that training on new languages as well. e.g. if you use a esoteric language that is vaguely object oriented, the AI will use its vast training on object oriented programs and apply it to your language instead of falling over because your language isn't Python and it doesn't have training data on it.

Moreover, the AI is trained on copious amounts of PL research, so it's not like the ideas in a new language are completely new to it.

▲lpil a day ago | parent | prev | next [-]

Why's that?

▲tharmas a day ago | parent [-]

Lots and lots of production code to train AI models.

▲giancarlostoro a day ago | parent | next [-]

That mindset is a bit dated when models can pull up docs for a few years now. You can even have it write itself a little guide for lesser known languages within its own agents file.

▲lpil a day ago | parent | prev | next [-]

Programming models have been sophisticated enough for some time to not be restricted to specific languages. It's rather like the difference between a junior developer (who knows how to use a specific language) and a mid developer (who knows who to program generally).

▲jeremyjh a day ago | parent [-]

Thanks for creating Gleam!

Is there any research that supports what you are saying here? I agree it mostly works, but I’d expect more API hallucinations and test cycles at a minimum.

▲lpil 12 hours ago | parent [-]

No problem!

I don't have anything formal to share, but in my testing I've found it works much the same in all languages now.

▲perrygeo a day ago | parent | prev | next [-]

The entire gleam language tour fits comfortably in a modern LLM context window. You're one web search away from "training" it yourself.

▲ch4s3 a day ago | parent | prev [-]

I'm not sure how much that matters. I suspect and anecdotally hear/see that compiler errors and docs are as/more important.

▲gavmor a day ago | parent | prev [-]

Too much schlock in the manifold, IMHO.

▲hugeBirb a day ago | parent | prev [-]

What's the fuckin point of any language ergonomic if you're not reading or writing it.

▲jimbokun a day ago | parent [-]

More ergonomic languages burn fewer LLM tokens to get the same result.

▲dofm a day ago | parent [-]

Only if they gain that ergonomic advantage without complicating flow of control. Metaprogramming is costly for example, in the past so have been operator overloading and lazy evaluation.