Appendix D: Tooling and IDE Setup
Development Environment
Good tools make you productive. This appendix shows you how to set up a professional Wyn development environment.
VS Code Setup
VS Code is the recommended editor for Wyn. It has the best support.
Installation
Install VS Code
bash# macOS brew install --cask visual-studio-code # Linux snap install code --classic # Or download from https://code.visualstudio.comInstall Wyn Extension
- Open VS Code
- Press
Cmd+Shift+X(macOS) orCtrl+Shift+X(Linux/Windows) - Search for "Wyn"
- Click Install
Features
The VS Code extension provides:
Syntax Highlighting
- Keywords, types, strings, comments
- Semantic highlighting for variables and functions
Code Completion
- Method suggestions when you type
. - Function parameter hints
- Import suggestions
Error Checking
- Real-time error highlighting
- Hover for error messages
- Quick fixes for common issues
Go to Definition
Cmd+Click(macOS) orCtrl+Clickto jump to definition- Works for functions, types, variables
Find References
- Right-click → Find All References
- See where a symbol is used
Formatting
Shift+Alt+Fto format document- Auto-format on save (configurable)
Debugging
- Set breakpoints
- Step through code
- Inspect variables
- (Requires debug adapter)
Configuration
Create .vscode/settings.json in your project:
{
"wyn.compilerPath": "/path/to/wyn",
"wyn.formatOnSave": true,
"wyn.lintOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": true
}Keyboard Shortcuts
| Action | macOS | Linux/Windows |
|---|---|---|
| Go to Definition | Cmd+Click | Ctrl+Click |
| Find References | Shift+F12 | Shift+F12 |
| Rename Symbol | F2 | F2 |
| Format Document | Shift+Alt+F | Shift+Alt+F |
| Quick Fix | Cmd+. | Ctrl+. |
| Command Palette | Cmd+Shift+P | Ctrl+Shift+P |
Vim/Neovim Setup
For Vim users, Wyn provides syntax files and LSP support.
Installation
Install syntax files
bashmkdir -p ~/.vim/syntax cp wyn/editors/vim/wyn.vim ~/.vim/syntax/ # Add to ~/.vimrc au BufRead,BufNewFile *.wyn set filetype=wynInstall LSP support (requires vim-lsp or coc.nvim)
vim" Using vim-lsp - the server is `wyn lsp` (stdio) if executable('wyn') au User lsp_setup call lsp#register_server({ \ 'name': 'wyn-lsp', \ 'cmd': {server_info->['wyn', 'lsp']}, \ 'allowlist': ['wyn'], \ }) endif
Features
- Syntax highlighting
- Auto-indentation
- LSP integration (completion, go-to-definition)
- Error highlighting
Language Server Protocol (LSP)
The Wyn LSP provides IDE features for any editor that supports LSP.
Starting the LSP
wyn lspThis starts the language server on stdio. Your editor communicates with it.
Supported Features
- Completion: Method and function suggestions
- Hover: Type information and documentation
- Go to Definition: Jump to symbol definition
- Find References: Find all uses of a symbol
- Diagnostics: Real-time error checking
- Formatting: Code formatting
- Rename: Rename symbols across files
Configuration
Create .wyn-lsp.json in your project root:
{
"compilerPath": "/path/to/wyn",
"checkOnSave": true,
"formatOnSave": false,
"maxDiagnostics": 100
}Build Tools
Makefile
For projects with multiple files:
# Makefile
WYN = wyn
SRC = $(wildcard src/*.wyn)
OUT = bin/program
all: $(OUT)
$(OUT): $(SRC)
mkdir -p bin
$(WYN) build src/main.wyn -o $(OUT)
clean:
rm -rf bin
run: $(OUT)
./$(OUT)
test:
$(WYN) test tests
.PHONY: all clean run testUsage:
make # Build
make run # Build and run
make test # Run tests
make clean # Clean build artifactsBuild Script
For more complex builds:
#!/bin/bash
# build.sh
set -e
WYN=wyn
SRC_DIR=src
OUT_DIR=bin
MAIN=src/main.wyn
OUT=$OUT_DIR/program
# Create output directory
mkdir -p $OUT_DIR
# Compile
echo "Compiling..."
$WYN build $MAIN -o $OUT
# Run tests
echo "Running tests..."
$WYN test tests
echo "Build complete: $OUT"Make it executable:
chmod +x build.sh
./build.shDebugging
Print Debugging
The simplest approach:
fn process(data: [int]) -> int {
print("Processing ${data.len()} items")
for (var i = 0; i < data.len(); i = i + 1) {
print("Item ${i}: ${data[i]}")
// Process item
}
return 0
}Debug Builds
Keep the generated C and build artifacts for inspection:
wyn build program.wyn --debug
# Keeps program.wyn.c alongside the binaryUsing the Built-in Debugger
wyn debug program.wynThis compiles with DWARF debug info and launches lldb (macOS/Linux). You can set breakpoints on .wyn source lines and step through your code:
(lldb) breakpoint set --name main
(lldb) run
(lldb) step
(lldb) print variable_name
(lldb) continueGDB users can run gdb against the same program.wyn.debug binary that wyn debug produces.
Testing
Unit Tests
Create test files alongside source:
src/
math.wyn
math_test.wynmath.wyn:
export fn add(a: int, b: int) -> int { return a + b }math_test.wyn:
import math
fn test_add() -> int {
var result = math.add(2, 3)
if (result != 5) {
print("FAIL: add(2, 3) = ${result}")
return 1
}
print("PASS: add")
return 0
}
fn main() -> int {
var failures = 0
failures = failures + test_add()
if (failures > 0) {
print("FAILED: ${failures} tests")
return 1
}
print("PASSED: all tests")
return 0
}Run tests:
wyn run math_test.wynTest Runner Script
#!/bin/bash
# run_tests.sh
set -e
TESTS=$(find tests -name "*_test.wyn")
PASSED=0
FAILED=0
for test in $TESTS; do
echo "Running $test..."
wyn build $test -o /tmp/test.out
if /tmp/test.out; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
done
echo ""
echo "Passed: $PASSED"
echo "Failed: $FAILED"
if [ $FAILED -gt 0 ]; then
exit 1
fiContinuous Integration
GitHub Actions
Create .github/workflows/ci.yml:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Wyn
run: curl -fsSL https://wynlang.com/install.sh | sh
- name: Build
run: make
- name: Test
run: make test
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: binary
path: bin/programProfiling
Wyn binaries are ordinary native executables - the standard system profilers work on them directly, no special flags needed.
Time Profiling
wyn build program.wyn
# macOS:
xcrun xctrace record --template 'Time Profiler' --launch ./program
# or the quick view:
sample ./program 5 # while it runs
# Linux:
perf record ./program && perf reportMemory Profiling
wyn build program.wyn
# Peak memory:
/usr/bin/time -l ./program # macOS
/usr/bin/time -v ./program # Linux
# Leak / allocation analysis:
leaks --atExit -- ./program # macOS
valgrind --tool=massif ./program # LinuxCode Formatting
Format Single File
wyn fmt program.wynFormat Project
wyn fmt src/ # formats all .wyn files recursively
wyn fmt src/ --check # check only (for CI)Format on Save
Configure your editor to run wyn fmt on save.
VS Code: Set "wyn.formatOnSave": true
Vim: Add to .vimrc:
autocmd BufWritePre *.wyn !wyn fmt %Linting
Wyn's checker doubles as the linter - wyn check reports errors and warnings without compiling:
wyn check program.wynCommon Warnings
- Unused variables
- Unreachable code
- Missing return on some paths (this one is an error)
wyn fix applies automatic migrations for deprecated syntax.
Documentation Generation
Generate Docs
wyn doc src/This generates HTML documentation from your code and comments.
Documentation Comments
// Calculates the sum of two integers.
//
// # Arguments
// * a - First integer
// * b - Second integer
//
// # Returns
// The sum of a and b
//
// # Example
// ```
// var sum = add(2, 3) // 5
// ```
pub fn add(a: int, b: int) -> int {
return a + b
}Package Management
Add packages from any Git host (bare names resolve to github.com/wynlang/<name>):
wyn pkg add sqlite # SQLite database
wyn pkg add github.com/user/[email protected] # any repo, pinned to a ref
wyn pkg install # install all deps from wyn.lock / wyn.toml
wyn pkg list # show declared dependencies
wyn pkg remove redis # remove
wyn pkg search sqlite # search wynlang org + wyn-package topic
wyn pkg audit # verify lock vs remotesDependencies are declared in wyn.toml:
[dependencies]
sqlite = "github.com/wynlang/sqlite"Official packages include: sqlite, redis, http-client, pg, mysql, gui, raylib, https, and more.
Editor Comparison
| Feature | VS Code | Vim/Neovim | Other |
|---|---|---|---|
| Syntax Highlighting | ✅ | ✅ | ✅ |
| Code Completion | ✅ | ✅ (LSP) | ✅ (LSP) |
| Go to Definition | ✅ | ✅ (LSP) | ✅ (LSP) |
| Error Checking | ✅ | ✅ (LSP) | ✅ (LSP) |
| Debugging | ✅ | ⚠️ | ⚠️ |
| Refactoring | ✅ | ⚠️ | ⚠️ |
✅ = Full support, ⚠️ = Partial support
Recommended Setup
For the best experience:
- Editor: VS Code with Wyn extension
- Build: Makefile or build script
- Testing: Test runner script
- CI: GitHub Actions
- Formatting: Auto-format on save
- Linting: Run on save
This gives you:
- Fast feedback
- Consistent code style
- Automated testing
- Professional workflow
For language features, see Appendix A. For troubleshooting, see Appendix E.
CLI Reference
Develop
| Command | Description |
|---|---|
wyn run <file> | Compile and run |
wyn run -e 'code' | Evaluate inline code |
wyn check <file> | Type-check without compiling |
wyn fmt <file|dir> | Format source files |
wyn fmt <dir> --check | Check formatting (for CI) |
wyn test | Run project tests |
wyn test <filter> | Run only test files whose path matches |
wyn repl | Interactive REPL |
wyn bench <file> | Benchmark with timing and comparison |
wyn doc <file> | Generate documentation |
wyn doc <file> --html | Generate HTML documentation |
Build
| Command | Description |
|---|---|
wyn build <file|dir> | Build binary |
wyn build <file> --shared | Build shared library |
wyn build <file> --python | Build shared library + Python wrapper |
wyn cross <target> <file> | Cross-compile (linux/macos/windows/ios/android) |
wyn build-runtime | Precompile runtime for faster builds |
Deploy
| Command | Description |
|---|---|
wyn deploy <target> | Deploy to server (reads wyn.toml) |
wyn deploy <target> --dry-run | Preview deployment |
wyn ssh <target> | SSH into deploy target |
wyn logs <target> | Tail remote service logs |
Project
| Command | Description |
|---|---|
wyn init <name> | Create new project |
wyn init <name> --web | Create web app project |
wyn init <name> --cli | Create CLI tool project |
wyn init <name> --lib | Create library project |
Tools
| Command | Description |
|---|---|
wyn upgrade | Self-update to latest version |
wyn upgrade <version> | Pin to a specific release (e.g. wyn upgrade 1.18.0) |
wyn explain <code> | Explain an error code |
wyn doctor | Check your setup |
wyn version | Show version |
wyn help | Show help |
Flags
| Flag | Description |
|---|---|
--fast | Skip optimizations (fastest compile) |
--release | Full optimizations (-O3) |
--debug | Keep .c and .out artifacts |