---
title: "Adam Tornhill 翻出了一个老问题：函数应该写多长？\n\nAI 模型理解代码的方式和人类不同。\n\n研究表明，命名对 AI 的理解能力影响极大。\n\n把有意义的变量名换成随机字符，模型表现会显著下..."
source_name: "向阳乔木(@vista8)"
original_url: "https://x.com/vista8/status/2050222575674925186"
canonical_url: "https://www.traeai.com/articles/b3119fc0-d1e9-45c1-b8e3-7014310aee5a"
content_type: "tweet"
language: "中文"
score: 7.8
tags: ["AI编程","代码可读性","软件工程","命名规范"]
published_at: "2026-05-01T14:35:27+00:00"
created_at: "2026-05-02T12:19:34.000426+00:00"
---

# Adam Tornhill 翻出了一个老问题：函数应该写多长？

AI 模型理解代码的方式和人类不同。

研究表明，命名对 AI 的理解能力影响极大。

把有意义的变量名换成随机字符，模型表现会显著下...

Canonical URL: https://www.traeai.com/articles/b3119fc0-d1e9-45c1-b8e3-7014310aee5a
Original source: https://x.com/vista8/status/2050222575674925186

## Summary

AI理解代码严重依赖变量名等字面特征，而非语义推断；函数长度不关键，用清晰命名表达意图才是人与AI共读代码的核心原则。

## Key Takeaways

- AI模型理解代码主要靠字面特征（如命名、结构），非语义推理
- 变量名有意义与否对AI性能影响显著，随机化命名会导致表现大幅下降
- 函数应以‘意图可读’为设计目标——命名即文档，而非追求固定行数

## Content

Title: 向阳乔木 on X: "Adam Tornhill 翻出了一个老问题：函数应该写多长？

AI 模型理解代码的方式和人类不同。

研究表明，命名对 AI 的理解能力影响极大。

把有意义的变量名换成随机字符，模型表现会显著下降。

AI 依赖的是字面特征，名字、结构、局部上下文，而不是推断出来的语义。

Fowler" / X

URL Source: http://x.com/vista8/status/2050222575674925186

Markdown Content:
# 向阳乔木 on X: "Adam Tornhill 翻出了一个老问题：函数应该写多长？ AI 模型理解代码的方式和人类不同。 研究表明，命名对 AI 的理解能力影响极大。 把有意义的变量名换成随机字符，模型表现会显著下降。 AI 依赖的是字面特征，名字、结构、局部上下文，而不是推断出来的语义。 Fowler" / X

Don’t miss what’s happening

People on X are the first to know.

[Log in](http://x.com/login)

[Sign up](http://x.com/i/flow/signup)

# [](http://x.com/)

## Post

See new posts

# Conversation

[![Image 1](https://pbs.twimg.com/profile_images/1960882043249942533/h4J39ERy_normal.jpg)](http://x.com/vista8)

[向阳乔木](http://x.com/vista8)

[@vista8](http://x.com/vista8)

Show translation

Adam Tornhill 翻出了一个老问题：函数应该写多长？ AI 模型理解代码的方式和人类不同。 研究表明，命名对 AI 的理解能力影响极大。 把有意义的变量名换成随机字符，模型表现会显著下降。 AI 依赖的是字面特征，名字、结构、局部上下文，而不是推断出来的语义。 Fowler 自己的观点是：函数长短本身不重要，重要的是意图和实现的分离。 如果你需要花时间去读一段代码才能理解它在做什么，那就应该把它提取成一个函数，用函数名说清楚"它在做什么"。 这个逻辑放在 AI 编程里同样成立。 原文还讨论了其他问题，都很有意思，推荐看

[](https://t.co/gSfIUBFzId)

[martinfowler.com Fragments: April 29 fragments 29 Apr 2026](https://t.co/gSfIUBFzId)

[2:35 PM · May 1, 2026](http://x.com/vista8/status/2050222575674925186)

·

[2,969 Views](http://x.com/vista8/status/2050222575674925186/analytics)

26

4

6

Read 26 replies

## New to X?

Sign up now to get your own personalized timeline!

Sign up with Apple

[Create account](http://x.com/i/flow/signup)

By signing up, you agree to the [Terms of Service](https://x.com/tos) and [Privacy Policy](https://x.com/privacy), including [Cookie Use.](https://help.x.com/rules-and-policies/twitter-cookies)

## Relevant people

*     [![Image 2](https://pbs.twimg.com/profile_images/1960882043249942533/h4J39ERy_normal.jpg)](http://x.com/vista8)       [向阳乔木](http://x.com/vista8) [@vista8](http://x.com/vista8)    Follow   Click to Follow vista8  喜欢摇滚乐、爱钓鱼的PM   

# Trending now

## What’s happening

UK national news · Trending

Princess Charlotte

Sports · Trending

Jaden McDaniels

Trending with [Nuggets](http://x.com/search?q=Nuggets&src=trend_click&vertical=trends)

Trending in United States

Championship Saturday

Trending in United States

Heavyweight

[Show more](http://x.com/explore/tabs/for-you)

[Terms of Service](https://x.com/tos)

|

[Privacy Policy](https://x.com/privacy)

|

[Cookie Policy](https://support.x.com/articles/20170514)

|

[Accessibility](https://help.x.com/resources/accessibility)

|

[Ads info](https://business.x.com/en/help/troubleshooting/how-twitter-ads-work.html?ref=web-twc-ao-gbl-adsinfo&utm_source=twc&utm_medium=web&utm_campaign=ao&utm_content=adsinfo)

|

More

© 2026 X Corp.
