Skip to content

Examples Gallery#

A curated collection of Jac examples organized by complexity level. Each example includes full source code, explanations, and step-by-step tutorials.


Beginner#

Start here if you're new to Jac. These examples demonstrate core language features.

Example Description Key Features
Quick Examples Standalone code snippets for key features by llm, OSP basics, Python superset
Jac in a Flash Learn Jac syntax in 5 minutes Variables, functions, control flow

Intermediate#

Build your first complete applications with these step-by-step tutorials.

Example Description Key Features
LittleX Build a Twitter-like app in 200 lines Nodes, walkers, jac start, graph traversal
EmailBuddy AI-powered email assistant by llm, structured outputs, email integration

Advanced#

Complex applications showcasing advanced Jac patterns and AI integration.

Full-Stack Applications#

Example Description Key Features
RAG Chatbot Multimodal MCP chatbot with document search MCP tools, vector search, multimodal AI
RPG Level Generator AI-powered game level generation by llm, structured data types, procedural generation
Fantasy Trading Game AI-driven trading simulation by llm, complex state management

Agentic AI#

Example Description Key Features
Friendzone Lite Social AI agent ReAct pattern, tool calling
Aider Genius Lite AI coding assistant Code generation, tool integration
Task Manager Lite AI task management Structured outputs, task decomposition

Reference Examples#

The Jac repository includes comprehensive reference examples for every language feature:

# Location in repository
jac/examples/reference/

These include working .jac files with corresponding .md documentation and Python equivalents (.py) for comparison.

Categories#

Category Examples
Basic Syntax Variables, expressions, control flow, functions
Data Types Collections, enums, type annotations
OSP Features Nodes, edges, walkers, graph operations
AI Integration by llm, semantic strings
Advanced Concurrency, context managers, generators

Running Examples#

Local Execution#

# Run any example
jac run example.jac

# Run with session persistence
jac run example.jac -s my_session

# Clear persisted state if needed
rm -rf .jac/data/

Server Mode#

# Start API server
jac start example.jac

# API docs at http://localhost:8000/docs

Testing Examples#

# Run tests in an example
jac test example.jac

# Run all tests in directory
jac test -d examples/

Contributing Examples#

Want to add your own example? Follow these guidelines:

  1. Create a directory under docs/docs/learn/examples/
  2. Include a tutorial.md with step-by-step instructions
  3. Add working source code in a src/ subdirectory
  4. Test all code before submitting
  5. Update mkdocs.yml to add navigation entry

See the Contributing Guide for more details.