编程语言与软件工程2016researcher.watson.ibm.com
Swift:语言与编译器研究的挑战和机遇
Swift: Challenges and Opportunity for Language and Compiler Research
进阶 · 约 15 分钟读完前置知识:编译器基础、类型推断、编程语言设计
导读
这份材料从语言与编译器研究的角度讨论 Swift 面临的挑战与机会,涉及编译器稳定性、编译时间、类型推断以及服务端应用等方向。评论者则更多从实际项目经验出发,质疑其在大型代码库中的生产可用性。
HN 关注点:Swift 在大型项目中暴露的编译器崩溃、编译速度和包体膨胀问题,以及它能否进入服务端高并发领域。
HN 评论精选
这几条评论里:质疑 1 补充 2 亲历 1
质疑大型 Swift 项目的核心痛点是编译器崩溃和编译时间,说明语言成熟度和测试不足。
有意思的是,这里很多人把源码破坏性变更当成主要问题,我想是因为他们没在大型代码库中用过 Swift。大项目里的主要问题是编译器崩溃(有专门的崩溃列表)和编译时间。我很难理解编译器怎么会崩这么多——我以前用过很多客户端和服务端语言,这是第一次遇到写代码时编译器崩溃。这让我很不安,因为说明单元测试不够好,语言还处在 alpha 阶段。编译时间也许可以靠优化解决,但在优化到来前不能过度依赖类型推断(它正是变慢的主因),这削弱了代码的美感。客户端如此,服务端可能还有更多问题。我曾很乐观,但 Swift 团队只剩一次机会让它达到生产级,否则大家会传开说这语言目前就是个笑话(也许 Apple 自己用它做 app 能争取更多资源)。
bsaul查看英文原文
Funny how people here mention source breaking change as the main issue with the language. I think it's because they haven't used swift on a large codebase. The main issue once you start to work on a big project are compiler crash ( https://github.com/practicalswift/swift-compiler-crashes ) and compilation time. I really don't understand how a compiler can crash that much ( actually i've been coding in many client and server languages before and it's the first time i see a compiler crashing while i code). It makes me really nervous, because it shows that unit tests aren't good enough, and that the language is really in alpha stage, not more. As for compilation time, you may think it's just a matter of optimisation. But the problem is that until those optimisation arrive, you can't rely too much on type inference (main source of slowdowns), which diminishes a lot the beauty of the code. Now that was for client side. Server side probably adds its share of issues. I used to be very optimistic for this language, but i'd say the swift team only has one more shot to make it really production grade, before the word spreads that this language is for now just a joke ( maybe apple using it for its own app would help allocate more resources).
补充Swift 运行时库使应用包体明显增大,需 OS 内置稳定框架。
我发现,在 macOS 上即便把很小的 Xcode 项目改用 Swift,也会让最终 bundle 增加 10 MB 库。操作系统需要默认内置一组稳定的 Swift 框架,这样 Swift 程序就不必让用户下载大得多的二进制包。
makecheck查看英文原文
I found that on macOS, refactoring even a tiny Xcode project to use Swift added 10 MB of libraries to the resulting bundle. The OS needs to start including a stable set of Swift frameworks by default so that Swift-based programs do not require users to download much fatter binaries.
亲历Swift 3 开发体验不错,但离服务端高并发竞争仍有距离。
我最近开始用 Swift 3 做一个 iOS 应用,整体体验相当愉快,尽管 Xcode 没有 Vim 键位绑定。我希望 Swift 能走出应用开发这个小圈子,但从这些幻灯片看,它要和高并发领域的 Go 等语言竞争还需要一段时间。
scribu查看英文原文
I've recently started working on an iOS app in Swift 3 and it's a mostly pleasant experience, even though XCode doesn't have Vim keybinds. I hope Swift can break out of the app-building niche, but from these slides it sounds like it will be a while until it can compete with Go and others in the high-concurrency space.
补充补充服务端框架 Vapor,与 Kitura 并列。
幻灯片因为是 IBM 的演讲提到了 Kitura,但还有 http://vapor.codes/。
rudedogg查看英文原文
Kitura is mentioned in the slides since it's an IBM talk, but there's also http://vapor.codes/
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2016Hacker News 讨论帖158 分 · 90 评
同领域还值得读
Google 的软件工程(2017)
Software Engineering at Google (2017)
介绍了 Google 的软件工程实践,包括其单一代码库(monorepo)、几乎全部开发在主干进行而非分支、代码审查、构建系统 Blaze、协议缓冲区等工具与流程,并讨论了频繁重…
编程语言与软件工程2017 · 1,127 分 · 465 评 · 引用 15入门 · 约 45 分钟编辑精选Peter Naur:编程作为理论构建 (1985)
Peter Naur – Programming as Theory Building (1985)
Peter Naur 1985 年的经典论文《Programming as Theory Building》提出:编程的本质不是写代码或文档,而是在程序员头脑中构建对程序及其运行…
编程语言与软件工程2016 · 629 分 · 74 评入门 · 约 45 分钟编辑精选SciPy 1.0:Python 科学计算的基础算法
SciPy 1.0: fundamental algorithms for scientific computing in Python
这篇发表于 Nature Methods 的论文介绍了 SciPy 1.0——Python 科学计算生态的基石库,涵盖其核心算法模块(优化、积分、插值、线性代数等)、软件架构与社…
编程语言与软件工程2020 · 387 分 · 98 评入门 · 约 45 分钟编辑精选Lisp 的历史(1979)
History of Lisp (1979)
这是 Lisp 发明者 John McCarthy 于 1979 年为 HOPL(编程语言史)会议撰写的回顾文章,讲述 Lisp 的起源、设计动机与早期演进,文中也涉及 if 表…
编程语言与软件工程2018 · 352 分 · 44 评入门 · 约 45 分钟编辑精选使用 NumPy 进行数组编程
Array Programming with NumPy
这篇 Nature 文章介绍 NumPy 的数组编程模型及其在科学计算中的核心作用:以 ndarray 为中心,通过向量化操作让 Python 高效处理多维数组。
编程语言与软件工程2020 · 318 分 · 134 评入门 · 约 40 分钟编辑精选