Skip to content

Latest commit

 

History

History
145 lines (113 loc) · 4.13 KB

File metadata and controls

145 lines (113 loc) · 4.13 KB

Veyra Language Design Philosophy

Core Principles

1. Performance by Default

Veyra is designed with performance as a primary concern, not an afterthought.

Key Decisions:

  • Ahead-of-Time (AOT) compilation for maximum runtime performance
  • Zero-cost abstractions where possible
  • Direct memory access when needed
  • LLVM backend for state-of-the-art optimizations

2. Memory Safety Without Garbage Collection

Memory safety should not come at the cost of performance or predictability.

Approach:

  • Ownership system similar to Rust but simplified
  • Borrow checker prevents data races and memory leaks
  • Optional regions/arenas for bulk allocation patterns
  • Escape hatch for unsafe operations when needed

3. Concurrency as a First-Class Citizen

Modern applications are concurrent by nature. Veyra makes this easy and safe.

Features:

  • Green threads (lightweight, user-space threads)
  • Actor model for message-passing concurrency
  • Async/await for asynchronous programming
  • Channels for safe data sharing
  • No shared mutable state by default

4. Simplicity and Clarity

Code should be easy to read, write, and understand.

Design Choices:

  • Minimal syntax with strong conventions
  • One obvious way to do common tasks
  • Strong type inference reduces boilerplate
  • Consistent naming and patterns throughout

5. Tooling-First Development

Great languages come with great tools built-in.

Included Tools:

  • Package manager (vey get)
  • Code formatter (vey fmt)
  • Linter (vey lint)
  • REPL (vey repl)
  • Debugger (vey dbg)
  • Documentation generator

Design Inspirations

From Rust

  • Ownership and borrowing for memory safety
  • Pattern matching
  • Trait system (adapted as interfaces)
  • Cargo-like package management

From Go

  • Simplicity and clarity
  • Fast compilation
  • Built-in concurrency primitives
  • Single binary distribution

From Swift

  • Clean, readable syntax
  • Optional types for null safety
  • Protocol-oriented programming

From Erlang/Elixir

  • Actor model for fault tolerance
  • "Let it crash" philosophy
  • Supervisors for process management

Syntax Philosophy

Readability First

# Clear and obvious
fn calculate_total(items: [Item]) -> Money
    total = Money.zero()
    for item in items
        total += item.price
    return total

Minimal Boilerplate

# Type inference reduces noise
items = [Item("apple", 1.50), Item("banana", 0.75)]
total = calculate_total(items)
print("Total: {total}")

Consistent Patterns

# Error handling
result = dangerous_operation()?
match result
    Ok(value) -> print("Success: {value}")
    Err(error) -> print("Error: {error}")

Trade-offs and Decisions

Compilation Speed vs Runtime Performance

Decision: Prioritize runtime performance Rationale: Developers compile less frequently than users run programs

Memory Safety vs Manual Control

Decision: Safe by default, unsafe when explicitly requested Rationale: Most code benefits from safety; systems code needs control

Simplicity vs Expressiveness

Decision: Favor simplicity, add expressiveness carefully Rationale: Maintenance is more important than initial development speed

Backward Compatibility vs Evolution

Decision: Break compatibility for meaningful improvements (pre-1.0) Rationale: Better to get the design right than maintain bad decisions

Non-Goals

What Veyra is NOT trying to be:

  1. A replacement for every language - Focused on specific use cases
  2. Beginner-friendly - Assumes programming experience
  3. Dynamic - Static typing provides better tooling and performance
  4. Object-oriented - Composition over inheritance
  5. Minimalist - Includes batteries, not just core language

Success Criteria

Veyra will be successful if:

  1. Performance: Matches C/C++ in benchmarks
  2. Safety: Memory-safe programs by default
  3. Productivity: Developers can build reliable software quickly
  4. Concurrency: Natural to write concurrent programs
  5. Adoption: Real projects choose Veyra for its benefits

This document will evolve as the language develops and we learn from implementation experience.