Crystal 1.22.0 已发布
Crystal 1.22

原始链接: https://crystal-lang.org/2026/10/12/1.22.0-released/

Crystal 1.22.0 发布,包含 33 位贡献者的 251 项变更。亮点:写入 STDOUT/STDERR 时遇 EPIPE 默认立即退出,可选择退出;常量可声明类型;aarch64 Linux 目标成为 Tier 1;移除 Process.fork;新增编译时文本宏;Crystal 标志通过常量暴露;DWARF 解析更快且内存占用更低;HTTP 获得多项改进与修复;所有目标默认使用原生事件循环;OpenSSL 默认启用 Kernel TLS;File.exists? 和 File::Info 权限检查新增 follow_symlinks 选项;新增 Char::Reader.new(Bytes)、Time::Span 转换方法和 GC.syscall;静态 PIE 回溯修复;支持大写实例/类变量;支持 LLVM 23.1/24.0;更新 markd;提供 aarch64 Windows 构建;构建需要 stage-0 编译器 1.14 或更高版本。感谢赞助者与贡献者。

Hacker News 上关于 Crystal 1.22 的讨论凸显了一门小众但受人敬佩的语言:Ruby 风格语法,具备静态类型和基于 LLVM 的原生性能。用户称赞其表现力、面向对象编程、宏、C 互操作、轻量级纤程以及 CLI/服务器用途;一位 Crystal 核心开发者提到用于并行的执行上下文和 aarch64 Linux 的 Tier 1 支持。一些生产用户指出运行时/异常问题,而另一些人则成功用于长期运行的服务和内部工具。批评者质疑其相关性、Ruby 兼容性、生态系统成熟度,以及是否具备独特优势;对比上,Go 在并行/库方面占优,TruffleRuby 在 Ruby 兼容性方面占优,Elixir 在 REPL 方面占优。Windows 支持较新但正在改进。一个更广泛的主题是,LLM 可能降低学习语言的动力,但有人认为理解代码仍然有价值。总体而言,Crystal 被视为精致但小众,若生态系统和运行时稳健性提升则有潜力。
相关文章

原文

We are announcing a new Crystal release 1.22.0 with several new features and bug fixes.

Pre-built packages are available on GitHub Releases and our official distribution channels. See crystal-lang.org/install for installation instructions.

This release includes 251 changes since 1.21.1 by 33 contributors. We thank all the contributors for all the effort put into improving the language! ❤️

Below we list the most remarkable changes in the language, compiler, and stdlib. For more details, visit the full changelog.

Crystal processes exit immediately when writing to STDOUT or STDERR fails with EPIPE. This closely resembles the default behaviour of the SIGPIPE signal. Previously, the failing write would raise IO::Error, which typically prints an error message and exits. This error message is now removed (#17335).

You can opt out of this behaviour with STDOUT.exit_on_broken_pipe = false.

Thanks, @straight-shoota

Constants can have type declarations (#16951). They work exactly as you would expect the combination of constants and type declarations to be.

module Foo
  BAR : Int32 = 1
  BAZ : String = ""
  QUX : Int64 = 123 # autocasts 123 to Int64
end

Thanks, @stakach

The targets aarch64-linux-gnu and aarch64-linux-musl moved from Tier 2 to Tier 1. The only missing piece was that we were lacking official builds, but we have that since 1.19.

Process.fork had been deprecated sine before 1.0 and now we finally removed it (#17367)

Thanks, @straight-shoota

  • New macros enable more text operations at compile time: StringLiteral#bytesize (#17176), NumberLiteral#chr (#17169) and RangeLiteral#each supports CharLiteral (#17170)

Thanks, @straight-shoota

New constants Crystal::ALL_FLAGS and Crystal::USER_FLAGS provide access to the compile time flags (#17392).

Thanks, @straight-shoota

We completely revamped DWARF parsing to enhance performance and reduce memory usage. The DWARF parser now scans sections on demand (#17283) and builds an efficient index table once (#17410, #17455), which results in blazingly fast look ups. Decoded backtrace lines are cached in an LRU cache (#17285).

Also added aupport for DWARF 5 features DW_FORM_addrx<n> and DW_FORM_strx<n> (#17445).

Thanks, @ysbaddaden

We merged numerous improvements and bug fixes for HTTP.

  • #remote_address and #local_address moved from HTTP::Request to HTTP::Context (#17196)
  • Add HTTP::Headers#merge (#17326)
  • Serialize IO::Memory in HTTP body with Content-Length header (#17388)

Bug fixes:

  • Reject unrecognized HTTP Transfer-Encoding header (#17140), invalid Content-Encoding (#17262), and invalid HTTP trailer (#17337)
  • [breaking] Fix the return values of HTTP::Request#body= and #content_length= (#17257, #17273)
  • Fix HTTP.parse_headers_and_body to not raise with without_zlib (#17272)
  • Validate properties of HTTP::WebSocketHandler (#17235), HTTP::Request (#17255,#17304, #17374, #17310, #17312, #17258), HTTP::Headers name (#17317)
  • Close HTTP::Client on IO::Error during request (#17318)
  • Fix Content-Encoding: deflate (#17261)
  • Fix HTTP::Request.from_io parsing empty header name (#17254)
  • Fix HTTP::Request#form_params? to ignore invalid content-type (#17256)

Thanks @straight-shoota, @hahwul, @jgaskins, @Sija

All targets support a native event loop based directly on the system selector and use it by default.

We enabled epoll on Solaris (#17370) and kqueue on all remaining BSD targets (#17421, #17420). libevent is still available as a fallback, but now it’s strictly opt-in and becoming technically obsolete. We expect to deprecate in a following release.

Thanks, @ysbaddaden

We finally enabled support for Kernel TLS in the OpenSSL bindings by default (#17059)

Thanks, @ysbaddaden

  • File.exists? (#17307), as well as File::Info.readable?, .writable?, .executable? now receive a follow_symlinks: false argument(#17391)
  • Add Char::Reader.new(Bytes) (#17428)
  • Add Time::Span#to_nanoseconds etc. (#17190)
  • Add GC.syscall(&) (#17150)
  • Fixed backtraces when linking with -static-pie on musl-libc (#17316)

Thanks, @straight-shoota, @ysbaddaden

  • Uppercase instance and class variables (#17160)
  • HTTP::Request#local_address and #remote_address (#17260)
  • LLVM::Type#size and #alignment (#17494)
  • Support for LLVM 23.1 and 24.0 (#17432)
  • Updated markd 0.6.0 (#17269)

Thanks, @straight-shoota, @hertzdevil

Updated distribution-scripts (#17178) brings upgrades of package dependencies, docker base images etc.

Thanks, @straight-shoota

This is the first release featuring builds for aarch64-windows-msvc.

Thanks, @hertzdevil

Crystal established a forward compatibility policy in RFC 30: Building Crystal 1.22 requires a stage-0 compiler at 1.14 or higher.


Thanks

We have been able to do all of this thanks to the continued support of 84codes and all other sponsors. To maintain and increase the development pace, donations, and sponsorships are essential. OpenCollective is available for that.

Reach out to [email protected] if you’d like to become a direct sponsor or find other ways to support Crystal. We thank you in advance!

Contribute
联系我们 contact @ memedata.com