Skip to content

splanck/viper

Repository files navigation

Viper

Viper

License: GPL v3 Platform

Viper is an IL-first compiler toolchain and virtual machine for building platform-native applications and games. Programs compile through a strongly typed, SSA-based intermediate language (Viper IL) that can be executed by the VM or compiled directly to native machine code.

Zia is Viper's flagship language — a modern, statically typed language with classes, generics, enums, lambdas, modules, and pattern matching, designed for building real applications and games on the Viper platform. A BASIC frontend is also included for educational use and rapid prototyping.

Status: Active development. APIs, IL, and tooling are still evolving and are subject to change. Ready for experimentation and game prototyping, but not production-ready.


Download

Latest Release: v0.2.5-dev (5/7/2026)

In development: v0.2.6 (unreleased) — see the draft release notes for what's landed on master since v0.2.5.

Working with the latest code: The master branch is a live snapshot of current development and is ahead of v0.2.5. To work with the most recent code:

git clone https://github.com/splanck/viper.git
cd viper

Quickstart

Build and test:

# macOS
./scripts/build_viper_mac.sh

# Linux
./scripts/build_viper_linux.sh

# Windows
.\scripts\build_viper.cmd

Create and run a project:

viper init my-app              # Zia project (default)
viper init my-app --lang basic # BASIC project
viper run my-app

Try the interactive REPL:

viper repl
zia> Say("Hello from the REPL")
Hello from the REPL
zia> Say(Fmt.Int(2 + 3))
5

See the Getting Started Guide for full setup instructions.


Components

Component Description
Zia Modern, statically typed language with classes, generics, enums, lambdas, modules, and pattern matching
BASIC Educational frontend for rapid prototyping
Viper IL Typed, SSA-based intermediate representation
Optimizer 24-pass pipeline: GVN, LICM, SCCP, loop opts, inlining, devirtualization, ownership-pair removal, runtime fast paths
VM Bytecode interpreter with switch, table, and threaded dispatch
AArch64 · x86-64 Native code generators
Assembler · Linker Built-in ELF/Mach-O/PE toolchain — zero external dependencies
Runtime 378 classes across 21 modules (graphics, 3D, GUI, game engine, networking, localization, and more)
Language Servers Dual-protocol (LSP + MCP) servers for Zia and BASIC
Tools Compiler drivers, verifier, disassembler, REPL, packager

Why Viper?

  • Platform-nativeZia compiles to native machine code via Viper IL — no VM required for production
  • IL-centric — A readable, typed IR makes semantics explicit and frontends interchangeable
  • Self-contained — Built-in assembler and linker with ELF/Mach-O/PE support and dynamic linking — zero external tool dependencies for native compilation
  • Full runtime — 378 classes covering graphics, 3D, networking, GUI, threading, localization, and more

Project Status

Viper is in early development. All components are functional but evolving:

Component Notes
Zia Frontend Classes, structs, generics, enums, lambdas, pattern matching, try/catch, modules
BASIC Frontend Core language with OOP, enums, select-case, namespaces
Viper IL Stable core; module linker for cross-language interop
Optimizer 24-pass pipeline covering SSA, loop, inlining, devirtualization, ownership, and peephole opts
VM Switch / table / threaded dispatch with trap handling and worker VMs
AArch64 Backend Apple Silicon and Windows ARM64 with register coalescing and post-RA scheduling
x86-64 Backend Windows and Linux, IEEE-754 NaN-safe, 300+ stress tests
Native Toolchain In-tree assembler and linker for ELF / Mach-O / PE with DWARF v5 and dynamic linking
Runtime 378 classes across 21 modules
3D Graphics 45 classes covering meshes, materials, lighting, skeletal animation, terrain, water, physics, asset import (glTF / FBX), and post-processing across Metal / D3D11 / OpenGL / software backends
Game Engine Collision, pathfinding, physics, tweening, particles, state machines, AI behaviors, level loading, asset embedding
GUI 47 widgets for cross-platform desktop apps
IDE / Language Servers ViperIDE with diagnostics, hover, go-to-definition, IntelliSense, symbol search; LSP + MCP servers
Packaging viper package for apps, viper install-package for the toolchain

Expect breaking changes. The IL specification, APIs, and tool interfaces are not stable.


Demos

Demo Description
ViperIDE Full-featured IDE for Zia and BASIC
ViperSQL SQL database engine with an interactive client
Paint Drawing app with layers, undo/redo, and an expanded tool set
Chess Chess with alpha-beta AI and a drag-and-drop GUI
Crackman Maze chase game with ghost AI
XENOSCAPE Metroid-style sidescroller with bosses, abilities, and saves
3D Bowling Physics-driven 3D bowling with multi-mode camera

See all demos → — 7 applications, 17 games, API coverage audits, IL examples, and C++ embedding demos.


Architecture

┌─────────────────────────────────────────┐
│           Source Languages              │
│          (Zia · BASIC · ...)            │
└─────────────────┬───────────────────────┘
                  ▼
┌─────────────────────────────────────────┐
│    Frontend (Parser · Sema · Lowerer)   │
└─────────────────┬───────────────────────┘
                  ▼
┌─────────────────────────────────────────┐
│         Viper IL  (Typed SSA)           │
│      Verifier · Optimizer (24 passes)   │
└─────────┬───────────────┬───────────────┘
          ▼               ▼
┌──────────────┐   ┌──────────────────────┐
│   Bytecode   │   │   Native Backends    │
│      VM      │   │   (AArch64 · x86-64) │
│              │   ├──────────────────────┤
│              │   │  Assembler · Linker  │
│              │   │  (ELF · Mach-O · PE) │
└──────┬───────┘   └──────────┬───────────┘
       └──────────┬───────────┘
                  ▼
┌─────────────────────────────────────────┐
│            Viper Runtime                │
│  Collections · Graphics · 3D · GUI ·    │
│  Game Engine · Audio · Network · I/O ·  │
│  Threads · Crypto · Math · Text ·       │
│  Localization · ...                     │
└─────────────────────────────────────────┘

See Architecture Overview and Code Map for detailed design.


IL at a Glance

Frontends lower to a typed IL that is compact, explicit, and inspectable.

Zia Source:

module Hello;

bind Viper.Terminal;
bind Fmt = Viper.Fmt;

func start() {
    var x = 2 + 3;
    var y = x * 2;
    Say("HELLO");
    Say(Fmt.Int(y));
}

Viper IL Output:

il 0.2.0
extern @Viper.Fmt.Int(i64) -> str
extern @Viper.Terminal.Say(str) -> void
global const str @.L0 = "HELLO"
func @main() -> void {
entry_0:
  %t0 = iadd.ovf 2, 3
  %t1 = alloca 8
  store i64, %t1, %t0
  %t2 = load i64, %t1
  %t3 = imul.ovf %t2, 2
  %t4 = alloca 8
  store i64, %t4, %t3
  %t5 = const_str @.L0
  call @Viper.Terminal.Say(%t5)
  %t6 = load i64, %t4
  %t7 = call @Viper.Fmt.Int(%t6)
  call @Viper.Terminal.Say(%t7)
  ret
}

See the IL Quickstart for a hands-on introduction, or the IL Reference for the full specification.


Runtime Library

All frontends share the Viper Runtime — 378 classes across 21 modules:

Module Classes Description
Collections 29 General-purpose data structures
Core 6 Base types and string operations
Crypto 7 Symmetric and asymmetric ciphers, hashing, key derivation, secure RNG
Data 3 Structured data serialization
Game 22 High-level 2D game systems, AI behaviors, level and scene management
Game.Physics2D 7 2D rigid-body dynamics and joints
Game.UI 6 In-game HUD widgets
Graphics 57 2D rendering, sprites, tilemaps, fonts, and the production 2D class set (render targets, textures, shaders, nine-slice, paths, debug draw)
Graphics3D 45 Full 3D pipeline: meshes, materials, lighting, skeletal and node animation, physics, terrain, water, asset import
GUI 47 Cross-platform desktop widgets
I/O 16 Files, archives, compression, streaming
Input 6 Keyboard, mouse, gamepad, and action mapping
Localization 10 BCP-47 locales, locale-aware number and date formatting, message bundles, CLDR-subset plural rules, list formatting, text direction
Math 12 Linear algebra, noise, splines, arbitrary precision
Memory 2 Validated retain/release wrappers and GC controls
Network 27 HTTP/1.1 and HTTP/2 client and server, WebSocket, TLS (in-tree X.509, RSA, ECDSA), UDP, SSE, connection pooling
Sound 8 Playback, synthesis, playlists, sound banks
Text 20 Structured-text parsing, templates, regex
Threads 18 Async primitives, channels, futures, pools
Time 8 Clocks, dates, durations, timers
Utilities 12 Formatting, logging, option / result helpers

See the Runtime Library Reference for complete API documentation.


Tools

Tool Purpose
viper Unified driver — run, build, compile, package
viper repl Interactive REPL for Zia and BASIC
viper package Generate installers (.app, .deb, .exe, .tar.gz)
viper install-package Generate staged toolchain installers (.exe, .pkg, .deb, .rpm, .tar.gz)
zia / vbasic Standalone language compilers
zia-server Language server (LSP + MCP)
viper -run Execute IL programs directly
viper il-opt Optimize and verify IL (-verify-each)
viper bench IL benchmark runner
viper run program.zia          # Run source
viper build project/ -o app    # Compile to native binary
viper repl                     # Interactive REPL

See Tools Reference for all commands and flags.


Building

Requirements

  • CMake 3.20+
  • C++20 compiler (Clang recommended, GCC 11+, or MSVC)

Build Steps

# macOS
./scripts/build_viper_mac.sh

# Linux
./scripts/build_viper_linux.sh

# Windows
.\scripts\build_viper.cmd

This configures, builds, tests, and installs Viper in one step.

Platform Notes

  • macOS — Use Apple Clang. ARM64 tests skip x86-64-specific checks automatically.
  • Linux — Clang recommended.
  • Windows — MSVC is the default compiler on Windows.

Documentation

Getting StartedSetup Guide · REPL Guide · Zia Tutorial · The Viper Bible

Language ReferencesZia Reference · BASIC Reference · IL Guide · IL Quickstart

Runtime & APIsRuntime Library · 3D Graphics · Game Engine · GUI

InternalsArchitecture · VM Design · Code Map · Backend · IL Passes

For ContributorsContributor Guide · Frontend How-To · Testing

Browse the full docs/ hierarchy for 200+ documents.


Contributing

Viper is in early development and the architecture is stabilizing. We welcome:

  • Bug reports and issues
  • Small fixes and documentation improvements
  • Feedback and suggestions

We are not currently seeking large feature PRs while the design solidifies. Feel free to fork for broader experimentation.


License

Viper is licensed under the GNU General Public License v3.0 (GPL-3.0-only).

See LICENSE for the full text.

About

Complete zero-dependency IL-first cross platform compiler toolchain, runtime, game engine, and virtual machine.

Topics

Resources

License

Stars

Watchers

Forks

Contributors