Hacker News new | ask | show | jobs
by mono442 22 days ago
if the ai is writing everything wouldn't it be better to choose a more popular language?
5 comments

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.

Another BEAM-based language, Elixir, came in first in a recent agentic coding study: https://dashbit.co/blog/why-elixir-best-language-for-ai
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.

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.

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.
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 more popular language like what? The more popular choice that I could think of was typescript and the world around typescript and javascript is so big and fragmented I think you'd end up with it the ai doing things in different ways in different places. Gleam is a smaller ecosystem but it also just feels better organized and more consistent which helps for keeping things consistent in your app.
Why's that?
Lots and lots of production code to train AI models.
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.
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).
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.

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.

The entire gleam language tour fits comfortably in a modern LLM context window. You're one web search away from "training" it yourself.
I'm not sure how much that matters. I suspect and anecdotally hear/see that compiler errors and docs are as/more important.
Too much schlock in the manifold, IMHO.