编程与软件工程github.com
Iced:受 Elm 启发的 Rust 跨平台 GUI 库
Iced: A cross-platform GUI library for Rust, inspired by Elm
2020 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Iced 是一个用 Rust 编写的跨平台 GUI 库,灵感来自 Elm 架构(Model-View-Update)。它提供声明式 API,旨在让开发者用纯 Rust 构建原生性能的图形界面,避免 Electron 那样的 Web 技术栈。示例程序(如 tour)可直接通过 cargo run 运行,开箱体验流畅。
为什么经久不衰:它代表了 Rust 生态中追求原生 GUI 与 Elm 式简洁架构的早期尝试,对关注 Rust GUI 发展或函数式 UI 设计的人仍有参考价值。
HN 评论精选
批评示例中将状态与 UI 组件耦合,建议分离模型与视图以利于测试和更换框架。
这看起来像是把状态放在 UI 层……把状态放在独立的模型对象(结构体)里,然后把 UI 绑定到它上面不是更好吗?不这样做的话,很多逻辑和状态会和 UI 框架耦合,导致以后很难切换 UI 框架,更不用说独立于 UI 选择来测试逻辑了。
andrekandre查看英文原文
struct Counter { // The counter value value: i32, // The local state of the two buttons increment_button: button::State, decrement_button: button::State, } impl Counter { pub fn view(&mut self) -> Column<Message> { ... } } this looks like it holds state in the ui layer... wouldn't it be better to keep state in some separate state/model object (struct) and bind the ui to that instead? not doing it this way couples a lot of logic/state to the ui framework which means its much harder to switch ui frameworks later, not to mention testing the logic independently of the ui choice...
认为模仿 Elm/React 不适用于原生 GUI,函数式风格处理复杂视图效率低。
个人认为,开发者有机会从头构建自定义 GUI 库时,不应模仿 Elm 或 React。Elm/React 有助于解决 HTML 组件开发的固有问题,但这使它们比典型的原生 GUI 框架效率更低。简单视图容易处理,但这种函数式风格的 GUI 通常不太擅长处理复杂视图。
seanalltogether查看英文原文
Personally, I don't think developers should be mimicking Elm or React when they have the opportunity to build a custom gui library from scratch. Elm/React are helpful for overcoming the inherent problems in the html component development, but that requires them to be more ineffecient then typical native gui frameworks. Simple views are easy enough to handle, but these functional style guis don't tend to deal with complex views very well.
指出跨平台 GUI 重复造轮子,建议编译到 WASM 并用 Skia 等渲染器实现语言无关的组件。
它看起来很像 Flutter,有 Column、Text 等元素。似乎可能渲染到 canvas,不确定,如果跨平台兼容性是这样实现的,那也像 Flutter。我注意到很多这类 GUI 框架存在重复劳动。Flutter 为 iOS 和 Android 创建了很多 widget,但如果你不想用 Dart,就得自己重新实现那些 widget。更好的做法是编译成标准格式,很可能是 WASM,然后任何语言(面向 WASM,我认为未来大多数语言都会)都可以与这些 widget 或组件交互。它们可以是画布渲染器如 Skia(谷歌用于 Chrome 和 Flutter,也被 Revery for ReasonML 等 GUI 项目使用)的形式。这样,有一个通用格式,人们可以用任何语言写功能代码。
satvikpendem查看英文原文
It looks very Flutter-like, with Column, Text, and other elements. It seems it renders to canvas potentially, not sure though, if that's how the cross platform compatibility works, also like Flutter. I notice that in many of these GUI frameworks that effort is duplicated. Flutter creates a lot of widgets for iOS and Android, but if you don't want to use Dart, we'll, you'll have to reimplement those widgets yourself again. Instead, what should happen is that they should compile to a standard format, most likely WASM, and then you can use any language (that targets WASM, which I think will be most of them in the future) to interface with those widgets or components. They can be in the form of a canvas renderer such as Skia, which is what Google uses for Chrome and Flutter, and also used by some other GUI projects like Revery for ReasonML. This way, there's one common format and people can write the functionality code in whatever language they'd like.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选