Skip to content

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

  1. Install VS Code

    bash
    # macOS
    brew install --cask visual-studio-code
    
    # Linux
    snap install code --classic
    
    # Or download from https://code.visualstudio.com
  2. Install Wyn Extension

    • Open VS Code
    • Press Cmd+Shift+X (macOS) or Ctrl+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) or Ctrl+Click to jump to definition
  • Works for functions, types, variables

Find References

  • Right-click → Find All References
  • See where a symbol is used

Formatting

  • Shift+Alt+F to 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:

json
{
  "wyn.compilerPath": "/path/to/wyn",
  "wyn.formatOnSave": true,
  "wyn.lintOnSave": true,
  "editor.tabSize": 4,
  "editor.insertSpaces": true,
  "files.trimTrailingWhitespace": true
}

Keyboard Shortcuts

ActionmacOSLinux/Windows
Go to DefinitionCmd+ClickCtrl+Click
Find ReferencesShift+F12Shift+F12
Rename SymbolF2F2
Format DocumentShift+Alt+FShift+Alt+F
Quick FixCmd+.Ctrl+.
Command PaletteCmd+Shift+PCtrl+Shift+P

Vim/Neovim Setup

For Vim users, Wyn provides syntax files and LSP support.

Installation

  1. Install syntax files

    bash
    mkdir -p ~/.vim/syntax
    cp wyn/editors/vim/wyn.vim ~/.vim/syntax/
    
    # Add to ~/.vimrc
    au BufRead,BufNewFile *.wyn set filetype=wyn
  2. Install 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

bash
wyn lsp

This 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:

json
{
  "compilerPath": "/path/to/wyn",
  "checkOnSave": true,
  "formatOnSave": false,
  "maxDiagnostics": 100
}

Build Tools

Makefile

For projects with multiple files:

makefile
# 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 test

Usage:

bash
make          # Build
make run      # Build and run
make test     # Run tests
make clean    # Clean build artifacts

Build Script

For more complex builds:

bash
#!/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:

bash
chmod +x build.sh
./build.sh

Debugging

The simplest approach:

wyn
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:

bash
wyn build program.wyn --debug
# Keeps program.wyn.c alongside the binary

Using the Built-in Debugger

bash
wyn debug program.wyn

This compiles with DWARF debug info and launches lldb (macOS/Linux). You can set breakpoints on .wyn source lines and step through your code:

bash
(lldb) breakpoint set --name main
(lldb) run
(lldb) step
(lldb) print variable_name
(lldb) continue

GDB 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.wyn

math.wyn:

wyn
export fn add(a: int, b: int) -> int { return a + b }

math_test.wyn:

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:

bash
wyn run math_test.wyn

Test Runner Script

bash
#!/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
fi

Continuous Integration

GitHub Actions

Create .github/workflows/ci.yml:

yaml
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/program

Profiling

Wyn binaries are ordinary native executables - the standard system profilers work on them directly, no special flags needed.

Time Profiling

bash
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 report

Memory Profiling

bash
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       # Linux

Code Formatting

Format Single File

bash
wyn fmt program.wyn

Format Project

bash
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:

vim
autocmd BufWritePre *.wyn !wyn fmt %

Linting

Wyn's checker doubles as the linter - wyn check reports errors and warnings without compiling:

bash
wyn check program.wyn

Common 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

bash
wyn doc src/

This generates HTML documentation from your code and comments.

Documentation Comments

wyn
// 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>):

bash
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 remotes

Dependencies are declared in wyn.toml:

toml
[dependencies]
sqlite = "github.com/wynlang/sqlite"

Official packages include: sqlite, redis, http-client, pg, mysql, gui, raylib, https, and more.

Editor Comparison

FeatureVS CodeVim/NeovimOther
Syntax Highlighting
Code Completion✅ (LSP)✅ (LSP)
Go to Definition✅ (LSP)✅ (LSP)
Error Checking✅ (LSP)✅ (LSP)
Debugging⚠️⚠️
Refactoring⚠️⚠️

✅ = Full support, ⚠️ = Partial support

For the best experience:

  1. Editor: VS Code with Wyn extension
  2. Build: Makefile or build script
  3. Testing: Test runner script
  4. CI: GitHub Actions
  5. Formatting: Auto-format on save
  6. 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

CommandDescription
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> --checkCheck formatting (for CI)
wyn testRun project tests
wyn test <filter>Run only test files whose path matches
wyn replInteractive REPL
wyn bench <file>Benchmark with timing and comparison
wyn doc <file>Generate documentation
wyn doc <file> --htmlGenerate HTML documentation

Build

CommandDescription
wyn build <file|dir>Build binary
wyn build <file> --sharedBuild shared library
wyn build <file> --pythonBuild shared library + Python wrapper
wyn cross <target> <file>Cross-compile (linux/macos/windows/ios/android)
wyn build-runtimePrecompile runtime for faster builds

Deploy

CommandDescription
wyn deploy <target>Deploy to server (reads wyn.toml)
wyn deploy <target> --dry-runPreview deployment
wyn ssh <target>SSH into deploy target
wyn logs <target>Tail remote service logs

Project

CommandDescription
wyn init <name>Create new project
wyn init <name> --webCreate web app project
wyn init <name> --cliCreate CLI tool project
wyn init <name> --libCreate library project

Tools

CommandDescription
wyn upgradeSelf-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 doctorCheck your setup
wyn versionShow version
wyn helpShow help

Flags

FlagDescription
--fastSkip optimizations (fastest compile)
--releaseFull optimizations (-O3)
--debugKeep .c and .out artifacts

MIT License - v1.19.1