Dawn Tutorial
中文 — this file is the original; the Chinese text is a translation of it.
Status: current — the reader-facing tutorial; the examples marked
dawn runhere are really run by CI (scripts/doc-check.py).
A deliberately small statically typed language: it compiles to JVM bytecode, and a native executable comes straight out of GraalVM native-image. This tutorial takes you from the first program to calling Java.
The
dawnfenced blocks in this document were once extracted, compiled, run and checked against theiroutputmechanically, byTutorialTeston the Kotlin side; that test is archived together with the Kotlin implementation at thekotlin-finaltag. The gate is back (TEST-04 in docs/codebase-audit.md):scripts/doc-check.pyis one of CI's jobs, and every block here marked```dawn runis really compiled and really run. Blocks not markedrunare still maintained by hand and may lag behind the language — mark your own if it matters that they are right.
- 1. Installing, and the first program
- 2. Values, types and functions
- 3. match and exhaustiveness
- 4. Modeling data: ADTs and records
- 5. Lists, tuples and destructuring
- 6. Loops: while, for, break and continue
- 7. Error handling: Result and ?
- 8. Lambdas and the effect system
- 9. Strings and the standard library
- 10. comptime and const
- 11. Calling Java
- 12. test blocks and dawn fmt
- 13. Modules and projects
- 14. Map and Set
- 15. Characters and code points
- 16. trait: constrained generics and operator overloading
- 17. Effects of your own: effect and with handle