Erlang/OTP 29.0
257 points
• 3 days ago
• Article
Link
Erlang/OTP 29.0 作为一次重大更新发布,带来了新特性、改进以及若干不兼容之处,整体聚焦于安全性、语言增强和系统性能优化。
安全性改进是本次版本的重点。 SSH 守护进程现在默认禁用 shell 和 exec 服务,遵循"默认安全"(secure by default)原则,除非显式配置,否则已认证用户无法执行任意 Erlang 代码。启动 SSH 守护进程时,SFTP 子系统也不再默认启用。在 SSL 中,后量子混合算法 x25519mlkem768 被列为默认配置中最优先的密钥交换组。 SSH 的默认密钥交换算法已更新为 mlkem768x25519-sha256,这是一种将 ML-KEM-768 与 X25519 结合的混合抗量子算法,通过自动回退机制在提供对经典与量子攻击的防护的同时保持向后兼容。
引入了多项语言层面的新特性。根据 EEP-79 描述的原生记录现已实现为独立的数据类型,而不再依赖传统的基于元组的记录,不过在本版本仍被视为实验性功能。新的 guard BIF `is_integer/3` 可用于方便地判断一个值是否为整数且处于指定范围内。根据 EEP-78 的多值推导式现已得到支持,启用 `compr_assign` 特性后,还可以在推导式中为变量赋值。新增的 `io_ansi` 模块允许发出虚拟终端序列(VT sequences),便于为文本添加颜色和样式或构建终端应用。
编译器和 JIT 也有显著改进。 JIT 在匹配或创建包含多个小端段的二进制时能生成更优的代码,编译器在处理与生成器无关的常量值映射推导式时生成了更高效的代码。 `compile` 模块的文档现在加入了对在 BEAM 上实现语言的开发者的建议。
若干新的编译器警告已默认启用,并提供可关闭的选项,涵盖使用已弃用的 `catch` 操作符、从子表达式导出变量、使用 `and`/`or` 操作符,以及一些可用更清晰写法的匹配模式。文档还指出,过时的 guard 测试将在 Erlang/OTP 30 中完全移除。
其他变更包括:STDLIB 中新增了用于随机排列列表的函数;新增 `ct_doctest` 模块以测试文档示例;`ignore_xref` 属性现在由 `xref` 本身处理,而不再作为事后过滤器。当前工作目录在默认代码路径中被放在最后一位,Windows 平台不再提供 32 位的 Erlang/OTP 构建。编译器默认会对调用已知不安全的函数生成警告,`xref` 现在可以用于查找对不安全函数以及缺少文档的函数的调用。
Erlang/OTP 29.0 has been released as a major update, bringing new features, improvements, and some incompatibilities. The release emphasizes security, language enhancements, and performance optimizations across the system.
Security improvements are a central focus of this release. The SSH daemon now defaults to disabling shell and exec services, following a "secure by default" principle that prevents authenticated users from executing arbitrary Erlang code unless explicitly configured. The SFTP subsystem is also no longer enabled by default when starting an SSH daemon. In SSL, the post-quantum hybrid algorithm x25519mlkem768 is now the most preferred key exchange group in the default configuration. The SSH default key exchange algorithm has been updated to mlkem768x25519-sha256, a hybrid quantum-resistant algorithm combining ML-KEM-768 with X25519, providing protection against both classical and quantum computer attacks while maintaining backward compatibility through automatic fallback.
Several new language features have been introduced. Native records, as described in EEP-79, are now implemented as a true data type rather than traditional tuple-based records, though they are considered experimental in this release. The new `is_integer/3` guard BIF allows easy verification that a value is both an integer and within a certain range. Multi-valued comprehensions according to EEP 78 are now supported, and with the `compr_assign` feature enabled, it is possible to bind variables within comprehensions. The module `io_ansi` has been added, allowing users to emit Virtual Terminal Sequences for adding colors and styling to text or creating terminal applications.
The compiler and JIT have received notable improvements. The JIT now generates better code for matching or creating binaries with multiple little-endian segments, and the compiler produces more efficient code for map comprehensions with constant values that don't depend on the generator. The documentation for the `compile` module now includes recommendations for implementors of languages running on the BEAM.
Several new compiler warnings are now enabled by default, each with options to disable them. These include warnings for using the deprecated `catch` operator, exporting variables out of subexpressions, using the `and` and `or` operators, and certain match patterns that could be written more clearly. The release also notes that obsolete guard tests will be removed entirely in Erlang/OTP 30.
Other changes include new functions for randomly permutating lists in the STDLIB module, the `ct_doctest` module for testing documentation examples, and the `ignore_xref` attribute now being handled by `xref` itself rather than as a post-analysis filter. The current working directory is now in the last position in the default code path, and there is no longer a 32-bit Erlang/OTP build for Windows. The compiler will by default generate warnings for calls to functions known to be unsafe, and `xref` can now be used to find calls to unsafe functions and functions lacking documentation.
61 comments • Comments Link
默认禁用 SSH 守护进程和 SFTP 是一项受欢迎的安全改进,践行了"安全默认"原则,可以防止在未明确配置时发生任意代码执行。
io_ansi 模块作为 stdlib 的有前景补充,填补了 Erlang CLI 应用开发的空白,其跨节点的 fwrite 功能尤其被看重。
Native Records 相较于传统记录有显著改进,可能会对 Elixir 的数据结构产生长期影响,但旧的记录机制并不太可能被完全废弃。
OTP(Open Telecom Platform)为构建高可靠、容错的应用提供了标准化的库和设计原则,虽然最初为电信场景而设计,但适用范围更广。
多方来源证实 WhatsApp 仍在使用 Erlang,公开代码库和近期会议演讲都支持这一点,同时 Rust 在与 Erlang 协同使用方面也在逐渐增多。
在 Erlang 27.3 中发现了多个严重和高风险的 CVE,这凸显了升级到 OTP 29 或其它生产环境中使用的最新版本的重要性。
与 Rails 和 Django 相比,Elixir/Phoenix 在生产环境中展现出明显优势,包括真正的并发性、更好的性能、通过 BEAM 和 OTP 提供的稳健性、内置的 KV 存储、分布式能力以及通过远程 shell 进行实时调试的便利。
Ecto 的数据映射器范式通过显式查询和 changesets 提供了更好的 SQL 对齐,并且设计上有助于避免 N+1 查询,这与 ActiveRecord 的有状态机制形成了对比。
BEAM 的并发模型可与 Go 的 goroutines 相媲美,但 Elixir 在并发编程的人机工程学方面更优,并且提供了 Go 中缺乏的一些生产调试能力。
开发者偏好各不相同:有人觉得 ActiveRecord 比 Ecto 更令人愉快,部署方式也有差异(比如 Capistrano 与 Elixir 构建),因此工具选择常常取决于具体用例和团队熟悉度。
总体讨论表明,人们高度评价 Erlang/OTP 在安全默认设置和增强 CLI 功能方面的改进。关于语言与框架的偏好仍有争论,Erlang 和 Elixir 的支持者强调生产可靠性、并发能力和显式设计模式,同时也承认不同工具适合不同领域。对话还强调了关注安全漏洞的现实问题以及保持软件版本更新的重要性,并对初始版本的稳定性持审慎态度。 • Disabling the SSH daemon and SFTP by default is a welcome security improvement, implementing a "secure by default" principle that prevents arbitrary code execution unless explicitly configured.
• The io_ansi module is a promising addition to the stdlib, addressing a gap in Erlang's CLI application development story, with seamless cross-node fwrite functionality being particularly appreciated.
• Native Records represent a substantial improvement over traditional records, with potential future implications for Elixir's data structures, though old records are unlikely to be deprecated entirely.
• OTP (Open Telecom Platform) provides standardized libraries and principles for building highly reliable, fault-tolerant applications, originally designed for telecom but applicable more broadly.
• Multiple sources confirm WhatsApp continues to use Erlang, with active public repositories and recent conference talks supporting this, though Rust is increasingly being adopted alongside it.
• Several critical and high-risk CVEs were found in Erlang 27.3, emphasizing the importance of upgrading to OTP 29 or the latest point release for production applications.
• Elixir/Phoenix offers significant production advantages over Rails and Django, including real concurrency, better performance, robustness through BEAM and OTP, built-in KV storage, distribution capabilities, and live debugging via remote shells.
• Ecto's data mapper approach with explicit queries and changesets provides better SQL alignment and prevents N+1 queries by design, contrasting with ActiveRecord's stateful mechanism.
• The BEAM's concurrency model is comparable to Go's goroutines, but Elixir offers superior ergonomics for concurrent operations and unique production debugging capabilities unavailable in Go.
• Development preferences vary, with some finding ActiveRecord more pleasant than Ecto, and deployment preferences differing between Capistrano and Elixir builds, highlighting that tool choice often depends on specific use cases and team familiarity.
The discussion reveals a strong appreciation for Erlang/OTP's security improvements and new features, particularly around secure defaults and enhanced CLI capabilities. There's ongoing debate about language preferences, with Erlang and Elixir advocates emphasizing production reliability, concurrency, and explicit design patterns, while acknowledging that different tools suit different domains. The conversation also highlights practical concerns around security vulnerabilities and the importance of staying current with releases, balanced against caution about initial release stability.