Skip to content

Example programs ​

Once you've done the tutorial, these fuller programs are a good next step. They all live in the repository's examples/ directory, and each one's README explains how to run it, what it depends on and what its limits are.

Start with small local tools ​

  • Task Tracker: a command-line task list that keeps its data in a local JSON file. It shows file I/O, a typed data model and reading JSON fields with @std/json_codec, with no network access.
  • json_select: a command-line tool for picking fields out of JSON, split across several files, using the sprig-cli library for options.
  • tasks: a todo CLI with subcommands over a JSON file (sprig-cli, @std/json_codec).
  • csv: writes a UTF-8 CSV file and reads it back with sprig-csv, with commas, a line break and non-ASCII text inside cells, and reads its columns by header. The library ships in the SDK from v0.9.0-beta.1.
  • config_summary: reads a small JSON configuration file and prints a summary in a fixed format, with clear errors for bad input.
  • blog: a static blog generator that turns posts with front matter into HTML pages and an index, with exit codes for bad input (@std/files, @std/text, @std/lists).
  • agent_tools: three small tools written in Sprig that read the compiler's JSON output to query Java and Sprig APIs, summarize errors and compare APIs.

Applications that use Java libraries ​

  • application_foundation: HTTP, JSON encoding and decoding, UTC time and file handling.
  • sqlite and sqlite_migrations: JDBC through Maven, with transactions, persistence and database migrations.
  • parallel_words: counts words in parallel with @std/concurrent, using a scope, tasks, a pool, a channel, a counter and a lock once each; see Concurrency.
  • crawler: a concurrent crawler over local pages with scopes, tasks, a channel, a counter and a lock (@std/concurrent).
  • ledger: a compact bookkeeping HTTP backend whose data survives a restart. See Web and SQLite.
  • todo: a todo list stored in SQLite behind a small HTTP API (sprig-sqlite, sprig-web); its test drives the live server over HTTP.
  • mini_web: typed routes, JSON and OpenAPI documentation.

Third-party Java libraries are added with ordinary Maven coordinates and pinned by the lock file; see projects and JVM interop. The libraries Sprig maintains itself are in the libraries/ directory.

Bigger programs ​

  • repository_audit: walks a code repository and writes a JSON report.
  • maven_slug: locks a Maven library, queries its API and reuses the cache offline.
  • source_analyzer: a source analysis tool written in Sprig that walks a syntax tree and lists functions, variables and references. It covers part of the language only and isn't a full compiler API.
  • test_runner: all kinds of tests in an ordinary Sprig project, including runtime tests, table tests, temporary files, subprocesses and tests that are expected to fail compilation.

Fabric mods is a separate case study: game logic in a Minecraft mod written in Sprig, with Gradle and Loom handling the build and only a thin layer of Java.

These examples cover the scenarios that have been tested. They don't mean every library API or production workload is supported.

Last updated:

Sprig is licensed under Apache-2.0 · v0.7.1-beta.1 published as a prerelease