Welcome to the GAL examples repository! These examples demonstrate why GAL is the world's first programming language with native chaos engineering, formal verification, and self-modification capabilities.
While other languages treat security, resilience, and correctness as afterthoughts, GAL makes them first-class language features:
- 🔐 Mathematically Proven Security - Don't hope your code is secure, prove it
- 🌪️ Chaos-Tested by Default - Break your code before production breaks it
- 🔄 Self-Evolving Systems - Code that adapts to threats automatically
- ⏮️ Time-Travel Debugging - Debug backwards through distributed failures
Cryptographically secure storage with formal verification of access control, featuring zero-knowledge authentication and automatic key rotation.
@verify(invariants: ["access_control", "data_integrity"])
@chaos_test(attacks: ["brute_force", "timing_attack"])
actor SecureVault {
proof no_unauthorized_access: ∀ request,
access_granted(request) → valid_auth(request)
}
Revolutionary supply chain security that detects and prevents dependency attacks through formal verification and chaos testing.
Prove identity without revealing credentials using mathematical zero-knowledge proofs.
Differential privacy with formal ε-guarantees for GDPR-compliant analytics.
End-to-end encrypted messaging with perfect forward secrecy and metadata protection.
Multi-signature wallet with chaos-tested resilience against double-spending.
Privacy-by-design storage with cryptographic erasure and consent management.
distributed_kv_store.gal (741 lines)
Eventually consistent key-value store with chaos-tested partition tolerance:
- Raft consensus for consistency
- Consistent hashing for distribution
- Automatic failover and recovery
- Built-in chaos testing
chat_application.gal (694 lines)
Real-time chat with thousands of concurrent users:
- Actor-based message routing
- Room management with moderation
- Message history and editing
- Spam detection and filtering
web_server.gal (666 lines)
Production-ready HTTP server with actor-based request handling:
- RESTful API endpoints
- WebSocket support
- Middleware pipeline
- Static file serving with caching
mapreduce.gal (556 lines)
Distributed computation framework:
- Parallel map and reduce operations
- Automatic data partitioning
- Word count and PageRank examples
- Job tracking and statistics
Self-aware actors that optimize themselves:
- Runtime code inspection
- Automated proof generation
- Fixed-point computations
- Paradox exploration
Introduction to chaos engineering in GAL:
- Fault injection annotations
- Resilience testing
- Contract verification
- Invariant enforcement
Your first GAL program - basic actor creation and message passing.
Stateful actors with message handlers and basic computation.
# Clone the repository
git clone https://github.com/geeknik/gal
cd gal/examples
# Run with verification
galc secure_vault.gal --verify --run
# Run with chaos testing
galc chaos_demo.gal --enable-chaos
# Generate formal proofs
galc zero_knowledge_auth.gal --generate-proofs
# Compile to production binary (LLVM backend)
galc compile distributed_kv_store.gal --backend llvm -o kv_store# Hope-driven development
def transfer_money(from_account, to_account, amount):
# Hope the network doesn't fail
# Hope there's no race condition
# Hope the database stays consistent
from_account.balance -= amount
to_account.balance += amount
# 🤞 Fingers crossed!@verify(invariants: ["balance_consistency", "no_negative_balance"])
@chaos_test(faults: ["network_partition", "database_failure"])
actor BankAccount {
// Mathematically proven correct
proof balance_invariant: sum(all_accounts.balance) == total_money
on Transfer(amount, to_account)
requires amount > 0 && balance >= amount
ensures balance == old(balance) - amount
=>
// Automatically tested against failures
atomic {
self.balance -= amount
to_account.deposit(amount)
}
}
| Feature | GAL | Rust | Go | Java | Python |
|---|---|---|---|---|---|
| Formal Verification | ✅ Native | ❌ External | ❌ | ❌ | ❌ |
| Chaos Engineering | ✅ Native | ❌ | ❌ | ❌ | ❌ |
| Self-Modification | ✅ Safe | ❌ | ❌ | ❌ | |
| Time-Travel Debug | ✅ Native | ❌ | ❌ | ❌ | ❌ |
| Zero-Knowledge | ✅ Built-in | 📦 Library | 📦 | 📦 | 📦 |
| Actor Model | ✅ Native | 📦 | ❌ | 📦 | 📦 |
proof no_sql_injection: ∀ input ∈ user_inputs,
sanitized(input) ∧ ¬contains_sql(processed(input))
@chaos_test(duration: "24h", scenarios: "production_like")
actor ResilientService {
// Tested with millions of failure combinations
}
@self_modify
on ThreatDetected(threat) =>
let defense = synthesize_countermeasure(threat)
self.hot_swap_security(defense)
let incident = record_security_breach()
debugger.time_travel(incident, step_back: true)
// Find the exact moment of compromise
Recommended order for learning GAL:
- Basics: Start with
hello_world.galandcounter.gal - Chaos: Study
chaos_demo.galfor resilience features - Security: Explore the security examples for verification
- Distributed: Dive into
distributed_kv_store.gal - Real-World: Examine
chat_application.galandweb_server.gal - Advanced: Experiment with Gödelian self-modification
The examples demonstrate production patterns:
- Actor Supervision Trees - Hierarchical fault tolerance
- Pipeline Processing - Stream processing with actors
- Consensus Protocols - Distributed agreement (Raft)
- CQRS/Event Sourcing - Event-driven architectures
- Circuit Breakers - Automatic failure recovery
- Zero-Trust Security - Verification at every layer
- 🏦 Financial Systems - Prove transaction consistency
- 🏥 Healthcare - HIPAA compliance through verification
- 🚗 Autonomous Vehicles - Chaos-test safety systems
- ☁️ Cloud Infrastructure - Self-healing services
- 🔐 Security Products - Unbreakable cryptography
- 📊 Data Analytics - Differential privacy guarantees
We welcome contributions! Areas of interest:
- Quantum-resistant cryptography
- IoT security patterns
- Distributed machine learning
- Blockchain consensus
- Privacy-preserving computation
See CONTRIBUTING.md for guidelines.
- Quick Start Guide
- Security Examples Guide
- Language Reference
- Chaos Engineering Guide
- Formal Verification Guide
MIT License - See LICENSE for details.
GAL isn't just another programming language. It's a paradigm shift in how we build secure, resilient, and intelligent systems.
Traditional languages make you choose between:
- Safety OR performance
- Correctness OR productivity
- Security OR usability
GAL gives you everything:
- Safety AND performance (zero-cost abstractions)
- Correctness AND productivity (verified by default)
- Security AND usability (chaos-tested automatically)
"We built GAL because we were tired of hoping our systems would work. With GAL, we don't hope - we prove, we chaos test, and we evolve. The age of fragile software is over."
Ready to build unbreakable systems?
🔗 Get Started | ⭐ Star this repo
GAL: Where Chaos Meets Certainty
The only language where bugs are compile errors and failures make you stronger.