Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Kotlin → Romit

This page goes through Kotlin’s documentation topic by topic and shows how to do each thing in Romit, or says plainly that Romit doesn’t.

Romit isn’t trying to be Kotlin. It has no classes, generics or static types, because those work against “write it like a prompt”. It does aim to cover what everyday programs need, and its app layer overlaps with Compose Multiplatform.

Status: ✅ supported · 🟡 partly or another way · ❌ missing · ➖ doesn’t apply to Romit’s design

Basics and types

KotlinRomit
val / varx = 5, set x to 5 (no read-only values)🟡
Operatorssymbols and words (+ / plus, >= / is at least)✅
String templates "$x ${a.b}""{x} {a.b}", any expression inside, quotes allowed✅
Raw and multi-line strings"""…""" (indentation trimmed), escapes \n \t \" \\✅
String functionsupper, lower, trim, split, join, replace … with … in, starts with, ends with, contains, letters 1 to 3 of, length✅
Numberswhole numbers and decimals, 7 / 2 = 3.5, 1_000; no Byte/Float/hex literals🟡
Booleanstrue / false✅
Characterssingle letters are text (item 2 of "hi")🟡
Arrays and listslist a, b, add, remove, item n of, first/last N of, items a to b of✅
Mapsmap "a" to 1, item k of m, set item k of m to v, keys of, values of, contains✅
Setsunique of xs🟡
Ranges1 to 5, 10 to 1 (down), by 2 (step), range 1, 5✅
Null safety (?, ?:, ?.)nothing, is nothing, or else; a missing field gives nothing✅
Type checks and castsno static types; number of, text of convert➖
Unsigned types, type aliases—➖
Packages and importsuse "file.rmt" (scripts and apps)✅
Annotations, visibility modifiers—➖

Control flow and functions

KotlinRomit
if / else (also as an expression)if / otherwise if / otherwise; if … then … else …✅
whenmatch with values, comparisons, or no subject✅
for, whilefor each x in xs, for each i in 1 to 9 by 2, while✅
do-whilewhile with stop🟡
return, break, continuegive, stop, skip (no labels)✅
Exceptions: throw, try / catchfail "…", try … if it fails (error holds the message)✅
finally—❌
Functions, defaults, named arguments, recursionfn name a, b, b is 2, with b 3, recursion✅
Top-level propertiesfunctions can read top-level values✅
Varargs, local functions, return types—❌
Lambdas and higher-order functionswhere, each, sorted by take an expression with it; apps pass actions (do …, on tap); no lambda values🟡
Type-safe builders (DSLs)the app syntax is a builder DSL like Compose🟡
Inline functions, operator overloading, context parameters, extensions—➖
Reading input readln()ask "Question?"✅

Classes and objects

KotlinRomit
Data classesrecords: with name "Ada", age 36, field access and change, structural equality, readable printing✅
Destructuring—❌
Enum classes, entriesenum Size small, medium, large; Size lists the values✅
Sealed classesspec machine (allowed state changes checked by the compiler)🟡
object (singletons)an app’s state is one shared object🟡
Properties, getters, observersapp state, computed, on change of x, saved (persisted)🟡
Classes, inheritance, interfaces, generics, delegation—➖

Standard library

KotlinRomit
Filter, map, sort, groupwhere, each, sorted by … descending, grouped by✅
Aggregatecount, sum, average, min, max✅
Take, drop, slice, first, lastfirst N of, last N of, items a to b of, first of, last of✅
zip, flatMap, windowed—❌
Scope functions, sequences, reflection—➖
Date and timetoday, now, year / month / day / weekday of, days from a to b; apps: as date, as ago, date picker🟡
JSON (kotlinx.serialization)automatic: saved, load "url" into x, open file … as json, save x to file🟡
HTTP client (Ktor client)load "https://…" into x (GET)🟡
Coroutinesapps: async actions (wait, load), timers (every), reactive state; no channels or flows🟡
Testing (kotlin.test)spec test blocks with romit test🟡
UUIDs, HTTP server, databases—❌

Platforms and tools

KotlinRomit
Compose Multiplatform + Material 3Romit apps: Material 3 on Android, Apple style on iPhone✅
Kotlin/JS, webapps compile to one HTML file✅
Android, iOSapps run in the phone’s browser with a native look; no store builds🟡
JVM, Native, Wasm targets, Java/C/Swift interop—❌
Scripting (.kts)romit run script.rmt✅
IDE supportVS Code extension: highlighting, errors as you type, autocomplete, snippets, run command🟡
Gradle / Mavenone romit tool➖

See also: SwiftUI → Romit, Records, match, and errors.