Author: DanexCodr
Date: December 15, 2025
Repository: https://github.com/DanexCodr/Coderive
The Three-World System: Scripting, Functional, and OOP in Harmony
A Language for Every Task
Coderive v0.3.0 introduces a revolutionary approach: three distinct program types that share a common syntax but optimize for different development paradigms.
World 1: Scripts - Direct and Immediate
Scripts are the simplest form of Coderive programs—perfect for automation, quick calculations, and learning:
// Simple script - executes top-down
output "=== Temperature Converter ==="
fahrenheit: float = (float) input "Enter °F: "
celsius: float = (fahrenheit - 32) * 5 / 9
output fahrenheit + "°F = " + celsius + "°C"
Characteristics:
· No classes or methods required
· Direct statement execution
· Perfect for one-off tasks
· Implicit Script type wrapper
World 2: Method Scripts - Functional Focus
Method Scripts bridge scripting and modular programming, focusing on reusable functions:
// Method script - only functions, no classes
local calculateBMI(weight: float, height: float) :: bmi: float {
bmi = weight / (height * height) ::
}
local categorizeBMI(bmi: float) :: category: text {
if bmi < 18.5 {
category = "Underweight" ::
} else if bmi < 25 {
category = "Normal" ::
} else if bmi < 30 {
category = "Overweight" ::
} else {
category = "Obese" ::
}
}
share main() {
output "BMI Calculator"
weight := (float) input "Weight (kg): "
height := (float) input "Height (m): "
bmi := calculateBMI(weight, height)
category := categorizeBMI(bmi)
output "BMI: " + bmi + " (" + category + ")"
}
Characteristics:
· Only functions allowed
· main() method as entry point
· Encourages pure functions
· Implicit MethodScript container
World 3: Modules - Full Object-Oriented Programming
Modules represent Coderive's most powerful form, supporting classes, inheritance, and complex systems:
unit BankingSystem
use {
lang.Sys,
math.Finance
}
share BankAccount {
// Fields
owner: text
balance: float
accountNumber: int
// Constructor
share this(ownerName: text, initialDeposit: float) {
owner = ownerName
balance = initialDeposit
accountNumber = generateAccountNumber()
}
// Methods
local deposit(amount: float) :: newBalance: float {
balance = balance + amount
~> newBalance: balance
}
local withdraw(amount: float) :: success: bool, newBalance: float {
if amount <= balance {
balance = balance - amount
~> success: true, newBalance: balance
} else {
~> success: false, newBalance: balance
}
}
// Private helper
private generateAccountNumber() :: number: int {
// Implementation details...
}
}
share main() {
account := BankAccount("Alice", 1000.0)
result := account.withdraw(500)
if result.success {
output "Withdrawal successful. New balance: " + result.newBalance
}
}
Characteristics:
· Full class support with PascalCase naming
· Constructors with this keyword
· Public and private methods
· Multiple return values via slots
· Explicit unit declarations
The Interpreter's Role
The Coderive interpreter intelligently handles all three world types:
// In Interpreter.java
private void runModule(ProgramNode program) {
// Find and execute main() in a class
// Full OOP support
}
private void runScript(ProgramNode program) {
// Execute statements directly
// No method/class overhead
}
private void runMethodScript(ProgramNode program) {
// Find main() method in synthetic type
// Function-focused execution
}
Design Philosophy
The Three-World System addresses fundamental programming needs:
- Beginner-Friendly: Scripts lower the barrier to entry
- Functional Elegance: Method Scripts encourage clean, testable code
- Enterprise-Ready: Modules support large-scale development
Practical Benefits
For Education:
· Students start with scripts, progress to functions, then learn OOP
· Gradual complexity increase matches learning curves
For Development:
· Quick prototypes as scripts
· Utility libraries as method scripts
· Production systems as modules
For Maintenance:
· Clear boundaries between different abstraction levels
· Easy migration between paradigms as needs change
The Vision Realized
This tri-modal approach represents a bold vision: one language that adapts to the programmer's needs, rather than forcing the programmer to adapt to the language. It acknowledges that different tasks require different tools, and provides all three in a cohesive, consistent syntax.