Median

Median is a high-performance programming language with flexible execution modes and comprehensive package system, designed for both interactive development and production environments.

2025 Standard

This version introduces stable package management, improved memory control, enhanced Unicode support, and branch processing capabilities.

Key Features

Multiple Execution Modes

Choose between interpreter and optimized compilers

Package System

Extend functionality with modular packages

Unicode Support

Advanced character processing capabilities

Resource Control

Precise memory management and limits

Branch Processing

Conditional execution flows with => operator

Error Logging

Comprehensive error tracking (requires FL + fl-rec)

Core Concepts

Execution Modes

Median provides three distinct execution strategies:

Mode Command Best For Memory Use Package Support
Direct Interpreter ~compil DI Debugging, development Low DI Packages
Flexible Compiler ~compil FL Balanced performance Medium FL Packages (fl-rec for error logging)
Direct Compiler ~compil DC Production code High None

System Commands

All system commands begin with ~ and control the Median environment.

~compil COMPILER CONTROL
Sets or displays the current compilation mode. This command is always available.
Usage:
~compil [mode]

Examples:

// List available modes
~compil

// Set to Direct Interpreter
~compil DI

// Set to Flexible Compiler
~compil FL

// Disable compilation
~compil null
~config CONFIGURATION
Manages runtime configuration settings. Requires the di-ext package.
Usage:
~config [set] [path] [value]

Examples:

// Show current configuration
~config

// Set memory limit to 1GB
~config set bash.memoryLimitMB 1024

// Enable strict mode
~config set compilerOptions.strictMode true
Requirements: di-ext package must be installed and active
~dipkg PACKAGE MANAGEMENT
Manages packages for the Direct Interpreter mode. Only available when DI is active.
Usage:
~dipkg [command] [package]

Examples:

// Install a package
~dipkg install di-ext

// Activate a package
~dipkg activate direct-actu

// List available packages
~dipkg available

// Show installed packages
~dipkg list
Requirements: DI compiler must be active
~flpkg PACKAGE MANAGEMENT
Manages packages for the Flexible Compiler mode. Only available when FL is active.
Usage:
~flpkg [command] [package]

Examples:

// Install a package
~flpkg install fl-gitbranch

// Activate a package
~flpkg activate fl-rec

// List available packages
~flpkg available

// Show installed packages
~flpkg list
Requirements: FL compiler must be active
~memory RESOURCE MONITORING
Displays current memory usage statistics. Always available.
Usage:
~memory

Example Output:

Memory usage: 247.18 MB / 512 MB (48.3%)
~reset SYSTEM CONTROL
Clears memory and compilation cache while preserving configuration. Always available.
Usage:
~reset

Example Output:

System state reset
Memory usage: 12.4 MB / 512 MB (2.4%)
~i SYSTEM INFORMATION
Displays comprehensive system status including package information. Requires direct-actu package.
Usage:
~i

Example Output:

=== SYSTEM INFORMATION ===

[Active Packages]
  directint (core)
  directint-sys (system)
  directint-api (api)

[System Status]
  Compiler: DI
  Memory: 45.23MB used
  Last Error: none
Requirements: direct-actu package must be installed and active
~logs ERROR LOGGING
Displays and filters error logs. Requires FL compiler with fl-rec package (dedicated logging package).
Usage:
~logs [filter_type] [filter_value]

Examples:

// Show all logs
~logs

// Filter by compiler
~logs compiler FL

// Filter by error type
~logs type MEMORY
Requirements: FL compiler must be active with fl-rec package

Compilation Modes

Direct Interpreter (DI)

Line-by-line execution with package support.

Key Characteristics

  • No compilation step
  • Supports modular packages
  • Best for debugging
  • Slower execution
  • Unicode conversion when API package inactive
  • No built-in error logging

Default Packages

Package Function Default
directint Core interpreter Active
directint-sys System commands Active
directint-api Standard API Active
Restricted Mode

If directint-sys is not active, only the ~compil command will be available for changing compilers.

Flexible Compiler (FL)

Balanced compilation with moderate optimizations and package support.

Key Characteristics

  • Just-In-Time compilation
  • Good development speed
  • Basic optimizations
  • Debug support
  • Branch processing with fl-gitbranch
  • Dedicated error logging with fl-rec

Configuration Options

// Default FL settings
optimizationLevel: 2  // 1-3
inlineFunctions: true // Enable function inlining
branches: false      // Auto-enabled by fl-gitbranch

Default Packages

Package Function Default
fl-var Variable support Active

Direct Compiler (DC)

Maximum performance compilation for production.

Key Characteristics

  • Ahead-Of-Time compilation
  • Aggressive optimizations
  • Fastest execution
  • Limited debugging
  • No package support
  • No error logging

Recommended Settings

// Production DC settings
optimizationLevel: 3
strictMode: true
debugSymbols: false

Package System

Modular system for extending Median functionality across different compilation modes.

Package States

Packages exist in three states within their respective environments:

Available

Can be installed from registry

~dipkg available
~flpkg available

Installed

Downloaded and ready for activation

~dipkg list
~flpkg list

Active

Currently loaded and functioning

~dipkg list
~flpkg list

DI Packages

Packages for Direct Interpreter mode

directint CORE

The fundamental package required for DI mode operation. Provides basic interpreter functionality.

Essential Package

This package cannot be uninstalled or deactivated while in DI mode.

Default State: Installed and Active
Dependencies: None
directint-sys SYSTEM

Enables system commands beyond basic compiler control. Required for most ~ commands.

Restricted Mode

When inactive, only ~compil command is available in DI mode.

Default State: Installed and Active
Dependencies: directint
directint-api API

Provides standard API functions and prevents automatic Unicode conversion of text.

// Without directint-api:
"Hello" → "U+48 U+65 U+6C U+6C U+6F"

// With directint-api:
"Hello" → "Hello"
Default State: Installed and Active
Dependencies: directint
di-ext EXTENSION

Adds configuration capabilities through the ~config command.

// Requires di-ext package:
~config set bash.memoryLimitMB 1024
Default State: Available but not active
Dependencies: directint-sys
direct-actu DIAGNOSTICS

Provides system information through the ~i command and enhances error reporting.

// Requires direct-actu package:
~i
// Shows package status and memory usage
Default State: Available but not active
Dependencies: directint-sys

FL Packages

Packages for Flexible Compiler mode

fl-var CORE

Essential package for FL mode that enables variable processing and basic functionality.

Mandatory Package

This package is automatically activated and cannot be deactivated in FL mode.

Default State: Installed and Active
Dependencies: None
fl-rec ERROR LOGGING

Provides comprehensive error logging capabilities for the Flexible Compiler mode. This package is dedicated solely to error tracking and does not provide any other functionality.

// Enables error logging system:
~logs
~logs type MEMORY
~logs compiler FL
Single Responsibility

This package only handles error logging and does not enable recursive functions or any other features.

Default State: Available but not active
Dependencies: fl-var
fl-gitbranch FLOW CONTROL

Enables branch processing with the => operator for conditional execution flows.

// Requires fl-gitbranch package:
build => test => deploy
cleanup => report
Automatic Configuration

Installing/activating this package automatically enables branch processing in FL mode.

Default State: Available but not active
Dependencies: fl-var

Package Management

Commands for managing packages in each mode:

Command DI Packages FL Packages
Install ~dipkg install [name] ~flpkg install [name]
Uninstall ~dipkg uninstall [name] ~flpkg uninstall [name]
Activate ~dipkg activate [name] ~flpkg activate [name]
Deactivate ~dipkg deactivate [name] ~flpkg deactivate [name]
List ~dipkg list ~flpkg list
Available ~dipkg available ~flpkg available
Package Compatibility

DI packages only work in DI mode, FL packages only work in FL mode. DC mode has no package support.

Configuration

Runtime Settings

Control execution environment parameters:

// Current runtime configuration
memoryLimitMB: 512     // Memory limit in MB
timeoutMs: 10000       // Execution timeout
maxOutputLines: 1000   // Output line limit
historySize: 50        // Command history size
autoScroll: true       // Auto-scroll output
theme: "dark"          // Interface theme

Example Configuration

// Set memory limit to 1GB
~config set bash.memoryLimitMB 1024

// Change timeout to 5 seconds
~config set bash.timeoutMs 5000

// Increase command history
~config set bash.historySize 100

Compiler Settings

Adjust compilation behavior:

// Current compiler configuration
optimizationLevel: 1   // 1-3
strictMode: false      // Strict syntax checking
debugSymbols: true     // Include debug info
inlineFunctions: true  // FL only - function inlining
branches: false        // FL only - branch processing

Example Configuration

// Set maximum optimization
~config set compilerOptions.optimizationLevel 3

// Enable strict mode
~config set compilerOptions.strictMode true

// Disable debug symbols
~config set compilerOptions.debugSymbols false

Error Handling

Error Types

Type Prefix Example
System System.exception Invalid command
Compiler Compiler.exception No compiler set
Package DI/FL Package.exception Missing package
Memory Memory.exception Limit exceeded
Configuration Config.exception Invalid setting
Runtime Runtime.exception Code execution error

Error Messages

Median provides descriptive error messages:

Example Error
FL Package.exception => Required package "fl-rec" is missing for logging

Error Logging

Median maintains detailed error logs when using FL compiler with fl-rec package:

// Setup dedicated logging system
~compil FL
~flpkg install fl-rec  // Install logging package
~flpkg activate fl-rec // Activate logging system

// View all logs
~logs

// Filter by error type
~logs type MEMORY

// Filter by command content
~logs command "failed to"
Log Retention

Error logs persist until system reset (~reset) and include memory usage, timestamps, and execution context.

Best Practices

Development Tips

Recommended Development Setup

// Set up for development
~compil DI
~dipkg install di-ext
~dipkg install direct-actu
~dipkg activate di-ext
~dipkg activate direct-actu
~config set compilerOptions.debugSymbols true
~config set bash.memoryLimitMB 1024

Debugging Workflow

  1. Start in DI mode with all packages
  2. Use ~i to check system status
  3. Monitor memory with ~memory
  4. For detailed error logs, switch to FL mode with fl-rec
  5. Reset state with ~reset when needed

Logging Setup

// Set up dedicated error logging
~compil FL
~flpkg install fl-rec  // Install logging package
~flpkg activate fl-rec // Activate logging system

// View and filter logs
~logs
~logs type RUNTIME

Optimization Guide

Production Configuration

// Optimized production setup
~compil DC
~config set compilerOptions.optimizationLevel 3
~config set compilerOptions.strictMode true
~config set bash.memoryLimitMB 256

Performance Tips

  • Use FL for development iterations with optimizations
  • Switch to DC for final production builds
  • Monitor memory usage patterns with ~memory
  • Reset state between major operations with ~reset
  • For production, disable debug symbols and enable max optimization

Appendix

Default Configuration

{
  "compiler": null,
  "compilerOptions": {
    "optimizationLevel": 1,
    "strictMode": false,
    "debugSymbols": true,
    "inlineFunctions": true,
    "branches": false
  },
  "bash": {
    "memoryLimitMB": 512,
    "timeoutMs": 10000,
    "maxOutputLines": 1000,
    "historySize": 50,
    "theme": "dark",
    "autoScroll": true
  }
}

Default Packages

// DI Packages
{
  "available": [
    "directint",
    "directint-sys",
    "directint-api",
    "di-ext",
    "direct-actu"
  ],
  "installed": [
    "directint",
    "directint-sys",
    "directint-api"
  ],
  "active": [
    "directint",
    "directint-sys",
    "directint-api"
  ]
}

// FL Packages
{
  "available": [
    "fl-var",
    "fl-rec",
    "fl-gitbranch"
  ],
  "installed": [
    "fl-var"
  ],
  "active": [
    "fl-var"
  ]
}

Quick Reference

Command Description Example
~compil Set compiler mode ~compil FL
~config Configure system ~config set memory 1024
~dipkg Manage DI packages ~dipkg install di-ext
~flpkg Manage FL packages ~flpkg install fl-rec
~memory Show memory usage ~memory
~reset Reset system state ~reset
~i System information ~i
~logs Error logs (requires FL + fl-rec) ~logs type MEMORY