问HN:我们是否需要一种专门为AI代码生成设计的编程语言?

1作者: baijum大约 2 个月前原帖
让我们进行一个思想实验。如果我们今天要设计一种新的编程语言,其主要目标是由人工智能(如Copilot)编写,并由人类进行审查,那么它的核心特性会是什么? 我最初的想法是,我们可能会为了绝对、明确的清晰度而放弃许多我们目前重视的便利性。例如: - 我们会去掉大多数语法糖吗?如果只有一种明确的方式来编写`for`循环,那么人工智能的输出将变得更加可预测,也更容易审查。 - 我们会强制要求极端的明确性吗?想象一下,如果没有参数,你必须写`fn foo(none)`,仅仅是为了消除`()`的模糊性。 - 我们将如何处理安全性?像强制可见性(`pub`/`priv`)和FFI调用的显式所有权注解这样的特性,会不会成为语言本身的核心,提供审查者可以立即看到的保证? - 这样一种语言是否能被人类用于日常工作,还是仅仅作为人工智能提示的编译目标? 为了获得对人工智能生成的代码更高的信心,你愿意为这种语言做出哪些权衡?
查看原文
Let&#x27;s run a thought experiment. If we were to design a new programming language today with the primary goal of it being written by an AI (like Copilot) and reviewed by a human, what would its core features be?<p>My initial thoughts are that we would trade many of the conveniences we currently value for absolute, unambiguous clarity. For example:<p>- Would we get rid of most syntactic sugar? If there&#x27;s only one, explicit way to write a `for` loop, the AI&#x27;s output becomes more predictable and easier to review.<p>- Would we enforce extreme explicitness? Imagine a language where you <i>must</i> write `fn foo(none)` if there are no parameters, just to remove the ambiguity of `()`.<p>- How would we handle safety? Would features like mandatory visibility (`pub`&#x2F;`priv`) and explicit ownership annotations for FFI calls become central to the language itself, providing guarantees the reviewer can see instantly?<p>- Would such a language even be usable by humans for day-to-day work, or would it purely be a compilation target for AI prompts?<p>What trade-offs would you be willing to make for a language that gave you higher confidence in the code an AI generates?