Advice for the next 100 Rust GUIs
This article serves as a follow-up to a previous piece on advice for the next dozen Rust GUI applications, published four and a half years ago. Since then, the landscape has evolved considerably, with approximately two dozen Rust GUI toolkits announced and a surge in interest driven by the growing relevance of AI in software development.
The desire to construct graphical user interface applications in Rust persists, despite many shipping GUI applications still experiencing performance issues, particularly when utilizing cross-platform technology. Established GUI toolkits provided by platforms have largely remained stagnant, and system vendors have shown little interest in addressing the cross-platform challenge, leading to the rise in popularity of Electron.
With memory becoming more costly and a shift towards mobile devices, the consequences of bloated applications have become significant. Building high-performance UI in Rust is increasingly seen as a pragmatic solution to these challenges. However, the adoption of Rust UI has been slower than anticipated. Only a handful of flagship applications have embraced Rust for their user interface, with the Zed editor standing out as a notable example.
Built upon GPUI, a framework developed by the creators of Zed, it demonstrates that delivering Rust UI is not only feasible but also feasible in real-world scenarios. GPUI is emerging as a strong contender for AI-driven code rewrites, as evidenced by its use in Discord. The slow adoption of Rust UI may be attributed to several factors.
Firstly, writing Rust code demands a higher level of expertise compared to languages more commonly used for UI development like TypeScript, Kotlin, or Swift. Additionally, finding developers proficient in both Rust and UI design remains a challenge. Nevertheless, advances in artificial intelligence are beginning to mitigate these obstacles.
The cost of generating code using Large Language Models (LLMs) appears to be comparable across different programming languages, and there is reason to believe that Rust's robust type system can enhance maintainability in large codebases. Consequently, Rust is gaining traction as the preferred language for AI rewrites of existing codebases.
Despite this, there is still no unanimous agreement on the strategy for the UI layer. Drawing from my 2022 blog post, I predict a surge in experimentation with various approaches. My initial advice emphasized that the term "native" lacks a clear definition, and "native" toolkits should be assessed based on essential quality criteria.
While Windows still lacks a clear native option and Mac experiences some fragmentation between AppKit and SwiftUI, SwiftUI's performance issues suggest that there is ample room for improvement in this area. The mobile landscape presents a different scenario. While platforms continue to invest resources into refining their native toolkits, achieving a truly native feel for apps built with cross-platform frameworks remains elusive.
Nevertheless, utilizing the native toolkit for UI while handling common "business logic" in Rust is gaining traction. Shopify and 1Password are two notable examples that have adopted this approach, abandoning React Native in favor of this strategy. For mobile applications, leveraging the native toolkit for UI seems to be the most viable option.
However, substantial progress has also been made in developing mobile UI entirely in Rust. The Android View editor demo provides a glimpse of this progress, showcasing features such as IME functionality, swiping, cursor movement, semantic text deletion, composition regions (essential for CJK text), and basic accessibility through AccessKit.
One particularly notable development is the emergence of Parley, a comprehensive text layout solution that has gained widespread adoption among new Rust UI toolkits, thanks to sustained investment from Google, Canva, and Dioxus (now Cognition), as well as contributions from the community. Another viable alternative is Cosmic Text.
Both solutions address the critical issue of text layout, which had long been a significant challenge in Rust UI development. Furthermore, AccessKit has evolved into a robust infrastructure, now integrated into most Rust UI frameworks. Accessibility remains an area that requires further attention, particularly in ensuring seamless integration with rich text editing.
Lastly, performance degradation when accessibility features are enabled is an issue that needs to be addressed, especially in frameworks like egui, which rely on an immediate mode design and must rebuild and diff a tree on each animation frame. An intriguing topic that was extensively discussed in my 2022 blog post is the utilization of the system compositor.
This issue has become even more pressing in the current context, particularly with the increased importance of video content and the demand for smooth frame rates, even on low-end devices. While progress has been made in this regard, exemplified by the subduction library, it is not yet widely integrated into UI toolkits.
Rewritten by urgent.news; may contain errors — check the original.