⚡ Language Features

What makes Mica unique and powerful

Core Language Features

🎯 Explicit Effects & Capabilities

Side effects are tracked at the type level through an explicit capability system:

  • Functions declare required capabilities (IO, Net, Time)
  • Effect rows track all side effects
  • Using blocks provide RAII semantics
  • Capability providers can be mocked for testing
func process(io: IO) !{io} { using File::open("/tmp/data", io)? { io.println("opened") } // file closed automatically }

🔒 Deterministic Concurrency

Structured concurrency with guaranteed determinism:

  • Spawn/await with effect tracking
  • No data races by design
  • Reproducible execution
  • Automatic task scheduling
func parallel_fetch(urls: [String], net: Net) !{net} { for url in urls { let result = await spawn http::get(url, net) handle_result(result) } }

📦 Algebraic Data Types

First-class ADTs with exhaustive pattern matching:

  • Sum types (enums) with data
  • Product types (records)
  • Generic type parameters
  • Compiler-enforced exhaustiveness
type Result[T, E] = Ok(T) | Err(E) func handle[T](r: Result[T, String]) -> T { match r { Ok(value) => value, Err(msg) => panic(msg), } }

🎨 Powerful Generics

Zero-cost abstractions with full type inference:

  • Generic functions and types
  • Trait bounds and constraints
  • Higher-order functions
  • Type inference (Hindley-Milner)
func map[T, U](list: [T], f: func(T) -> U) -> [U] { let mut result = [] for item in list { result.push(f(item)) } result }

🛡️ Memory Safety

Move semantics and borrow checking (planned):

  • No null pointers
  • Move-by-default semantics
  • Planned: Rust-style borrow checker
  • RAII for resource management

⚡ Predictable Performance

Ahead-of-time compilation with no surprises:

  • LLVM backend for optimization
  • Zero-cost abstractions
  • Purity analysis for parallelization
  • No garbage collection pauses

🔧 Inspectable Compilation

Every compiler stage is exposed:

  • View tokens, AST, HIR, IR, LLVM
  • JSON output for tooling
  • Detailed error messages
  • Compile-time guarantees

📚 Minimal Surface Area

Small, learnable language core:

  • 10 fundamental constructs
  • Learn the whole syntax in an afternoon
  • Extend via libraries, not keywords
  • Read the compiler in a weekend

🧪 Testing-First Design

Built for reliability:

  • Deterministic shims for testing
  • 50+ integration tests
  • Golden snapshot testing
  • Exhaustiveness checking

🌐 Interop-Friendly

Play well with existing ecosystems:

  • C-compatible ABI
  • Python/JavaScript bridges (planned)
  • Foreign function interface
  • Standard calling conventions

📖 Documentation-Driven

Keep code and docs in sync:

  • Auto-generated CLI docs
  • Snapshot-tested examples
  • Comprehensive language tour
  • Inline documentation

🚀 Extensible Architecture

Designed for experimentation:

  • Modular compiler design
  • Plugin-friendly capability system
  • Alternative backend support
  • Clean separation of concerns

Language Comparison

How Mica compares to other languages

Feature Mica Rust Go Haskell
Memory Safety Move semantics Borrow checker GC GC
Effect System Explicit capabilities Traits only None IO monad
Deterministic Concurrency Built-in Manual with channels Goroutines (non-det) STM/Par monad
Learning Curve Low (weekend) High (months) Low (week) High (months)
Compile Times Fast Slow Very fast Moderate
Pattern Matching Exhaustive Exhaustive Basic switch Exhaustive
AOT Compilation LLVM LLVM Native GHC
Inspectable Pipeline Every stage Limited Limited Core dumps

Design Philosophy

The principles guiding Mica's development

🎯 Explicit Over Implicit

Effects, capabilities, and control flow are always visible. No hidden behavior or surprising action at a distance.

🔒 Safety By Default

The type system and effect system prevent common errors at compile time. Deterministic execution prevents race conditions.

📖 Readable Implementations

The compiler itself is designed to be a learning resource. Every module is documented and intentionally compact.

🧪 Verifiable Correctness

Exhaustive pattern matching, effect tracking, and testing infrastructure help ensure programs work as intended.

⚡ Predictable Performance

AOT compilation with LLVM, zero-cost abstractions, and explicit control over allocations and effects.

🚀 Industrial-Strength Design

While learning-sized, Mica follows industrial compiler patterns: proper IR, staged compilation, and runtime systems.