文章摘要
WASI 0.3.0正式发布,将异步功能原生集成到WebAssembly组件模型中。新版本基于组件模型的异步原语重构,相比0.2版本通过wasi:io实现的复杂异步机制,现在可以直接使用future和stream等原生异步类型,使代码更简洁高效。主要变化包括用future替代pollable资源,用stream替代input/output-stream,并支持直接使用async函数。
文章总结
以下是文章主要内容的重新陈述,保留了关键细节并删减了非核心内容:
WASI 0.3.0 正式发布公告
核心更新: 1. 异步支持原生集成 - 基于WebAssembly组件模型的异步原语重构 - 废弃WASI 0.2的复杂异步实现方案(如pollable资源) - 新模型采用标准future/stream类型和await语法
主要模块变更:
- wasi:cli
- 标准I/O接口重构:
• stdin:返回(stream
, future )元组 • stdout:改为传入stream 并返回future - 新增共享的error-code错误类型
- wasi:sockets
- 移除network资源,改为通过world imports授权网络访问
- 合并异步操作: • 废弃start/finish模式(如start-bind/finish-bind) • 简化为async func(如bind/connect)
- 统一TCP/UDP的错误处理机制
- wasi:http
- 资源数量从8个精简为2个(request/response)
- 请求体直接使用stream
表示 - 处理器改为原生异步函数:
• 废弃response-outparam参数
• 直接返回future
> - 新增service和middleware世界类型
- wasi:filesystem
- 文件读写改用stream-plus-future模式
- 目录迭代从资源迭代器改为stream方案
- wasi:clocks
- 标准化命名: • wall-clock → system-clock • datetime → instant
- 移除subscribe类方法,统一使用await定时器future
兼容性说明: - 大部分变更为机械性修改,测试套件已同步更新 - 错误处理机制更加统一和规范 - 异步操作现在由运行时原生处理
(注:移除了原始版本中的代码示例细节和部分技术术语解释,保留了架构层面的核心变更点和设计思路)
评论总结
总结评论内容:
- 对WebAssembly/WASI发展现状的质疑
- 认为十年未取得重大突破,使用率低 "Will WebAssembly ever achieve a real breakthrough? It's been almost 10 years...only very few folks or companies use it." (评论1)
- 批评开发过程不透明 "I do not like that this has been worked on in the shadows." (评论2)
- 对WASI组件模型的批评
- 认为过度复杂化,偏离初衷 "WASI should be simple and stable...Now, there is an opinionated component model which is an unneeded overcomplication" (评论5)
- 指出静态链接设计缺陷 "the offering has been statically linking components before you ship. Defeating 99% of the use cases" (评论2)
- 技术方向争议
- 支持保持精简核心 "Let's keep WebAssembly lean and fast! Anything extra can (and should) be implemented by other technologies." (评论5)
- 认为自由发展更有前景 "think that freestanding wasm with custom integrations is the more likely future" (评论2)
- 实际应用疑问
- 询问具体使用案例 "If you have used WASI in the past, can you mention your use case?" (评论3)
- 提供技术资源参考 "you can browse the content for this release (.wit interface files) here on GitHub" (评论4)