Live data from Hacker News

A case for Go as the best language for AI agents

getbruin.com

61–70 of 310 posts

Re: A case for Go as the best language for AI agents

#61
I have let Gemini, Claude Code and Codex hallucinate the language they wanted to for a few days. I prompted for "design the language you'd like to program in" and kept prompting "go ahead". Just rescued it from a couple too deep rabbit holes or asked it for some particular examples to stress it a bit.

It´s a weird-ass Forth-like but with a strong type system, contracts, native testing, fuzz testing, and a constraint solver for integer math backed by z3. Interpreter implemented in Elixir.

In about 150 commits, everything it has done has always worked without runtime errors, both the Elixir interpreter and the examples in the hallucinated language, some of them non-trivial for a week old language (json parser, DB backed TODO web app).

It´s a deranged experiment, but on the other hand seems to confirm that "compile" time analysis plus extensive testing facilities do help LLM agents a lot, even for a weird language that they have to write just from in-context reference.

Don´t click if you value your sanity, the only human generated thing there is the About blurb:

https://github.com/cairnlang/Cairn

Re: A case for Go as the best language for AI agents

#62
post #5

I think the more you can shift to compile time the better when it comes to agents. Go is therefore 'ok', but the type system isn't as useful as other options. I would say Rust is quite good for just letting something churn through compiler errors until it works, and then you're unlikely to get runtime errors. I haven't tried Haskell, but I assume that's even better.

Haskell works pretty well with agents, particularly when the agent is LSP-capable and you set up haskell-language-server. Even less capable models do well with this combo. Without LSP works fine but the fast feedback loop after each edit really accelerates agents while the intent is still fresh in context

Re: A case for Go as the best language for AI agents

#63
post #55

Earlier quoted context omitted.

Exactly. Here's my experience using LLMs to produce code: - Rust: nearly universally compiles and runs without fault. - Python,JS: very often will run for some time and then crash The reason I think is type safety and the richness of the compiler errors and warnings. Rust is absolutely king here.

[flagged]

What will you use for dependent types, Idris 2? Lean? None are as popular as Rust especially counting the number of production level packages available.

Re: A case for Go as the best language for AI agents

#64
post #38

Earlier quoted context omitted.

I am guessing there is a balance between a language that has a lot of soundness checks (like Rust) and a language that has a ton of example code to train on (like Python). How much more valuable each aspect is I am not sure.

Rust is the best language for AI: - Rust code generates absolutely perfectly in Claude Code. - Rust code will run without GC. You get that for free. - Rust code has a low defect rate per LOC, at least measured by humans. Google gave a talk on this. The sum types + match and destructure make error handling ergonomic and more or less required by idiomatic code, which the LLM will generate. I'd certainly pick Rust or Go…

https://arxiv.org/abs/2508.09101

In this benchmark, models can correctly solve Rust problems 61% on first pass — A far cry from other languages such as C# (88%) or Elixir (a “buggy dynamic language”) where they perform best (97%).

I wonder why that is, it’s quite surprising. Obviously details of their benchmark design matter, but this study doesn’t support your claims.

Re: A case for Go as the best language for AI agents

#65
post #5

I think the more you can shift to compile time the better when it comes to agents. Go is therefore 'ok', but the type system isn't as useful as other options. I would say Rust is quite good for just letting something churn through compiler errors until it works, and then you're unlikely to get runtime errors. I haven't tried Haskell, but I assume that's even better.

I built an agent with Go for the exact reasons laid out in the article, but did consider Rust. I would prefer it to be Rust actually. But the #1 reason I chose Go is token efficiency. My intuitive sense was that the LLM would have to spent a lot of time reasoning about lifetimes, interpreting and fixing compiler warnings, etc.

"LLM would have to spend a lot of time reasoning about lifetimes"

Let's set aside the fact that Go is a garbage collected language while Rust is not for now...

Do you prefer to let LLM reason about lifetimes, or debugging subtle errors yourself at runtime, like what happens with C++?

People who are familiar with the C++ safety discussion understand that lifetimes are like types -- they are part of the code and are just as important as the real logic. You cannot be ambiguous about lifetimes yet be crystal clear about the program's intended behavior.

Re: A case for Go as the best language for AI agents

#66

Earlier quoted context omitted.

Haskell is great, for what it's worth, but as with any language you have to reign in the AI's use of excessive verbosity. It will stack abstractions to the moon even for simple projects, and haskell's strengths for humans in this regard are weaknesses for AI - different weaknesses than other languages, but still, TANSTAAFL I am trying out building a toy language hosted on Haskell and it's been a nice combo - the toy…

> Haskell is great, for what it's worth, but as with any language you have to reign in the AI's use of excessive verbosity. It will stack abstractions to the moon even for simple projects, and haskell's strengths for humans in this regard are weaknesses for AI - different weaknesses than other languages, but still, TANSTAAFL I haven't had this problem with Opus 4.5+ and Haskell. In fact, I get the opposite problem an…

I guess it might be something with the subject matter and how I'm prompting. I prefer somewhat more imperative haskell though so that's probably a taste thing.

Re: A case for Go as the best language for AI agents

#67
post #5

I think the more you can shift to compile time the better when it comes to agents. Go is therefore 'ok', but the type system isn't as useful as other options. I would say Rust is quite good for just letting something churn through compiler errors until it works, and then you're unlikely to get runtime errors. I haven't tried Haskell, but I assume that's even better.

What about SPARK? Not enough training data?

Re: A case for Go as the best language for AI agents

#68

> I have worked with PHP, Go, JavaScript, and Python in a professional capacity for over 10 years now. Well if it's a choice between these 4, then sure. Not sure that really suffices to qualify Go as "the" best language for agents

Yeah, only one of these is a compiled language.

Re: A case for Go as the best language for AI agents

#69
post #60
post #5

I think the more you can shift to compile time the better when it comes to agents. Go is therefore 'ok', but the type system isn't as useful as other options. I would say Rust is quite good for just letting something churn through compiler errors until it works, and then you're unlikely to get runtime errors. I haven't tried Haskell, but I assume that's even better.

Was asking on mastodon if people tried leveraging very concise and high level languages like haskell, prolog with 2025 llms.. I'm really really curious.

the problem there might be limited training data?

Re: A case for Go as the best language for AI agents

#70

I have let Gemini, Claude Code and Codex hallucinate the language they wanted to for a few days. I prompted for "design the language you'd like to program in" and kept prompting "go ahead". Just rescued it from a couple too deep rabbit holes or asked it for some particular examples to stress it a bit. It´s a weird-ass Forth-like but with a strong type system, contracts, native testing, fuzz testing, and a constraint…

Have you asked them to compile it to BEAM bytecode directly?
Post reply on HN