Tutorials — Learn Clean Language Step by Step

Learn Clean Language from scratch with guided tutorials. Go from your first program to building full-stack web apps with the Frame framework — hands-on, step by step.

1
beginner

Your First Program

Write and run your very first Clean Language program in just three lines.

start blockprintindentation
2
beginner

Variables and Types

Store values in variables and discover Clean's four basic types.

variablesstringintegernumberbooleantoString
3
beginner

Working with Text

Use string interpolation and the most common string operations.

string interpolationtrimtoUpperCasecontainsreplacechaining
4
beginner

Making Decisions

Use if, else if, and else to run different code based on conditions.

ifelseelse ifandornotconditions
5
beginner

Loops: Doing Things More Than Once

Use iterate and while loops to repeat code, and break or continue to control the flow.

iteratewhilerangebreakcontinue
6
beginner

Lists: Keeping Groups of Things

Create and work with lists of values — add, access, iterate, and check.

listaddlengthindex accesscontainsiterate
7
beginner

Writing Your Own Functions

Write reusable functions with parameters and return values.

functions blockparametersreturnvoid
8
beginner

Classes: Grouping Data and Behavior

Define classes with fields, constructors, and methods — then build on them with inheritance.

classconstructorfieldsmethodsinheritancebase
9
beginner

Handling Errors

Raise errors with error() and catch them gracefully with onError.

erroronErrorfallbackerror handling
10
beginner

Your AI Coding Partner

Use the MCP server to get AI assistance that knows the exact Clean Language spec.

MCP serverAIrequirecontractscln mcp-server

Build a Web App

Frame framework →
11
beginner

Your First Web Server

Create a server with endpoints that respond to HTTP requests. You'll have something running in under 5 minutes.

frame.serverendpoints server:http.respond
12
beginner

Returning HTML Pages

Serve complete HTML pages from your server. Use helper functions to keep your page structure consistent across every route.

html: blockfunctions:raw interpolationpage structure
13
beginner

Route Parameters

Read values from the URL path and use them to serve dynamic content. One endpoint handles /users/alice, /users/bob, and every name in between.

req.param:param syntaxdynamic routes
14
beginner

Reading from a Database

Connect to MySQL and query your data. Display database records in a web page using db.query and json.get.

frame.datadb.queryjson.getSQL params
15
intermediate

Saving Data to a Database

Handle POST requests and save form data to your database. Build the write side of your web application.

POST endpointsreq.bodyINSERTvalidation
16
intermediate

Building Reusable Components

Create functions that return HTML — Clean Language's component model. Write a card, a button, or a nav bar once and use it everywhere.

functions:html: blockreusable componentsraw interpolation
17
intermediate

Listing Records from a Database

Fetch multiple rows and render them as a list. This pattern powers every feed, search result, and dashboard in your app.

COUNT queryiteratejson.get with indexlisting pattern
18
intermediate

Query Parameters and Search

Read URL query strings to filter results. Add search and filtering to any listing page without changing your routes.

req.queryfilteringconditional SQLsearch
19
intermediate

JSON API Endpoints

Return JSON instead of HTML. Build API endpoints that mobile apps, frontend JavaScript, or other services can consume.

application/jsonAPI designerror responseshealth check
20
intermediate

Putting It All Together

Build a complete bookmarks app — add URLs, list them, view them. Every pattern from this track working together in one real project.

full-stack appCRUDcomponentsmultiple routes

Language in Depth

How Clean works →
21
beginner

Types and Conversions

Understand Clean Language's four core types and how to convert between them. The type system catches mistakes before they reach production.

stringintegernumberbooleantype conversion
22
intermediate

Functions in Depth

Write functions that call each other, return different types for different conditions, and build complex behavior from simple pieces.

return typesfunction compositiontyped parametersboolean functions
23
intermediate

List Operations

Everything you can do with a list — add items, access by index, check membership, iterate, and build new lists from existing ones.

list<T>.add()index access.contains().length()iterate
24
intermediate

The String Toolkit

A practical guide to Clean Language's string methods — the ones that appear in real programs, with examples that show when to reach for each one.

.trim().toUpperCase().contains().replace().split().slice()
25
intermediate

Designing Classes

Bundle data and behavior into a class. Write a constructor, define methods, and create multiple independent instances from the same template.

classconstructorpropertiesmethodsinstances
26
intermediate

Class Inheritance

Extend a class with is and call the parent constructor with base(). Reuse behavior from a parent and add or override what the child needs.

isbase()inheritancemethod overrideparent class
27
intermediate

Contracts with require

State function preconditions explicitly. require is documentation and enforcement in one line — the compiler and runtime guarantee the contract is honored.

requirepreconditionscontractsdefensive programming
28
intermediate

Error Handling in Depth

Signal errors with error() and handle them at the call site with onError. Make error handling explicit, local, and readable.

error()onErrorerror propagationdefensive programming
29
intermediate

Iteration Patterns

Master all iteration forms — range, step, list, while, break, and continue. Know which pattern fits each problem.

iteratewhilebreakcontinuestepaccumulation
30
intermediate

Language in Practice

Put it all together: build a word-frequency counter using classes, functions, lists, strings, and iteration. See how the pieces connect in a complete program.

program designfunctionsclasseslistsstringsiteration
Copied!