Cassowary, A Constraint Satisfaction System for UI, and Its Reimplementation Kiwi

Cassowary /ˈkæs.ə.ˌwɛɹ.i/ is “an incremental constraint solving toolkit that efficiently solves systems of linear equalities and inequalities. Constraints may be either requirements or preferences. Client code specifies the constraints to be maintained, and the solver updates the constrained variables to have values that satisfy the constraints.” “Constraint Cascading Style Sheets for The Web” is the seminal paper.

It “was developed by Greg J. BadrosAlan Borning (his home page at UW) and Peter J. Stuckey, and was optimized for user interface applications. Badros used Cassowary amongst others for implementing Constraint Cascading Style Sheets (CCSS), an extension to Cascading Style Sheets (CSS). CCSS adds support for layout constraints. These allow designers to describe the layout of a web page in a more flexible manner. Cassowary is used to solve these constraints and calculate the final layout.”

UW Cassowary Constraint Solving Toolkit is a dedicated website for Casowary hosted by UW. It urges visitors to visit overconstrained.io as the website for the “current” Casowary Project, but this site seems to be a malicious site.

Casowary has been ported to many languages other than the original Smalltalk, but Kiwisolver, or Kiwi (repository) is a complete re-implementation in C++ with hand-written Python bindings. lume/kiwi is “a fast TypeScript implementation of the Cassowary constraint solving algorithm (soon for AssemblyScript / WebAssembly).”

According to “ConstraintLayout vs Auto Layout: How Do They Compare? – Big Nerd Ranch,” Cassowary is the basis for iOS’s Auto Layout and Android’s ConstraintLayout.

For resources on Auto Layout in Japanese, see “iOSDC Japan 2017で「Auto Layoutのアルゴリズム」について発表しました – Qiita.”

For those coming from iOS development to Web app development, there’s lume/autolayout: Apple’s Auto Layout and Visual Format Language for JavaScript (using cassowary constraints). Discussions on it on Hacker News mentions Grid Style Sheets or GSS, which also uses the Cassowary Constraint Solver. The latest release of GSS was in 2015, and not much development has been going on recently.

Incidentally, as “Popular CSS Preprocessors With Examples: Sass, Less & Stylus · Raygun Blog” explains, CSS preprocessors seem to have proliferated in the early 2010s. The most prominent three are Less, Sass and Stylus, but none has any constraint satisfaction function.

Speaking of cassowaries, see “Cassowary: World’s most dangerous bird raised by humans 18,000 years ago, study suggests – CNN.”

Cassowary, A Constraint Satisfaction System for UI, and Its Reimplementation Kiwi」への1件のフィードバック

  1. ピンバック: Just Some Personal Notes on VLANs | あくまで暫定措置としてのブログ

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください