Zed is a modern, dynamic programming language built for fun, learning, and productivity. Created by Mazell Smack-Dubose, Zed features a complete implementation with both interpreter and compiler modes, backed by a sophisticated virtual machine with 80+ bytecode instructions.
- β¨ Key Features
- π Quick Start
- π Examples
- ποΈ Building from Source
- π» Usage
- π§ͺ Testing
- ποΈ Architecture
- π Performance
- π― Development Status
- π License
- π€ Contributing
- π€ Author
- π Interpreter Mode: Direct AST interpretation perfect for development, debugging, and interactive programming
- β‘ Compiler Mode: High-performance bytecode compilation with VM execution optimized for production use
- Variables & Types: Dynamic typing with strong type checking
- Arithmetic: Full operator support (
+,-,*,/,%,**) with proper precedence - Comparisons: Complete comparison operators (
==,!=,<,>,<=,>=) - Logic: Boolean operators (
and,or,not) with short-circuiting - Bitwise: Full bitwise operations (
&,|,^,~,<<,>>) - Control Flow: Comprehensive flow control (
if/elif/else,while,forloops) - Functions: First-class functions with parameters, return values, and closures
- Data Structures: Rich built-in types (lists, dictionaries, sets)
- Advanced: List comprehensions, pattern matching (
match/case), break/continue
- I/O:
print()for console output - Introspection:
len(),type()for runtime inspection - Iteration:
range()for generating sequences - Conversion:
str(),int(),float(),bool()for type conversion - Math:
min(),max()for numerical operations
- Architecture: Stack-based bytecode execution engine
- Instructions: 80+ specialized opcodes for optimal performance
- Memory: Sophisticated call frame and upvalue management
- Debugging: Professional disassembler with execution profiling
- Error Handling: Comprehensive error reporting and recovery
- Statistics: Built-in execution timing and memory usage tracking
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
- CMake 3.10 or higher
- Make or Ninja build system
# Clone the repository
git clone https://github.com/PlangoDev/zed-lang.git
cd zed-lang
# Build the project
./build.sh
# Run your first Zed program
./build/zed examples/hello.zed-
Create a file
hello.zed:print("Hello, World!") print("Welcome to Zed programming!") -
Run it:
./build/zed hello.zed
-
See the magic β¨
Explore all of Zed's features with our comprehensive example:
./build/zed examples/comprehensive_demo.zedTry our number guessing game:
./build/zed examples/number_guessing_game.zedSee Zed's data processing capabilities:
./build/zed examples/data_analysis.zedπ’ Variables and Data Types
name = "Zed"
version = 2.0
is_awesome = True
numbers = [1, 2, 3, 4, 5]
person = {"name": "Alice", "age": 30}
print("Language: " + name)
print("Version: " + str(version))
print("Type: " + type(name))
π Control Flow
# Conditional logic
score = 85
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
else:
grade = "C"
# Loops
for i in range(5):
print("Count: " + str(i))
while score > 0:
print("Score: " + str(score))
score = score - 10
βοΈ Functions and Closures
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
def make_multiplier(factor):
def multiplier(x):
return x * factor
return multiplier
double = make_multiplier(2)
result = double(fibonacci(10))
print("Result: " + str(result))
π Data Processing
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# List comprehensions
squares = [x * x for x in data]
evens = [x for x in data if x % 2 == 0]
print("Squares: " + str(squares))
print("Even numbers: " + str(evens))
# Pattern matching
def describe_number(n):
match n % 2:
case 0:
return "even"
case 1:
return "odd"
case _:
return "unknown"
for num in range(5):
print(str(num) + " is " + describe_number(num))
# Create build directory
mkdir build && cd build
# Configure with CMake
cmake ..
# Build the project
make -j$(nproc)
# Optional: Install system-wide
sudo make install# Use the provided build script (recommended)
./build.sh
# This automatically:
# - Creates build directory
# - Runs CMake configuration
# - Compiles with optimizations
# - Sets up examples# Debug build
cmake -DCMAKE_BUILD_TYPE=Debug ..
# Release build (default)
cmake -DCMAKE_BUILD_TYPE=Release ..
# Enable additional debugging
cmake -DZED_DEBUG=ON ..Basic Execution
# Interactive REPL mode
./build/zed
# Run a Zed file with interpreter
./build/zed script.zed
# Run with compiler + VM (faster)
./build/zed -c script.zedAdvanced Options
# Compile to bytecode file
./build/zed -c -o script.zbc script.zed
# Execute bytecode file
./build/zed script.zbc
# Debug mode with detailed output
./build/zed -d script.zed
# Show bytecode disassembly
./build/zed --disasm script.zed
# Performance profiling
./build/zed --profile script.zed$ ./build/zed
Zed Programming Language v2.0
Created by Mazell Smack-Dubose
>>> x = 42
>>> print("The answer is " + str(x))
The answer is 42
>>> def greet(name): return "Hello, " + name
>>> greet("World")
"Hello, World"
>>> exit()# Run all tests (recommended)
./build.sh && ./run_tests.sh
# Run unit tests only
make -C build && ./build/run_tests
# Run language feature tests
./build/zed tests/test_functions.zed
./build/zed tests/test_data_structures.zed
./build/zed tests/test_control_flow.zed# Test interpreter mode
./build/zed examples/comprehensive_demo.zed
# Test compiler mode
./build/zed -c examples/data_analysis.zed
# Test bytecode generation and execution
./build/zed -c -o test.zbc examples/fibonacci.zed
./build/zed test.zbc# Run performance tests
./build/zed --profile examples/comprehensive_demo.zed
# Compare interpreter vs compiler performance
time ./build/zed examples/fibonacci.zed
time ./build/zed -c examples/fibonacci.zed| Component | File | Description |
|---|---|---|
| π€ Lexer | src/lexer.cpp |
Tokenization with Python-style indentation handling |
| π³ Parser | src/parser.cpp |
Recursive descent parser generating comprehensive AST |
| π AST | src/ast.cpp |
Abstract syntax tree nodes for all language constructs |
| π Interpreter | src/interpreter.cpp |
Tree-walking interpreter with environment management |
| β‘ Compiler | src/compiler.cpp |
AST β Bytecode compilation with optimization passes |
| π₯οΈ Virtual Machine | src/vm.cpp |
Stack-based VM with comprehensive instruction set |
| πΎ Value System | src/value.cpp |
Dynamic typing system supporting all Zed data types |
graph LR
A[Source Code] --> B[Lexer]
B --> C[Parser]
C --> D[AST]
D --> E{Mode?}
E -->|Interpreter| F[Tree Walker]
E -->|Compiler| G[Bytecode Generator]
G --> H[Virtual Machine]
F --> I[Result]
H --> I
Zed's VM supports 80+ specialized instructions organized into categories:
π’ Arithmetic Operations
ADD,SUB,MUL,DIV,MOD,POW,NEG
β‘ Bitwise Operations
BIT_AND,BIT_OR,BIT_XOR,BIT_NOT,BIT_LSHIFT,BIT_RSHIFT
π§ Logical Operations
LOGICAL_AND,LOGICAL_OR,LOGICAL_NOT
π Comparison Operations
CMP,CMP_NE,CMP_LE,CMP_GE,IS,IN
π― Control Flow
JMP,JZ(Jump if Zero),JNZ(Jump if Not Zero)
πΎ Variable Management
LOAD_LOCAL,STORE_LOCAL,LOAD_GLOBAL,STORE_GLOBAL
βοΈ Function Handling
CALL,CALL_BUILTIN,RET,YIELD
π Data Structure Operations
LIST_NEW,DICT_NEW,SET_NEW,DICT_SET,SET_ADD
π Indexing and Slicing
INDEX_GET,INDEX_SET,SLICE
π Iterator Support
ITER_NEW,ITER_NEXT,ITER_DONE
π Stack Management
POP,DUP,SWAP,ROT
| Mode | Speed | Use Case | Memory | Debugging |
|---|---|---|---|---|
| π Interpreter | Moderate | Development, debugging, interactive use | Lower | Excellent |
| β‘ Compiler + VM | Fast | Production, batch processing | Higher | Good |
- Startup Time: < 10ms for simple programs
- Fibonacci(30): ~2.1s (interpreted), ~0.8s (compiled)
- Data Processing: 50K+ operations/second
- Memory Footprint: ~5MB base, +1MB per 10K variables
- β Core Language: All fundamental language constructs
- β Type System: Dynamic typing with runtime type checking
- β Control Flow: Complete conditional and loop support
- β Functions: First-class functions with closures
- β Data Structures: Lists, dictionaries, sets with full operations
- β Advanced Features: List comprehensions, pattern matching
- β Virtual Machine: Complete 80+ instruction VM
- β Error Handling: Comprehensive error reporting
- β CLI Interface: Professional command-line interface
- β Testing Suite: Extensive test coverage
- β Documentation: Complete API and usage documentation
- β Build System: Cross-platform CMake build
- π Language Server Protocol (LSP) support
- π VS Code Extension improvements
- π Standard Library expansion
- π Package System design
- π WebAssembly compilation target
- π― Module System for better code organization
- π― Foreign Function Interface (FFI) for C/C++ integration
- π― Concurrent Programming with async/await
- π― Just-In-Time (JIT) compilation
- π― Interactive Debugger
MIT License - See LICENSE file for details.
Zed is free and open-source software. Feel free to use, modify, and distribute it according to the MIT License terms.
We welcome contributions! Here's how you can help:
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/zed-lang.git - Create a feature branch:
git checkout -b feature/amazing-feature - Build and test:
./build.sh && ./run_tests.sh
- π Follow the existing code style
- β Add tests for new features
- π Update documentation as needed
- π§ͺ Ensure all tests pass before submitting
- π¬ Write clear commit messages
- π Bug fixes and improvements
- β¨ New language features
- π Documentation improvements
- π§ͺ Test coverage expansion
- π¨ Example programs and tutorials
- π οΈ Development tools and IDE support
See CONTRIBUTING.md for detailed contribution guidelines.
Zed Programming Language is created and maintained by:
Mazell Smack-Dubose
- π GitHub: @PlangoDev
- π§ Project: zed-lang
Zed was built as a fun project to explore programming language design and implementation. It combines modern language features with educational value, making it perfect for:
- π Learning programming language concepts
- π§ͺ Experimenting with new ideas
- π Teaching compiler and interpreter design
- π Building small to medium projects
π Zed Programming Language
A modern, dynamic language built for fun and productivity
"Programming should be fun, expressive, and educational."
β Mazell Smack-Dubose, Creator of Zed
Made with β€οΈ by Mazell Smack-Dubose β’ GitHub β’ Get Started β’ Examples