Application Development Approaches
Comparing Built-in Apps, GXM Native Apps, and GXM Scripts
Overview
guideXOS provides three distinct approaches for creating applications, each optimized for different scenarios:
Type: Native C# compiled into OS
Location: DefaultApps/
Examples: File Manager, Task Manager, WAV Player
Best For: Core system utilities
Type: C# compiled to native binary
Location: Separate .gxm files
Examples: Custom applications with complex logic
Best For: Third-party applications
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
- Add
MyApp.cstoDefaultApps/ - Register in
OS/App.csswitch statement - Rebuild entire guideXOS binary
- Rebuild ISO image
- Reboot to test changes
? Advantages
- Full API Access: Direct access to kernel, drivers, memory
- Maximum Performance: Compiled to native code, no interpretation overhead
- Type Safety: Compile-time type checking prevents runtime errors
- Advanced Features: Custom controls, animations, effects
- Complex Logic: Implement sophisticated algorithms and state machines
- Deep Integration: Can modify OS behavior, hook into system events
- Debugging: Full C# debugging support in Visual Studio
? Disadvantages
- Larger Binary: Every app increases OS size (~50-100KB per app)
- Slow Updates: Must rebuild entire OS for any change
- No Modularity: Apps cannot be updated independently
- Long Build Times: Full OS rebuild takes 5-15 minutes
- No User Customization: Users cannot modify apps
- High Barrier: Requires C# knowledge and OS source code
- Tight Coupling: Apps tied to specific OS version
?? 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
- Write C# application
- Compile with NativeAOT:
dotnet publish -c Release -r win-x64 --self-contained - Package:
GXMPackager.exe MyApp.exe MyApp.gxm --entry 0x1000 - Copy
MyApp.gxmtoRamdisk/Programs/ - Rebuild ISO (to include new file in Ramdisk)
- Boot and run from console or Start Menu
? Advantages
- Modular Distribution: Apps distributed as separate files
- Smaller OS: Apps not compiled into OS binary
- Independent Updates: Update apps without rebuilding OS
- Full C# Power: Write complex logic in C#
- Native Performance: Compiled to native code
- Version Independence: Apps can target different OS versions
- Third-party Apps: Developers can distribute apps without OS source
? Disadvantages
- Limited API Access: No direct access to OS internals (security boundary)
- Syscall Overhead: Must use syscalls for OS features
- Complex Build: Requires NativeAOT setup and configuration
- Large Binary Size: NativeAOT output can be 5-20MB per app
- Debugging Challenges: Harder to debug than built-in apps
- Entry Point Management: Must specify RVA correctly
- Still Requires Rebuild: ISO must be rebuilt to deploy
?? 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 |
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
- Create
myapp.txtwith script commands - Package:
GXMPackager.exe myapp.txt myapp.gxm --script myapp.txt - Copy
myapp.gxmtoRamdisk/Programs/ - Rebuild ISO
- Launch from Start Menu or console
? Advantages
- ?? Ultra-Fast Development: No compilation, just edit text
- ?? Simple Syntax: No programming knowledge required
- ?? Rapid Iteration: Edit ? Package ? Test in seconds
- ?? User Customization: Users can modify UI without coding
- ?? Tiny File Size: Scripts are 1-5KB (vs. MB for compiled apps)
- ?? UI Prototyping: Test layouts quickly
- ?? Easy to Learn: Simple command reference
- ?? Community Friendly: Anyone can create apps
? Disadvantages
- Limited Logic: No complex algorithms or calculations
- Predefined Controls Only: BUTTON, LABEL, TEXTBOX, LIST, DROPDOWN
- No Custom Rendering: Cannot draw pixels directly
- Action Limitations: Only predefined actions (NOTIFY, CLOSE, OPENAPP, etc.)
- No State Management: Limited to simple event handlers
- Runtime Interpretation: Slight parsing overhead
- No Type Safety: Errors only caught at runtime
?? 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
NOTIFY|Message- Show notificationCLOSE|- Close windowOPENAPP|AppName- Launch another appSAVEDIALOG|DefaultFile- Open save dialogOPENDIALOG|- Open file dialogCLEAR|ControlId- Clear control content
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
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
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
- ? Identify apps suitable for GXM scripts (UI-driven, simple logic)
- ? Create
.txtscript with WINDOW, controls, events - ? Package with GXMPackager
- ? Copy to
Ramdisk/Programs/ - ? Update
App.csto useLaunchGXMFromFile() - ? Test functionality
- ? Remove old
.csfile fromDefaultApps/ - ? 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:
- Use GXM scripts for UI-driven applications
- Keep built-in apps for core system utilities
- Prototype with scripts, then migrate to built-in if needed
- Extend GXMLoader for common operations (CALCULATE, CANVAS, IMAGE)
- Document which approach you're using in README
? Don't:
- Don't make everything a built-in app (bloats OS)
- Don't use scripts for complex algorithms
- Don't use GXM Native apps unless absolutely necessary
- Don't forget to update App.cs when migrating
- Don't mix approaches without clear reasoning
Future Enhancements
Planned GXM Script Features
- ?? CANVAS - Drawing area for Paint app
- ??? IMAGE - Display images in Image Viewer
- ?? CALCULATE - Arithmetic for Calculator
- ?? MENUBAR - Menu bar support
- ?? TOOLBAR - Toolbar widget
- ?? STATUSBAR - Status bar at bottom
- ?? THEME - Color theme support
- ?? VAR - Variable storage and logic
- ?? IF/ELSE - Conditional execution
- ?? LOOP - Iteration support
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
GXM.Apps/Apps/README.md- Complete GXM app documentationGXM.Apps/Apps/QUICKSTART.md- Quick start guideKernel/Misc/GXMLoader.cs- Script interpreter source codeOS/App.cs- Application loader