Skip to content

Introduction

Iodine is a functional UI toolkit for Kotlin built on top of Flow, Jetpack Compose , and Arrow. Where Arrow intends to be a "Functional companion to Kotlin's Standard Library", Iodine aims to be a functional companion to Jetpack Compose (including for desktop and multi-platform targets).

Iodine makes use of a component-based architecture, while also taking some inspirations from traditionally object-oriented approaches such as Model-View-ViewModel.

To get started, check out basic concepts for a short introduction to some of core concepts and types used by Iodine -- or examples for some concrete examples of how to build up some basic applications with Iodine components.

Background

Declarative functional UI programming has a long and varied history, going back to at least to the Fudgets library in the 1990s. More recently, in the 2010s, the React framework popularized functional declarative UI programming in the Javascript ecosystem. Since then, there have been a number of different approaches to this paradigm, from the popular to the more obscure -- in many languages and platforms.

Amidst this great array of diversity and complexity, a common organizing principle is the idea of a Component. To quote the documentation from Halogen:

Halogen uses a component architecture. That means that Halogen uses components to let you split your UI into independent, reusable pieces and think about each piece in isolation. You can then combine components together to produce sophisticated applications.

Iodine takes heavily from the ideas of the Halogen framework (iodine is a type of halogen, after all) -- in particular, the idea of using generic parameters to expose the public API of a UI component. From there, the approaches diverge somewhat. Whereas Halogen is designed to work well in a purely functional language, with support for some helpful but not very commonly implemented type system features, Iodine is designed with similar goals in mind, but implemented in a way as to work more idiomatically with Kotlin's multi-paradigm philosophy -- and to take advantage of features unique to Kotlin, such as typesafe builder DSLs and functions with receivers.

Users coming from the Halogen library might want to take a look at a more in-depth comparison.

Another strain of ideas that Iodine is inspired by the idea of using comonads to model user interface (c.f. Declarative UIs are the Future — And the Future is Comonadic!, Phil Friedman, 2018). A similar approach is taken by the Swift framework Bow Arch. Direct support for this style of programming is provided by the iodine-core-comonadic-ui package.