Application Development Approaches

Comparing Built-in Apps, GXM Native Apps, and GXM Scripts

Three Ways to Build Apps: guideXOS supports three distinct approaches for application development, each with unique advantages and use cases.

Overview

guideXOS provides three distinct approaches for creating applications, each optimized for different scenarios:

1. Built-in Apps

Type: Native C# compiled into OS

Location: DefaultApps/

Examples: File Manager, Task Manager, WAV Player

Best For: Core system utilities

2. GXM Native Apps

Type: C# compiled to native binary

Location: Separate .gxm files

Examples: Custom applications with complex logic

Best For: Third-party applications

3. GXM Script Apps

Type: Declarative text scripts

Location: .txt ? .gxm

Examples: Notepad, Welcome, Settings dialogs

Best For: UI-driven applications


Approach 1: Built-in Apps (Native C#)

Description

Applications written in C# and compiled directly into the guideXOS kernel binary. These apps have full access to all OS internals and are loaded at boot time.

Architecture

guideXOS Binary
??? Kernel/
??? GUI/
??? Drivers/
??? DefaultApps/        ? Built-in apps here
    ??? Notepad.cs
    ??? Calculator.cs
    ??? Paint.cs
    ??? ImageViewer.cs
    ??? FileManager.cs
    ??? TaskManager.cs

Code Example

// DefaultApps/MyApp.cs
using guideXOS.GUI;
using guideXOS.FS;

namespace guideXOS.DefaultApps {
    internal class MyApp : Window {
        public MyApp(int x, int y) : base(x, y, 600, 400) {
            Title = "My Application";
            IsResizable = true;
            ShowInTaskbar = true;
            // Full access to OS internals
            var files = Directory.GetFiles("/");
            // Custom rendering, events, logic
        }
        
        public override void OnDraw() {
            base.OnDraw();
            // Direct framebuffer access
            Framebuffer.Graphics.DrawRectangle(X + 10, Y + 10, 200, 100, 0xFFFFFFFF, 2);
        }
    }
}

Deployment

  1. Add MyApp.cs to DefaultApps/
  2. Register in OS/App.cs switch statement
  3. Rebuild entire guideXOS binary
  4. Rebuild ISO image
  5. Reboot to test changes

? Advantages

? Disadvantages

?? Use Cases

Application Type Why Built-in?
File Manager Requires direct file system access, complex tree navigation
Task Manager Needs process enumeration, system monitoring
Console/Terminal Executes commands, requires kernel interaction
Network Settings Configures DHCP, DNS, firewall (system-level)
Disk Manager Partition management, low-level disk operations

Approach 2: GXM Native Apps (Compiled Binary)

Description

Applications written in C# and compiled to native code using NativeAOT, then packaged as .gxm files. These apps are loaded dynamically at runtime.

Architecture

Development:
MyApp/
??? MyApp.cs          ? Your C# code
??? MyApp.csproj
??? Program.cs

Build Process:
1. Compile with NativeAOT ? MyApp.exe (native binary)
2. Package with GXMPackager ? MyApp.gxm
3. Deploy to Ramdisk/Programs/

Runtime:
guideXOS loads MyApp.gxm ? Executes in user mode

Code Example

// MyApp.cs
using System;

namespace MyApp {
    public class Program {
        [UnmanagedCallersOnly(EntryPoint = "main")]
        public static int Main() {
            // Custom logic here
            // NOTE: Limited API access (no direct OS internals)
            // Must use syscalls or provided interfaces
            
            // Example: Basic calculation
            int result = 5 + 3;
            return result;
        }
    }
}

// Build:
// dotnet publish -c Release -r win-x64 --self-contained
// GXMPackager.exe MyApp.exe MyApp.gxm --entry 0x1000

Deployment

  1. Write C# application
  2. Compile with NativeAOT: dotnet publish -c Release -r win-x64 --self-contained
  3. Package: GXMPackager.exe MyApp.exe MyApp.gxm --entry 0x1000
  4. Copy MyApp.gxm to Ramdisk/Programs/
  5. Rebuild ISO (to include new file in Ramdisk)
  6. Boot and run from console or Start Menu

? Advantages

? Disadvantages

?? Use Cases

Application Type Why GXM Native?
Third-party Games Complex logic, but isolated from OS
Scientific Calculators Complex math, no OS access needed
Data Processing Tools CPU-intensive algorithms
Custom Utilities User-developed tools distributed separately
?? Note: GXM Native apps are currently experimental. Most developers should use Built-in apps or GXM Scripts instead.

Approach 3: GXM Script Apps (Declarative)

Description

Applications defined using a simple text-based scripting language with pipe-delimited commands. Scripts are interpreted at runtime by GXMLoader.cs.

Architecture

Development:
notepad.txt           ? Simple text script

Script Format:
WINDOW|Title|Width|Height
LABEL|Text|X|Y
BUTTON|Id|Text|X|Y|Width|Height
ONCLICK|Id|Action|Argument

Build Process:
GXMPackager.exe notepad.txt notepad.gxm --script notepad.txt

Runtime:
GXMLoader.cs reads script ? Creates GXMScriptWindow ? Displays UI

Script Example

WINDOW|Notepad|700|460
RESIZABLE|true
TASKBAR|true
MAXIMIZE|true
MINIMIZE|true
TOMBSTONE|true
STARTMENU|true
TEXTBOX|1|10|40|680|370|
BUTTON|100|Save As...|10|420|88|28
BUTTON|101|Open...|108|420|72|28
BUTTON|102|New|190|420|60|28
BUTTON|103|Close|260|420|72|28
ONCLICK|100|SAVEDIALOG|notes.txt
ONCLICK|101|OPENDIALOG|
ONCLICK|102|CLEAR|1
ONCLICK|103|CLOSE|
LABEL|guideXOS Notepad - Type your notes here|10|10

Deployment

  1. Create myapp.txt with script commands
  2. Package: GXMPackager.exe myapp.txt myapp.gxm --script myapp.txt
  3. Copy myapp.gxm to Ramdisk/Programs/
  4. Rebuild ISO
  5. Launch from Start Menu or console

? Advantages

? Disadvantages

?? Use Cases

Application Type Why GXM Script?
Notepad Simple text editing, file dialogs built-in
Welcome Screen Static content, quick launch buttons
About Dialogs Display information, single OK button
Settings UI Forms with dropdowns, checkboxes (logic in OS)
Launchers Buttons that launch other apps
Wizards Step-by-step UI with Next/Back buttons
Contact Forms Input fields with submit button

Supported Commands

Command Syntax Description
WINDOW WINDOW|Title|Width|Height Create main window
RESIZABLE RESIZABLE|true/false Allow window resizing
TASKBAR TASKBAR|true/false Show in taskbar
LABEL LABEL|Text|X|Y Static text label
BUTTON BUTTON|Id|Text|X|Y|Width|Height Clickable button
TEXTBOX TEXTBOX|Id|X|Y|Width|Height|InitialText Text input area
LIST LIST|Id|X|Y|Width|Height|Items List selection
DROPDOWN DROPDOWN|Id|X|Y|Width|Height|Items Dropdown menu
ONCLICK ONCLICK|Id|Action|Argument Button click handler

Supported Actions


Feature Comparison Matrix

Feature Built-in Apps GXM Native Apps GXM Script Apps
Development Speed Slow (rebuild OS) Medium (compile + package) Fast (edit text)
Iteration Speed 5-15 min per change 2-5 min per change 10-30 sec per change
File Size 50-100KB per app 5-20MB per app 1-5KB per app
OS Binary Size Impact Increases OS size No impact No impact
API Access Full (kernel, drivers, all) Limited (syscalls only) Minimal (predefined)
Performance Native (fastest) Native (fast) Interpreted (slight overhead)
Complex Logic Unlimited Full C# capabilities Very limited
Custom Graphics Full framebuffer access Limited (user mode) None
Type Safety Compile-time Compile-time Runtime only
Debugging Full VS debugging Limited debugging No debugging
User Customization Impossible Impossible Easy (edit .txt)
Third-party Distribution Requires OS source Standalone .gxm Standalone .gxm
Learning Curve C# + OS internals C# + NativeAOT Simple text commands
Build Tools Required .NET SDK + OS build .NET SDK + NativeAOT GXMPackager only
Update Process Rebuild OS + ISO Repackage + ISO Repackage + ISO
Community Contributions Very difficult Moderate Very easy

When to Use Each Approach

Use Built-in Apps For:
  • Core System Utilities
    • File Manager
    • Task Manager
    • Console/Terminal
    • Disk Manager
  • System Configuration
    • Network Settings
    • Firewall Manager
    • Hardware Configuration
  • Performance-Critical Apps
    • WAV Player (audio processing)
    • Image Viewer (decoding, scaling)
    • Web Browser (rendering)
  • Apps Needing Deep Integration
    • HD Installer
    • Boot Manager
    • Driver Configuration
Use GXM Native Apps For:
  • Third-Party Applications
    • Games
    • Custom utilities
    • User-developed tools
  • Complex Logic Without OS Access
    • Scientific calculator
    • Data processors
    • Encryption tools
  • Isolated Applications
    • Sandboxed tools
    • Untrusted code
Note: Currently experimental. Most use cases better served by other approaches.
Use GXM Script Apps For:
  • Simple Utilities
    • Notepad (basic editing)
    • Calculator (UI only)
    • About dialogs
  • UI-Driven Apps
    • Welcome screen
    • Launchers
    • Quick tools
  • Forms and Dialogs
    • Settings UI
    • Contact forms
    • Wizards
  • Prototypes
    • UI mockups
    • Design testing
    • Concept validation
  • User-Customizable Apps
    • Personal tools
    • Configurable utilities

Hybrid Development Strategy

The most effective approach is to use a hybrid strategy that leverages the strengths of each method:

Recommended Distribution

Optimal App Distribution Strategy
Built-in Apps (30%)
  • File Manager
  • Task Manager
  • Console
  • Network Settings
  • Disk Manager
  • WAV Player
  • Image Viewer
  • Web Browser

Core system utilities requiring OS access

GXM Script Apps (70%)
  • Notepad
  • Welcome
  • About Dialog
  • Settings UI
  • Launchers
  • Wizards
  • Simple tools

UI-driven apps and utilities

Example: Calculator as Hybrid App

The Calculator demonstrates how to combine approaches:

GXM Script (UI)
WINDOW|Calculator|320|420
RESIZABLE|false
BUTTON|1|7|20|80|60|50
BUTTON|2|8|90|80|60|50
...
BUTTON|16|=|20|320|200|50
ONCLICK|1|CALCULATE|7
ONCLICK|16|CALCULATE|EQUALS
Native Logic (in GXMLoader.cs)
else if(action == "CALCULATE") {
    // Implement calculation logic
    if(arg == "EQUALS") {
        double result = PerformCalculation();
        win.UpdateLabel("display", result);
    } else {
        AddToCalculation(arg);
    }
}

Benefits: Fast UI iteration + powerful calculation logic

Extending GXM Scripts

To make GXM scripts more powerful, add new actions to Kernel/Misc/GXMLoader.cs:

// Example: Add CANVAS for Paint app
else if(StringEquals(cmd,"CANVAS")) {
    // CANVAS|Id|X|Y|Width|Height
    win.AddCanvas(id, x, y, w, h);
}

// Example: Add IMAGE for Image Viewer
else if(StringEquals(cmd,"IMAGE")) {
    // IMAGE|Id|Path|X|Y
    win.LoadAndDisplayImage(id, path, x, y);
}

// Example: Add CALCULATE action
else if(action == "CALCULATE") {
    // Perform arithmetic
    double result = Calculate(operation, value1, value2);
    win.UpdateLabel(labelId, result.ToString());
}

Migration Guide

Converting Built-in App to GXM Script

Example: Migrating Notepad

Before (Built-in)
// DefaultApps/Notepad.cs
internal class Notepad : Window {
    private string _text;
    private bool _dirty;
    
    public Notepad(int x, int y) 
        : base(x, y, 700, 460) {
        Title = "Notepad";
        IsResizable = true;
        ShowInTaskbar = true;
        // ... 300 lines of code
    }
    
    public override void OnDraw() {
        // Custom rendering
    }
    
    public override void OnInput() {
        // Event handling
    }
}

// OS/App.cs
case "Notepad":
    _apps[i].AppObject = new Notepad(300, 200);
    b = true;
    break;
After (GXM Script)

WINDOW|Notepad|700|460
RESIZABLE|true
TASKBAR|true
MAXIMIZE|true
MINIMIZE|true
TOMBSTONE|true
STARTMENU|true
TEXTBOX|1|10|40|680|370|
BUTTON|100|Save As...|10|420|88|28
BUTTON|101|Open...|108|420|72|28
BUTTON|102|New|190|420|60|28
BUTTON|103|Close|260|420|72|28
ONCLICK|100|SAVEDIALOG|notes.txt
ONCLICK|101|OPENDIALOG|
ONCLICK|102|CLEAR|1
ONCLICK|103|CLOSE|
LABEL|guideXOS Notepad|10|10
// OS/App.cs
case "Notepad":
    b = LaunchGXMFromFile(
        "Programs/notepad.gxm", 
        _apps[i].Icon
    );
    break;

Result: 300 lines of C# ? 15 lines of script! ?

Migration Checklist

  1. ? Identify apps suitable for GXM scripts (UI-driven, simple logic)
  2. ? Create .txt script with WINDOW, controls, events
  3. ? Package with GXMPackager
  4. ? Copy to Ramdisk/Programs/
  5. ? Update App.cs to use LaunchGXMFromFile()
  6. ? Test functionality
  7. ? Remove old .cs file from DefaultApps/
  8. ? Rebuild OS (smaller binary!)

Apps Successfully Migrated to GXM Scripts

Application Original Size (C#) Script Size Reduction
Notepad ~4KB source (300 lines) ~427 bytes 90% smaller
Welcome ~3KB source ~1.1KB 65% smaller
Calculator (UI) ~4KB source ~970 bytes 75% smaller
Paint (UI) ~3KB source ~1.1KB 65% smaller
Image Viewer (UI) ~5KB source ~964 bytes 80% smaller

Development Workflow Comparison

Built-in App Workflow

1. Edit .cs file in DefaultApps/
2. Build entire OS (5-15 minutes)
3. Build ISO (2-5 minutes)
4. Boot VM
5. Test app
6. Find bug
7. Repeat steps 1-6

Total iteration time: 15-30 minutes

GXM Script Workflow

1. Edit .txt file
2. Run: build-all.ps1 (10 seconds)
3. Run: deploy.ps1 (30 seconds)
4. Boot VM (if not running)
5. Test app
6. Find issue
7. Repeat steps 1-3

Total iteration time: 1-2 minutes (15x faster!)

Performance Benchmarks

Metric Built-in Apps GXM Native Apps GXM Script Apps
Launch Time Instant (pre-loaded) 50-200ms (load from disk) 50-100ms (parse script)
Memory Usage 50-200KB per app 100KB-5MB per app 20-100KB per app
File Size N/A (in OS binary) 5-20MB 1-5KB
Render Speed 60 FPS (native) 60 FPS (native) 60 FPS (interpreted)
Event Response <1ms <5ms <10ms

Best Practices

? Do:
? Don't:

Future Enhancements

Planned GXM Script Features


Summary

Quick Decision Guide
Need OS internals? ? Built-in App
Simple UI with buttons? ? GXM Script
Third-party distribution? ? GXM Script (or Native if complex)
Complex algorithms? ? Built-in App (or extend GXMLoader)
Rapid prototyping? ? GXM Script
Performance critical? ? Built-in App
User customization? ? GXM Script

See Also

?? Related Documentation: