Cassowary (software)
Cassowary 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.
Cassowary was developed by Greg J. Badros, Alan Borning and Peter J. Stuckey, and was optimized for user interface applications.[1] 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.
Smalltalk, C++ and Java versions are available in the main distribution. Furthermore, there are bindings for GNU Guile, Python[2], and STk.
Other people have ported the solver to JavaScript[3], Dart, Squeak, Python[4], the .NET framework (Cassowary.net), and Rust[5].
Applications
- As of September 2014, GSS, a layout language and layout engine for the web, is being developed by The Grid.[6] It is a modern extension of CCSS.[7]
- Layx, a layout language for the web designed with ease of use in mind.[8]
- Scwm, the Scheme Constraints Window Manager.
- As of 2011, Cassowary is being used as the algorithm in the layout engine for Mac OS X (Lion and greater) and iOS (6 and greater).
- Enaml's layout engine is built on top of the Cassowary linear constraint optimizer.[9][10][11][12]
References
- The Cassowary linear arithmetic constraint solving algorithm, Authors: Greg J. Badros, Alan Borning & Peter J. Stuckey
- https://github.com/brodderickrodriguez/cassowary
- https://github.com/slightlyoff/cassowary.js/
- https://github.com/brodderickrodriguez/cassowary
- https://github.com/dylanede/cassowary-rs
- "Grid Style Sheets development history".
- "About CCSS". Archived from the original on 2014-09-11. Retrieved 2014-09-22.
- "Layx website's homepage".
- "Casuarius provides Python bindings to a C++ implementation of the Cassowary algorithm". Archived from the original on 2017-08-14. Retrieved 2017-09-19.
- casuarius on GitHub
- Kiwi, a replacement for Casuarius/Cassowary. The new solver removes that bottleneck. It still uses the same Cassowary algorithm, but it's a from-scratch implementation of the algorithm based on the Cassowary paper, not the existing Cassowary source code. While the Cassowary algorithm is good, the existing C++ implementation has many inefficiencies. The new solver is anywhere between 12x and 500x faster depending on the problem (40x typical) and uses around 5x less memory. And as I typically do, I chose to write the Python bindings by hand in C++ rather than use Cython. The resulting code is faster, and we now have one less external dependency.
- kiwi on GitHub
External links
- Cassowary Constraint Solving Toolkit:, project page at the University of Washington
- Ports of Cassowary
- JavaScript: cassowary.js
- Python: cassowary on GitHub, kiwi on GitHub
- Squeak (Smalltalk): Cassowary
- Rust: cassowary-rs
- GSS/Grid Stylesheets, a solver for layout in web pages implemented in coffeescript (which compiles to javascript).