
从苹果开发的客户端语言演变而来,经历多年的失败尝试后,Swift 终于有望在服务端大展拳脚。谷歌已对此予以关注,并刚刚推出了面向 Swift 的 Google Cloud API 客户端库,显然是确信 Swift 凭借其性能和易用性,在后端开发中扮演着重要角色。GCP Swift 库面向 Swift 6.2+ 版本,并充分利用了 SwiftNIO 的异步事件循环、HTTP/2 多路复用、gRPC 传输以及数据竞争安全编译器标志。
After evolving from an Apple-made, client-side language and years of false starts, Swift could finally make it on the server. Google has taken note and has just rolled out Google Cloud API Client Libraries for Swift, evidently convinced Swift has a backend role thanks to its performance and ease of use. The GCP Swift libraries target Swift 6.2+ and take advantage of SwiftNIO's asynchronous event loops, HTTP/2 multiplexing, gRPC transport, and data race safety compiler flags.
“多年来,Swift 主要被视为一种与苹果客户端设备绑定的 UI 语言,”开发者关系总监 Karl Weinmeister 和软件工程师 Carlos O'Ryan 在一篇博客文章中写道。“随着 Swift 6 和严格并发检查的推出,它已成熟为一种可行的系统和云语言,将类 Rust 的数据竞争安全性与可预测的引用计数性能相结合。”
"For years, Swift was perceived mainly as a UI language tied to Apple client devices," said Karl Weinmeister, director of developer relations, and Carlos O'Ryan, software engineer, in a blog post. "With Swift 6 and strict concurrency checking, it has matured into a viable systems and cloud language, pairing Rust-like data-race safety with predictable, reference-counted performance."
Weinmeister 和 O'Ryan 认为,Swift 兼具开发者友好性和对底层资源的低级控制能力,这在 C++ 或 Rust 等具有挑战性的系统语言中并不常见。他们对该语言的轻量级运行时和自动引用计数 (ARC) 表示赞赏,同时也欣赏其富有表现力的语法。他们也认可 Swift 的编译时并发检查。“数据竞争在二进制文件编译或投入生产之前,就能在编辑器中被捕获,”他们指出。
Weinmeister and O'Ryan argue that Swift manages to be both developer-friendly and suitable for low-level control over resources, which tends not to be the case for challenging systems languages like C++ or Rust. They voice appreciation for the language's lightweight runtime and Automatic Reference Counting (ARC), alongside its expressive syntax. And they approve of Swift's compile-time concurrency checking. "Data races are caught in your editor before a binary ever compiles or reaches production," they note.
这两位谷歌工程师认为,服务端云 Swift SDK 非常适合服务器、容器和 DevOps 环境,并指出其在使用 Hummingbird 或 Vapor 等 Swift Web 框架构建高性能微服务方面的实用性。“借助 google-cloud-swift,服务端 Swift 开发者可以编写具备编译时竞争安全性、原生 async/await 人体工学 API 且零操作系统线程拥塞的端到端云基础设施,”他们宣称。这确实是一段漫长的旅程。
The Googlers argue that the Server Side Cloud Swift SDK is well-suited for servers, containers, and DevOps environments, pointing to its utility for building capable microservices using Swift web frameworks like Hummingbird or Vapor. "With google-cloud-swift, server-side Swift developers can write end-to-end cloud infrastructure with compile-time race safety, native async/await ergonomic APIs, and zero OS thread congestion," they declare. It's been quite a journey.
苹果早在 2015 年就将 Swift 编程语言开源,随后几年,开发者开始关注服务端 Swift。IBM 于 2016 年在其 Bluemix 云平台上提供 Swift 支持,几个月后 Swift 团队宣布成立服务端 API 工作组。首届服务端 Swift 大会于 2017 年底宣布举办。苹果 2018 年在异步 SwiftNIO 框架上的工作,进一步推动了后端 Swift 的发展。
Apple open-sourced the Swift programming language all the way back in 2015 and in the years that followed, developers started looking at Swift on the server. IBM in 2016 made Swift available on its Bluemix cloud and a few months later the Swift team announced a server API working group. The first server-side Swift conference was announced in late 2017. And Apple's work on the async SwiftNIO framework in 2018 advanced the case for backend Swift.
根据 TIOBE 指数,Swift 的流行度在 2020 年 1 月达到顶峰,当时排名第 9 位。目前排名第 18 位。Stack Overflow 2025 年开发者调查显示 Swift 排名第 20 位。即便如此,服务端 Swift 的采用进展缓慢。IBM 于 2019 年调整策略,不再坚持其 Swift 承诺。过去几年,亚马逊对其服务端 Swift 的 Smoke 框架也鲜有作为。
Swift's popularity peaked in January 2020, according to the TIOBE index, when it ranked as the 9th most popular programming language. It currently ranks 18th. Stack Overflow's 2025 developer survey has Swift ranked 20th. Even so, server-side adoption of Swift has been slow. IBM reversed course in 2019, backing away from its Swift commitment. And Amazon hasn't really done much with its Smoke Framework for server-side Swift in the past few years.
尽管如此,Swift 社区仍在坚持。Swift 服务端工作组于 2018 年启动,到 2024 年,Swift 6 发布并引入数据竞争安全检查,使该语言对后端应用更具吸引力。Swift 可能比 Rust 或 C++ 等语言更易上手,但随着开发者越来越依赖 AI 编码代理,这一优势在未来几年将发挥多大作用尚不确定。当然,Swift 代码可读性强,利于应用维护,但当 AI 负责读写大部分代码时,语言的人体工学和易用性就变得不那么重要了。®
Still, the Swift community has kept at it. The Swift Server Workgroup launched in 2018 and, by 2024, the release of Swift 6 with data race safety checks made the language more interesting for backend applications. Swift may be more approachable than languages like Rust or C++, but it's unclear how much that will matter in the years to come as developers become more and more dependent on AI coding agents. Certainly, Swift code is readable, a benefit for those maintaining applications, but language ergonomics and approachability matter less when AI is reading and writing most of the code. ®