# Declare：专为人类与AI设计的UI语言

Original title: Declare is a UI language for you and your AI

> Hacker News story 50622854 · language: zh · submitted 2026-11-24
> Web version: https://zeli.app/zh/story/50622854
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 55 · by [ilamont](<https://news.ycombinator.com/user?id=ilamont>) · 💬 43
[original](<https://davidtemkin.github.io/declarelang/>) · [HN discussion](<https://news.ycombinator.com/item?id=50622854>)

## Summary

Declare 是一种全新的 UI 语言，旨在让人类和 AI 协作构建可验证的界面。它不再依赖拼凑的库，而是将布局、动效和状态直接编码为语言本身。从 568 行代码实现的 Declare Calendar 到 3529 行的 Declare Desktop，所有应用均由 AI 生成但由编译器严格把关。相比 React，Declare 生成的代码更精简且一次性通过率更高。这种语言让 AI 不仅能写代码，还能通过形式化验证发现并修复错误，确保每一行代码都精准表达设计意图。

## Key quote

> 在 Declare 中，AI 不仅能编写代码，还能通过编译器验证并修正错误，确保应用逻辑始终正确。

## HN discussion (43 comments)

### [saidinesh5](<https://news.ycombinator.com/item?id=50624498>)

> 我觉得在描述 UI 方面，Qt/QML 对我来说真的达到了一个完美的平衡点（如果有任何语法错误请忽略，我是凭记忆写的）：
>
> 举个例子，对比一下：
>
> \`\`\`
>
> Window {
>
> textColor: "slategray"
>
> property int v: 40
>
> ColumnLayout {
>
> id: layout
>
> anchors.fill: parent
>
> spacing: 20
>
> Text {
>
> id: number
>
> Layout.alignment: Qt.AlignHCenter
>
> font.pixelSize: 70
>
> text: v
>
> }
>
> ProgressBar {
>
> id: progressBar
>
> Layout.alignment: Qt.AlignHCenter
>
> value: v/100
>
> color: v < 50 ? "dodgerblue" : "turquoise"
>
> }
>
> }
>
> MouseArea {
>
> anchors.fill: parent
>
> onClick: v = (v+20)%100
>
> }
>
> }
>
> \`\`\`
>
> 与 Declare：
>
> \`\`\`
>
> App [ textColor = slategray,
>
> group: View [ x = center, y = center, width = 80%,
>
> layout: SimpleLayout [ axis = y, spacing = 20 ],
>
> number: Text [ width = 100%, textAlign = center,
>
> fontSize = 70, fontWeight = bold, text = { "" + v } ],
>
> bar: Gauge [ width = 100%, value = { v },
>
> tint = { v < 50 ? cool : warm }, accessibilityLabel = "v" ],
>
> hint: Text [ width = 100%, textAlign = center,
>
> text = "click anywhere to change v" ]
>
> ],
>
> v: number = 40,
>
> cool: Color = dodgerblue,
>
> warm: Color = turquoise,
>
> onClick() { v = (v + 20) % 100 }
>
> ]
>
> \`\`\`

### [abrookewood](<https://news.ycombinator.com/item?id=50624469>)

> 这个 LLM 风格的语言让人很反感：“说你所想，分毫不差”，然后在代码注释里写“// 一个值 v，以及紧随其后的三个东西”。这种写法简直糟糕透顶。

### [samrus](<https://news.ycombinator.com/item?id=50624512>)

> 这里的“克劳德味”（claudish）过一会儿就让人看不下去了。这个项目的核心理念真的应该由人来写。很遗憾，因为看起来这本来是个很有趣的想法。

### [mtford](<https://news.ycombinator.com/item?id=50624171>)

> 初次接触的市场页面和核心文档应该由人来撰写。这听起来挺有意思，但一旦我嗅到了 AI 的味道，眼睛就立刻开始发直了……

### [skybrian](<https://news.ycombinator.com/item?id=50623917>)

> 这看起来做得相当不错。我有点犹豫要不要尝试，主要是因为网站上有太多营销风格的文案（很可能是 AI 生成的），我不确定自己是否想再读更多这类内容。
>
> 它应该在一开始就说明这是一个 npm 包，附带相应的工具，且输出结果在浏览器中运行。

---

## Cite

- Page: https://zeli.app/zh/story/50622854
- Date: 2026-11-24
- Source: davidtemkin.github.io (https://davidtemkin.github.io/declarelang/)
- Hacker News: https://news.ycombinator.com/item?id=50622854

## Other languages

- en: https://zeli.app/story/50622854 · markdown: https://zeli.app/story/50622854.md
- ja: https://zeli.app/ja/story/50622854 · markdown: https://zeli.app/ja/story/50622854.md
- ko: https://zeli.app/ko/story/50622854 · markdown: https://zeli.app/ko/story/50622854.md
- de: https://zeli.app/de/story/50622854 · markdown: https://zeli.app/de/story/50622854.md
- es: https://zeli.app/es/story/50622854 · markdown: https://zeli.app/es/story/50622854.md
- ru: https://zeli.app/ru/story/50622854 · markdown: https://zeli.app/ru/story/50622854.md
