Paradigm 4 of 4

Subject-Oriented Programming

Model autonomous domains with perspectives, roles, and inter-subject communication. Evolution of the Agent paradigm with boundaries and governance.

🚧 Full SOP support coming in v0.6.0

Current: Agent + Governance

HudHudScript currently supports these building blocks of SOP:

agent

Autonomous agents with model binding

constitution

Governance frameworks with laws

council

Multi-agent decision bodies

Working Example: Agent + Governance

Current approach using available features. This code compiles and runs today:

// English - Customer Service Agent

law respect_law {
    description: "The agent must be polite and respectful",
    priority: 1
}

constitution service_constitution {
    laws: [respect_law],
    description: "Customer service framework"
}

agent service_agent {
    model: "gpt-4"
}

function greet(customer_name) {
    let message = "Hello " + customer_name + ", how can I help you?";
    print(message);
    return message;
}

function handle_request(type, details) {
    if (type == "complaint") {
        print("I apologize for the inconvenience. I will help resolve your issue.");
    } else {
        print("Thank you for reaching out. I will process your request now.");
    }
    return "Processed: " + type + " - " + details;
}

print("=== Customer Service Agent ===");
greet("Alice");
let result = handle_request("complaint", "shipping delay");
print(result);

Code Organization

// English - Code Organization by Topic
// Organizing code into logical folders

// Project Structure:
// 
// project/
//   ├── agent/
//   │   ├── agent_definition.hudhud
//   │   ├── agent_tasks.hudhud
//   │   ├── agent_tools.hudhud
//   │   └── agent_providers.hudhud
//   │
//   ├── constitution/
//   │   ├── constitution.hudhud
//   │   ├── laws.hudhud
//   │   ├── rules.hudhud
//   │   ├── ruleset.hudhud
//   │   └── rulechain.hudhud
//   │
//   ├── data/
//   │   ├── note.hudhud
//   │   ├── chord.hudhud
//   │   ├── melody.hudhud
//   │   ├── harmony.hudhud
//   │   └── rhythm.hudhud
//   │
//   ├── governance/
//   │   ├── council.hudhud
//   │   ├── swarm.hudhud
//   │   ├── community.hudhud
//   │   └── enforcement.hudhud
//   │
//   ├── flow/
//   │   ├── dataflow.hudhud
//   │   ├── layer.hudhud
//   │   ├── network.hudhud
//   │   └── orchestration.hudhud
//   │
//   ├── state/
//   │   ├── entity.hudhud
//   │   ├── state_machine.hudhud
//   │   ├── event.hudhud
//   │   └── intent.hudhud
//   │
//   └── utils/
//       ├── math.hudhud
//       ├── physics.hudhud
//       ├── chemistry.hudhud
//       └── helpers.hudhud

// Benefits of this organization:
// 1. Clear separation of concerns
// 2. Easy to find related code
// 3. Scalable for large projects
// 4. Team collaboration friendly
// 5. Modular and maintainable

// Example imports:
// use "agent/agent_definition.hudhud";
// use "constitution/laws.hudhud";
// use "data/note.hudhud";
// use "utils/math.hudhud";

Multilingual

// Türkçe - Müşteri Hizmetleri Ajanı

yasa saygi_yasasi {
    açıklama: "Ajan nazik ve saygılı olmalıdır",
    öncelik: 1
}

anayasa hizmet_anayasasi {
    yasalar: [saygi_yasasi],
    açıklama: "Müşteri hizmetleri çerçevesi"
}

ajan hizmet_ajanı {
    model: "gpt-4"
}

işlev karşıla(müşteri_adı) {
    değişken mesaj = "Merhaba " + müşteri_adı + ", size nasıl yardımcı olabilirim?";
    yazdır(mesaj);
    dön mesaj;
}

işlev talep_işle(tür, detay) {
    eğer (tür == "şikayet") {
        yazdır("Rahatsızlık için özür dilerim. Sorununuzu çözmek için buradayım.");
    } değilse {
        yazdır("İletişime geçtiğiniz için teşekkürler. Talebinizi şimdi işliyorum.");
    }
    dön "İşlendi: " + tür + " - " + detay;
}

yazdır("=== Müşteri Hizmetleri Ajanı ===");
karşıla("Ahmet");
değişken sonuç = talep_işle("şikayet", "kargo gecikmesi");
yazdır(sonuç);

SOP Concept Preview

How the same system will look with full SOP support:

future_sop_version.hudhud (v0.6.0) 🔒 Not Yet Available
// SOP Version - Domain boundaries with subjects

subject CustomerService {
    // Provider binding
    provider OpenAI { token: env("OPENAI_KEY") }
    
    // State
    state ticket_count: Int = 0
    
    // Events and Effects
    event TicketCreated { agent: Agent, type: Text }
    
    effect on TicketCreated {
        ticket_count += 1
    }
}

// Usage
spawn CustomerService;

What SOP Adds

  • Domain Boundaries: subjects isolate agents and rules
  • State Management: subject-level state with effects
  • Event System: event → effect chain
  • Inter-Subject Communication: protocols for cross-domain messaging

Planned SOP Keywords

subject

Domain boundary

role

Capability bundle

state

Mutable property

effect

Event handler

intent

Declared intention

relation

Between subjects

memory

Agent history

spawn

Create instance

All keywords will be available in 23 languages