首页›Brett Cannon›文章

My impressions of Gleam

Brett Cannon · 2025年1月23日

AI 摘要 AI 生成,可能有误

作者分享了对 Gleam 的积极印象——这是一门小型、带类型的函数式语言,作者花了两天时间学会它,并用 Lustre 框架构建了一个客户端编程字体锦标赛网站。他们欣赏 Gleam 友好的社区、紧凑的设计以及可同时编译为 Erlang 和 JavaScript 的能力,不过也遇到了一些小烦恼,比如花括号语法,以及必须把记录类型名称写两次。尽管一个名为 CodingFont 的类似项目已经存在,因此他们没有上线自己的网站,但作者对 Gleam 依然感到满意,并期待未来的 WebAssembly/WASI 和 Python 后端。

When I was about to go on paternity leave, the Gleam programming language reached 1.0. It's such a small language that I was able to learn it over the span of two days. I tried to use it to convert a GitHub Action from JavaScript to Gleam, but I ran into issues due to Gleam wanting to be the top of the language stack instead of the bottom. As such I ended up learning and using ReScript. But I still liked Gleam and wanted to try writing something in it, so over the winter holidays I did another project with it from scratch.

Why Gleam?

First and foremost, their statement about community on their homepage spoke to me:

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Brett Cannon

What's missing to have reproducible builds on PyPI

AI 摘要The article argues that reproducible builds would strengthen Python's secure supply chain by allowing third parties to verify that distributions match their source code and detect tampering, citing SolarWinds as an example. What's missing includes recording the source code location in distribution metadata and support for software bills of materials (SBOMs) in sdists, which—unlike wheels—lack a place to store such data, though build backends could theoretically record build environments automatically without extra effort from distribution producers. The author also proposes that trusted verifiers could report successful reproductions to PyPI so users could see when a distribution was independently verified, framed as a perk rather than a requirement.

My nomination statement for the 2026 Python packaging council

AI 摘要The author announces his self-nomination for the inaugural 2026 Python Packaging Council (PPC), with support from his employer Microsoft but no employer pressure. He cites his qualifications, including over 23 years as a Python core developer, service on the first five Python Steering Councils, co-maintaining the packaging project, and authoring seven packaging PEPs such as PEP 518 and PEP 751. His goals for the PPC include drawing on his steering council experience to establish the new body, improving the developer experience for both package producers and consumers, and strengthening the secure supply chain through reproducible builds and software bills of materials (SBOMs).

How to publish to PyPI using GitHub Actions securely

AI 摘要The article outlines three relatively painless steps for securely publishing to PyPI with GitHub Actions: using the zizmor tool to fix insecure workflow defaults (broad token permissions, persisted credentials, and unpinned actions) both locally and in CI, and adopting Trusted Publishing with a GitHub environment that requires reviewer approval before any publishing workflow runs. The author stresses that the post is not meant to shame maintainers into using GitHub Actions or Trusted Publishing, and recommends keeping build and publish workflows separate. Together, these measures guard against accidental or malicious workflow triggers while letting GitHub's security team handle the PyPI communication concerns.

Why I wrote PEP 832 -- virtual environment discovery

AI 摘要The article explains why the author wrote PEP 832, addressing the problem that tools like VS Code (or any editor or AI agent) cannot easily determine which workflow tool a Python project uses or where its virtual environments are located. It outlines key difficulties—such as discovering environments on first project open, handling environments stored outside the project or shared across projects via tools like conda—and proposes solutions including detecting .venv directories, a .python-envs file listing environment paths, and a [workflow] table in pyproject.toml paired with a workflow server protocol (WSP) for JSON-RPC communication between tools. The author's motivation is to make project setup as easy as possible for users of all experience levels by hiding environment management, while creating a general, editor-agnostic standard rather than the VS Code-specific bespoke integrations that exist today.

Why pylock.toml includes digital attestations

AI 摘要The article explains that a Python project hack involving malicious PyPI uploads could have been detected if the project used trusted publishing with digital attestations, since pylock.toml lock files record publisher details (e.g., the GitHub repo and workflow) for each file. Trusted publishing lets CD systems upload releases without exposing API keys, while attestations verify a file's origin, allowing users to compare the lock file's recorded publisher against PyPI's data to spot discrepancies. The author recommends that maintainers enable trusted publishing and attestations, and that users verify attestations in lock files via code or manual review of diffs to catch suspicious changes or deletions.