1. Your first program
Start with Getting started to build Kalm and make the
kalm command available in your shell.
Create a workspace
Create a folder named text-stats outside the Kalm checkout. Inside it, create
src/main/kalm/stats and src/test/kalm/stats. All commands in this path run
from text-stats.
Save this as src/main/kalm/stats/App.kalm:
space stats
pub fun main() -> Unit:
sayLine("Text stats")space stats
pub fun main() -> Unit {
sayLine("Text stats")
}package stats;
public final class App {
public static void main(String[] args) {
System.out.println("Text stats");
}
}Kalm Script unavailable — showing KalmThis source file belongs to the project path; the script path uses one self-contained file.
space names the package; main is the entry point. sayLine is available
without an import. The block contains the statements run by the entry point.
Run it
kalm.bat runkalm.bat runkalm runkalm runkalm runkalm runkalm runkalm runText statsTry changing the message and run it again. Your project will eventually read a text file and report its line and word counts.
Save the complete program below as App.kalms in a folder of your choice. Each lesson replaces this file; the shell does not load neighboring project files.
pub fun main() -> Unit:
sayLine("Text stats")pub fun main() -> Unit {
sayLine("Text stats")
}sayLine("Text stats")sayLine("Text stats")void main() {
System.out.println("Text stats");
}kalm.bat shell -f App.kalmskalm.bat shell -f App.kalmskalm shell -f App.kalmskalm shell -f App.kalmskalm shell -f App.kalmskalm shell -f App.kalmskalm shell -f App.kalmskalm shell -f App.kalmsText stats