←新闻详情

DevClass更新于 10月21日 22:36

Go v1.27 发布:泛型支持方法,但可读性争议再起

Go updates may delight diehard gophers but displease AI overlords

AI 导读

Go 语言发布 v1.27,将泛型支持扩展到方法,并允许直接为嵌套或嵌入字段赋值、在切片字面量等场景中自动推断类型参数。泛型自 2022 年 v1.18 引入,此次更新可减少重复代码,但批评者认为抽象层增加会损害 Go 一贯的可读性,对需要审查和维护代码的 AI 智能体尤为不利。

正文

当前显示原文,中文全文译文尚未就绪。

DEVOPS

The keepers of the Go programming language on Wednesday released the latest version, v1.27, and with it come considerable advances in generics.

In a nutshell, generics allow developers to write logic where data types are treated as variables, eliminating the need to rewrite (or copy and paste) a separate method for each different data type (int, string, floating point, etc.). It was "absolutely barbaric," noted one YouTube tutorial creator.

Go introduced generics for both functions and custom data types in version 1.18, released in 2022.

The v1.27 release expands generics to support methods, which are basically just functions that are bound to a data type. These new generics will save a lot of typing, at least if the programmer has some chops.

Golang’s standard random number generator, for example, can produce either a 32-bit integer (int32), 64-bit integer (int64) or whatever integer size the CPU expects (int). Prior to v1.27’s generics, the developer would have to write a method separately to support each numerical data type they wanted to use.

Beyond generics, v1.27 allows developers to more easily work with structs, which are composites that collect different data types within a single object. Now, they can set values for nested or embedded fields directly without specifying all the intermediate steps to reach them. This will save time when working with deeply nested structs.

This release also gets smarter in its ability to infer data types from functions without the developer explicitly typing them out. Previously, Go required explicit type arguments whenever a generic function was passed into a slice literal, channel send, or type conversion.

Save a keystroke, break a brain

Go continues to evolve into a programming language capable of tackling tasks as sophisticated as building the new TypeScript language server, but some wonder if it’s losing its approachable charm along the way.

Generics and these other time-saving features will come as a relief to the busy Gopher who grows weary of how much identical code they’re typing. But these language shortcuts also make the code on the screen more abstract, which has its own mental overhead.

When Google engineers Rob Pike, Robert Griesemer, and Ken Thompson created Go, first released in 2009, they prioritized readability over writability.

The designers “recognized that developers spend far more time reading existing code than they do typing it out,” wrote Google Group Product Manager Cameron Balahan and Google Cloud Chief Evangelist Richard Seroter in a blog post earlier this month.

Generics and other keystroke-saving measures will create more indirection that can confuse someone trying to understand what the code is doing, others have argued.

Generics will “make every code base entirely different,” complained the popular YouTube tech commentator (and former Netflix engineer) known as ThePrimeagen (Michael Paulson).

“You're going to jump into code bases and have no idea how they work. You're gonna have to go through layers of abstraction and whole new ways in which to express things, which is just gonna be like every other language, just without all the conveniences.”

Go’s value is in its simplicity. Adopting higher-level constructs makes it more of a C++ or Rust imitator, he said.

“Generics aren’t needed in most of practical Go code,” observed VictoriaMetrics founder Aliaksandr Valialkin in a 2024 Medium post. The downside of these new features is that they make it “harder to understand what’s going on by just reading the code.”

Think of the agents

And for AI agents, Golang’s easy readability is more than just a personal preference; it’s critical to staying on target.

“When code generation is offloaded to AI, the primary bottleneck of software engineering shifts entirely from the speed of writing to the rigor of reviewing, verifying, and maintaining,” the Google execs wrote. The more complicated the language, the more work it’ll take agents to understand.

Syntactic magic like generics helps seasoned programmers save coding time, but does it bring any value when agents write all the code? Would learning generics contribute to an agent’s cognitive overhead (possibly leading to context rot) when writing a random number generator method for each data type takes a second or two, and is easier to debug?

It’s a question that the maintainers of Go, like those of every other language, will be facing.

When you just need to build a tiny desktop app: TinyJS

October 13, 2026

Valen creator drives 'Golden Spike' to connect new languages with Rust

September 26, 2026

Microsoft agentically ports Copilot runtime to Rust for $120K

September 19, 2026

Apple iPhone Duo makes developers think in folds

September 16, 2026

JavaScript installer pnpm recast in Rust because ECMAScript can't keep up

September 5, 2026

Kubernetes cleans house, bins legacy kube-dns, IPVS, and cgroup v1

August 27, 2026

How Cursor beat Git's scalability shortcomings

August 24, 2026

Go updates may delight diehard gophers but displease AI overlords

August 21, 2026

SvelteKit 3 puts heat on Next.js with radical approach to RPCs

August 20, 2026

Almost nobody pays attention to web standards anymore

August 18, 2026

ChainDrop worm crawls into npm supply chain, evades standard defenses

August 16, 2026

Node.js creator liberates Durable Objects from Cloudflare

August 13, 2026

AI titans to tidy agent frontier with plugin prescription

August 8, 2026

Platform Engineering 2.0: your platform was built for a different era. AI just exposed it

August 6, 2026

Next.js 16.3 aims to reduce dreaded FATAL ERROR messages

August 5, 2026

Dev who gave HashiCorp its name returns with a faster terminal multiplexer

August 1, 2026

How AI drove Shopify back to clean code

Turns out, agents just want the same things as humans: easily-readable code, explicit contracts, and helpful feedback

July 26, 2026

Zig creator calls Bun's Claude Rust rewrite 'unreviewed slop'

July 15, 2026

HTTP gets a QUERY method so complex searches can stop pretending to be POST

July 14, 2026

Speedier type checks in TypeScript 7.0 as first stable Go release ships

July 10, 2026

GitHub cuts short offer to burn repos on CD after mockery ensues

A purported jab of Sony's physical media phase-out blows up on GitHub itself

July 7, 2026

.NET's long term support is not long term enough, dev complains

June 30, 2026

来源

DevClass