System76 has been developing their own COSMIC desktop as the next evolution of their Pop!_OS Linux distribution built on top of Ubuntu.Interestingly, for this large COSMIC desktop project written in Rust, they decided not to use the GTK toolkit, but to use Iced-Rs Instead, the latter is a native Rust cross-platform graphics toolkit.

A System76 engineer involved in the COSMIC project commented on Reddit about COSMIC’s use of the Iced toolkit:

The UX team has been crafting widgets and apps for the past year. We are now at a critical moment when the engineering team decides on COSMIC’s GUI toolkit. After much deliberation and experimentation over the last year,Engineering team decided to use Iced instead of GTK.

Iced is a native Rust GUI toolkit that is moving fast enough for COSMIC to use it. The development team has written various COSMIC widgets in GTK and Iced for comparison. The latest development version of Iced has a very flexible, expressive and intuitive API compared to GTK. It’s very natural to use in Rust, and anyone familiar with Elm will appreciate its design.

The engineer also stated that GTK is one of the least efficient GUI toolkits because of its use of GObject, C, and its common layout and rendering methods. Every aspect of GTK is considered bad practice in software development and GUI architecture today. One of its biggest problems is the deep bundling of data, logic, and UI. So unless all code is thrown away and a new toolkit is created from scratch in Rust in a similar fashion to Iced, the shortcomings cannot be solved.

In Iced, the data is separate from the desktop widgets, the engineer said. Developers start with an application structure as a model, which stores all the state your application needs to build its layout. Whenever a message is received and the state changes, a view method is called, and this view method describes the entire layout as a state machine. The previous layouts are then compared and diffed so that the renderer only renders the differences between the two. There are also some neat techniques that can be used in the future to reduce the number of view updates required. Of course one of the best parts is that developers don’t need to use Iced to load dozens of huge libraries at runtime – because it has the option of a completely static binary.

Iced is a cross-platform GUI library written for the Rust programming language “with a focus on simplicity and type safety”. Iced’s design ideas were inspired by the Elm language. The Iced toolkit is not only available for Linux, macOS and Windows, but also for web applications.


Further reading

#PopOS #COSMIC #desktop #replaces #GTK #Rust #GUI #library #Iced

Leave a Comment

Your email address will not be published. Required fields are marked *