Go作为AI智能体最佳语言的理由
A case for Go as the best language for AI agents

原始链接: https://getbruin.com/blog/go-is-the-best-language-for-agents/

## Go:人工智能代理时代的理想语言 作者在8年的专业Go开发经验后认为,Go在新兴的人工智能驱动软件创建领域中具有独特的优势。最初选择Go用于Bruin,一个开源ETL工具,是基于其性能、并发性和个人喜好,但随着人工智能代理的兴起,他们发现了意想不到的优势。 Go的编译特性和强类型系统允许代理生成更可靠的*正确*代码,从而最大限度地减少基本错误。它的简单性——比Rust更容易学习,并且具有标准化的工具生态系统(与JavaScript不同)——使代理能够生成惯用、易于理解的代码,并快速迭代测试和格式化。 此外,Go的跨平台支持对于在不受控制的环境中部署的工具至关重要,允许代理跨操作系统快速验证更改。作者指出,目前代理生成的Go代码具有惊人的有效性,这可能归因于Go的一致风格和与Python等语言相比更少的实现变体。 最终,Go的易用性、性能和标准化相结合,使开发人员和人工智能代理能够高效地构建和交付软件,使其成为未来人工智能辅助开发的首选语言的有力竞争者。

## Go 作为 AI 代理的最佳语言:总结 一则 Hacker News 讨论集中在 Go 是否是开发 AI 代理的理想语言。原始帖子认为 Go 的简洁性、编译性和意见性使其非常适合代理生成的代码。 许多评论者表示同意,强调 Go 比 Rust 等语言具有更快的编译时间和更少的样板代码,后者虽然提供了更强的类型安全,但对于 LLM 来说可能更冗长和复杂。 几位用户指出 Go 庞大的现有代码库为 AI 模型提供了充足的训练数据。 然而,也有人支持 Rust,因为它具有强大的错误处理和类型系统,或者支持 Haskell 和 OCaml 等语言,因为它们具有函数式纯度和强类型。 尽管存在潜在的运行时问题,Python 也因其广泛使用和丰富的库而受到支持。 一个关键点是迭代速度(编译/测试周期)至关重要,而 Go 在这方面表现出色。 最终,讨论表明,虽然 Go 提出了一个强有力的论点,但“最佳”语言取决于具体需求和所使用的 AI 模型的 capabilities。 有些人甚至质疑如果代码生成变得足够高效,语言本身的重要性。
相关文章

原文

I have been working with Go for the past 8 years in a professional capacity. I’d like to make a case here about why Go is the best language to work with using AI agents.

I have worked with PHP, Go, JavaScript, and Python in a professional capacity for over 10 years now. Most of my career has been building web services, and I have been building Bruin over the past few years, which is primarily a CLI tool written in Go.

Bruin is an open-source ETL tool, and as some of you might know, the data ecosystem loves (or used to love?) building tools in Python. There are a ton of available libraries, data people are familiar with Python, so it is easier to get contributions, and it is easy to find Python developers compared to Go. When we started building Bruin, we had to make a decision: do we build the CLI in Go or do we build it in Python?

We had a few constraints that we needed to take into account before we made a decision:

  • Bruin is a data orchestration tool, which means there’ll be a lot of stuff that needs to run concurrently.
  • Bruin needs to interact with a lot of different systems, such as language runtimes or external APIs for data platforms; therefore, we need a decent ecosystem around the language.
  • Bruin needs to be fast. It is a CLI tool, and we wanted to use it with various systems, such as VS Code extensions or local UIs as a backend, and it needed to have sufficient performance.
  • Bruin needs to have predictable error handling paths for all the different systems it has to integrate with, and inform the user explicitly.
  • Bruin will run on users’ machines, which means it should be easy to support various operating systems and architectures.

On top of all these constraints, there was a more subjective constraint as well: I would be the primary contributor for quite some time, and it had to be a language I enjoyed working with. Joy and energy is one of the rarest resources a small team can have when building large projects, and I felt it was crucial that I did not dread the tech stack we used.

In the end, we decided to go with Go. It ticked a lot of the boxes, and while having some drawbacks, such as a lack of libraries for certain data-related tasks compared to Python, it fulfilled the most important requirement: I seriously enjoyed working with Go. This joy allowed me to contribute thousands of lines of code before agents were a thing, and it kept us going for quite some time. Part of me was scared that I made a strategic mistake by choosing Go since we had to build quite a lot of stuff from scratch; however, my intuition told me that the speed and DX advantages of Go over Python would bring us further advantages in the long run.

I had absolutely no idea that agents would become a thing, but I believe our intuition put us in a pretty lucky spot when agents became a thing. I’d like to touch on some of the advantages of Go when it comes to working with AI agents to write software, and why I believe Go is the best language today for agents.

Agents spit out tons of lines of code. Whether or not you call them intelligent in that regard, they produce very believable code, code that usually looks correct. That’s where the first challenge starts: how do we make sure the code they produce works?

One of the easiest ways of ensuring that is by using a compiled language. Strong typing, static typing, whatever, I always mix them up, which allows AI agents to iterate on the code they produce until it is correct to a certain extent. This does not mean that the code does what it is supposed to do, it just means that the code is exempt of certain subset of bugs with regard to using the wrong types or arguments. The code that compiles gives you the guarantee that, as far as the language standards go, the code that has been generated is syntactically correct.

While compiled languages have been around for a very long time, there are not many high-level programming languages like Go out there. There is Rust, obviously, which has very different dynamics and target usecases than Go, and I believe Go wins over Rust for an AI agent:

  • Go’s syntax and concepts are simpler than Rust's.
  • Go’s type system is not as sophisticated as Rust, allowing the generated code to be closer to a shared idiomatic way of writing code and simpler to understand for humans.
  • Go compiles faster than Rust, enabling a faster feedback loop for AI agents.
  • There are far more Go code out there than Rust, allowing models to generate better code in Go than Rust.

This is more of an intuitive thought than backed by real data, happy to be corrected here. While there are many more compiled languages, in terms of ease of use, community, speed of iteration, and simplicity, Go definitely becomes a clear top player there.

Maybe this should have been at the top? Anyway. Go is a very simple language. If you have any proficiency in any programming language, reading Go code should be trivial to you. You can immediately understand what the code does and reason about it. This means that if your agent generates a ton of Go code, you'll still be fine.

Another advantage here is understanding the design choices: while agents are able to generate very good code, they sometimes jump into weird design decisions and continue down the rabbit hole. The simplicity of the language helps a lot here to figure out where the agent is moving towards.

With that being said, I am a strong believer that we are not going to read code much in 12 months, and therefore could also make the argument that readability or simplicity won't matter much in the future, which could be true. Even in that case, I'd still like to be able to jump around the code if I ever wanted to.

This is one of the things I love about Go: it is an opinionated language with clear guidelines and tooling to support that. There is a standard way of running tests, formatting code, or building binaries. Go, even though it is hated by many, also has a particular way to deal with errors. Like it or not, it certainly advertises a way of doing things that makes it easier to write idiomatic Go that can be worked on by many people and agents.

Take JavaScript, for instance: there are a billion different ways of doing things. Every time I hop on a JS project, I have to discover the tools they use, learn how they work, and try to familiarize myself before I can be productive in it. Everyone has different opinions around how to format code, how to distribute packages, or even how to import libraries into a script. I find the state of JS to be a hot mess, to be frank, but I am digressing.

Go avoiding these problems surfaces a significant advantage for AI-generated code: the models know how to work with Go based on all the code they saw in their training data. Go code is generally very similar to each other, and the standardized tooling allows agents to use them effectively.

Ask an agent to format a JS code, and it’ll import a new tool and try to make it work. Ask it to do the same with a Go codebase, and it’ll just run gofmt and be done with it. The same goes for writing unit tests or building binaries.

I don’t think this would resonate with you much if you are writing software that just runs in a specific environment, but if you write things like CLI tools that you have no control over where they run, then Go becomes the perfect choice. This point holds regardless of the AI stuff, but I think there’s an interesting effect of this with AI agents.

Cross-platform support being a first-class citizen in Go means that running all of our tests, be it unit or integration tests, across environments, on every change, becomes trivial.

You know what this means?

You guessed right: this means AI agents can validate their work quickly and ensure they didn’t break any existing functionality. Obviously, this is not a win on its own if you are not writing tests, but the fact that you have the ability to just throw the same commands on another OS and validate the code is big.

Background agents & Go

Like many others, we have been experimenting with background agents as much as we can. Be it triggering Cursor to tackle a change via a Slack message or handing off a local session to a remote one, we slowly decouple ourselves from having tight control over the environment in which our code is being built and run.

This is a small one, but Go’s cross-platform advantages shine here as well: the same code will produce binaries that run on Linux, Windows, or macOS the same way, and the whole process of working with Go code is standardized across environments. This means I don’t care where different agent platforms run in or if a sandbox provider can handle our dev dependencies; everything just works.

This is likely one of the advantages that would go away over time as well, but as of early 2026, agents produce valid Go in one shot 95% of the time in my experience. I have absolutely no data whatsoever on this, although I struggle a lot more with Python than Go. Models know the libraries, patterns, and best practices in such a way that it becomes almost trivial to build a feature in Go once the direction is settled.

I think part of this is not that there is a lot of training data for Go; if that were the case, Python would have definitely won that. There's usually a single way of doing things in Go, whereas there are 20 different ways of doing the same thing in Python. If we said training data in Go vs Python, Python would win, but in practice, it seems more like training data in Go vs training data in Python for this particular library, and there Go wins.

I bet this advantage will disappear over time, if it hasn't happened already, due to models getting better and training data including more and more examples of other languages, such as Rust, and I definitely lack the evidence to support my claims here; therefore, treat this more as vibes.

I believe programming languages are going through a weird phase where a lot of the stuff we cared about in the past doesn't seem to matter anymore. It seems like humans will write less and less code by hand, and we'll need systems that empower agents to do that well.

I think by pure luck, Go might have landed in a sweet spot of usability, performance, and ubiquity that makes it a very good fit for agents. They write beautiful Go, they run, compile, test, format, and deliver performant software in Go that can be used across a variety of machines. All of these benefits are already available today to anyone who wants to build new tooling: just tell Claude Code to build you a CLI in Go, sit back, and enjoy the result.

Go has given us a lot of power at Bruin recently, thanks to these benefits, and we are doubling down on it. Is Go gonna be the programming language for agents? I don't know. Will there be better languages that are more suitable for agents? I don't know. All I know is that I am productive, my team is productive, and we deliver decent software very fast. And more importantly, I still do enjoy working with Go quite a lot, even with agents.

联系我们 contact @ memedata.com