Softanza
DémarrerEnglish
Softanza
Recherche · narration

Near-Natural Programming: Bridging Human Thought and Code Execution

We humans think in stories, questions, and natural flows of logic. "Is this word all lowercase, made of Latin letters, exactly four characters long?" That's how our minds frame problems. Yet, when we program, we often fracture these thoughts into rigid syntax: isolated functions, boolean checks, and conditional branches that feel far removed from our original intent.

par Mansour Ayouni · dans le dépôt depuis le 2025-09-24 · essai de paradigme · domaine Traitement du langage et linguistique

Cet article est écrit en anglais, comme la bibliothèque.

How the Softanza library enables executable code that reads like everyday language, powered by elegant design in the Haro programming language


The Human Side of Programming

Take a simple validation in Python:

Python, montré pour comparaison, non exécuté
word = "haro"
is_valid = (word.islower() and 
            word.isascii() and 
            isinstance(word, str) and 
            len(word) == 4)

It's functional, but it doesn't flow. The code prioritizes the machine's needs over the programmer's natural expression. What if we could write code that mirrors our thoughts more closely—without sacrificing precision, performance, or computability?

Introducing Near-Natural Programming

Enter Softanza, a library for the Haro programming language that transforms code into near-natural expressions. Here's the same validation, now reading like a sentence:

Haro
? Q("haro").IsAXTQ([:Lowercase, :Latin, :String]).WhichQ().HasAQ().LengthQ().EqualTo(4)
#--> TRUE

exécuté le 2026-10-08 20:42 au commit 4a184e6f0 : a tenu sa promesse

This isn't magic or AI trickery—it's a carefully crafted system of methods and conventions that lets developers articulate logic in a way that feels intuitive and human. We call it Near-Natural Programming (NNP): close enough to natural language to be readable and expressive, yet structured enough to execute as pure code.

At its heart, NNP in Softanza allows you to chain ideas fluidly, using words like "Which," "Has," "And," and "That" to build logical narratives. It's about making code not just workable, but thinkable—reducing the mental translation between idea and implementation.

The Elegant Simplicity Behind the System

Softanza's NNP isn't built on complex frameworks or external dependencies. It's grounded in a straightforward foundation: a collection of methods spread across stzObject (the parent of all Softanza objects), through specialized classes like stzString, stzList, and stzNumber, and all coordinated by lightweight stzNaturalCode class and other related global functions and state management.

All Softanza objects share consistent method names and behaviors where it makes sense—Find() works similarly whether you're searching a string for characters, a list for elements, or a number for digits:

Haro
? Q("text").Find("t")      # Finds positions in the string
? Q([1,2,3,2]).Find(2)     # Finds positions in the list  
? Q(12321).Find(2)         # Finds digit positions in the number

illustration

This uniformity creates a predictable canvas for natural expressions, supported by a simple but powerful global state system using Haro variables like _MainValue, _LastValue, and _aFuture.

Turning Descriptors into Actions

One key innovation is dynamic resolution of natural descriptors. When you specify qualities like [:Lowercase, :Latin, :String], Softanza generates and evaluates the corresponding checks dynamically:

Haro
# Inside stzObject.IsAXT() method:
cCode = '@is' + pacStr[i] + '(' + @@(this.Content()) + ')'
eval(cCode)

illustration

For IsAXT([:Lowercase, :Latin, :String]), it effectively runs:

  • @isLowercase("haro") → TRUE
  • @isLatin("haro") → TRUE
  • @isString("haro") → TRUE

This maps human-friendly terms directly to code execution without parsers or overhead.

Intelligent Flow Through Object Transitions

Chains aren't just sequences—they're smart. Methods return not only results but the right type of object to keep the narrative going. The "Q" suffix pattern creates fluent continuations:

Haro
? Q("haro").IsAQ(:String).InLowercase()     #--> TRUE
? Q("haro").IsAQ(:String).Which().IsLowercase() #--> TRUE

illustration

Multiple natural variations express the same logic, accommodating different thinking patterns.

Context Memory with Minimal State

Softanza uses simple global variables to maintain context across chains. The SetLastValue() function stores values that subsequent methods can reference:

Haro
? TheWordQ("haro").HasNQ(4).LettersNB()
#--> TRUE

illustration

Here's the flow:

  1. HasNQ(4) stores 4 in _LastValue
  2. LettersNB() counts letters (4) and compares to _LastValue (4)
  3. Returns TRUE since they match

The "B" suffix indicates binary (boolean) operations that often use this context.

Programming the Future with Deferred Actions

Softanza's most innovative feature lets you describe actions to perform later, mimicking natural planning:

Haro
? BeforeQ("ringo").IsUppercasedFQ().RemoveFFQ("o").AndThenQ().ReturnIt()
#--> HARO

illustration

The system works through a global _aFuture array that stores action plans:

Haro
_aFuture = [
    ["IsUppercased", []],
    ["Remove", ["o"]]
]

illustration

Methods with "FQ" suffixes queue actions, while "FFQ" methods execute them. SetFutureOrder(:Before) or SetFutureOrder(:After) controls execution sequence.

Suffix Patterns: Fine-Tuned Control

Softanza uses consistent suffix patterns for nuanced control:

  • No suffix: Acts on object, returns nothing (Remove("X"))
  • Q(): Acts and returns object for chaining (RemoveQ("X"))
  • B(): Returns boolean, often context-aware (LettersNB())
  • N(): Returns number (VowelN() for vowel count)
  • FQ(): Queues future action (IsUppercasedFQ())
  • FFQ(): Executes queued actions (RemoveFFQ("o"))

Multiple forms express the same concept:

Haro
? Q("haro").IsAString()      # Direct check
? Q("haro").IsA(:String)     # Symbolic form
? Q("haro").IsAXT([:String]) # Extended validation

illustration

Real-World Power in Everyday Code

Natural Validations

Replace nested conditions with flowing queries:

Haro
? Q(["Haro", :and = "Ruby"]).AreBothQ(:strings).HavingQ().TheirQ().FirstCharQ().EqualTo("R")
#--> TRUE

illustration

Context-Aware Operations

Use remembered values elegantly:

Haro
SetLastValue(3)
? Q("AnnIE").VowelNB()  # Compares vowel count to LastValue
#--> TRUE

SetLastValue(["A", "I", "E"])
? Q("AnnIE").VowelsB()  # Compares vowel list to LastValue  
#--> TRUE

exécuté le 2026-10-08 20:42 au commit 4a184e6f0 : a tenu sa promesse

Complex Logical Chains

Handle multiple criteria seamlessly:

Haro
? Q([-1200, -10200, -820, -10]).AreQ(:numbers).ThatQ().AreNegativeQ().AndQ().DividableBy(10)
#--> TRUE

exécuté le 2026-10-08 20:42 au commit 4a184e6f0 : a tenu sa promesse

Future-Oriented Programming

Plan and execute multi-step transformations:

Haro
? BeforeQ("ringo").IsUppercasedFQ().AndThenQ().SpacifiedFQ().
  RemoveFFQ(" o").BoundItWithQ(["<< ", :and = " >>"]).
  AndFinallyQ().ReturnIt()
#--> << H A R O O >>

illustration

Technical Architecture: Efficiency Through Simplicity

Softanza's NNP runs at native Haro speed through direct method calls with no interpretation layers. The global state system uses minimal memory—just Haro's built-in variables and lists:

Haro
$aFuture = []           		# Action queue
$LastValue = NULL       		# Context memory  
$MainValue = NULL       		# Chain context
$oMainObject = ANullObject()  	# Object context

illustration

Functions like AddFuture(), ExecuteActions(), and CleanFuture() manage the action system with straightforward list operations. Results are deterministic with no AI unpredictability.

Error-Tolerant Design

The system gracefully handles common variations and typos:

Haro
? Q("haro").IsAQ(:String).InLowarcase()  # Misspelled
#--> TRUE (still works)

? Q("haro").IsAQ(:String).InLowercase()  # Correct
#--> TRUE

illustration

Universal Language Patterns

While examples use English, NNP represents universal programming concepts. The method structure supports any language's natural patterns by extending the vocabulary accordingly. The core idea—bridging human thought and code execution—transcends specific linguistic implementations.

The Grand Vision: Executable Human Language

Softanza's NNP foundation enables even more natural expressions:

Haro
Naturally() {
    Make a stzString using "haro"
    Spacify it and uppercase it  
    Then show the result
}
#--> "H A R O"

illustration

By embedding natural expressions in Haro, Softanza points toward programming that feels like conversation, blending human intuition with machine reliability.

A Step Toward Thoughtful Code

Softanza's Near-Natural Programming demonstrates that humane code doesn't require vast AI models—it needs smart design. By weaving methods, chains, and context into a cohesive system, it reduces the gap between thinking and coding, making development more accessible and enjoyable.

The system's power lies not in complexity but in thoughtful simplicity: global state for context, consistent patterns for predictability, and deferred execution for natural planning. As programming evolves, approaches like this remind us that the best innovations often simplify rather than complicate.

Softanza isn't rewriting programming's rules—it's making them readable, natural, and unmistakably human.

Lectures liées

Citer

Mansour Ayouni. « Near-Natural Programming: Bridging Human Thought and Code Execution ». Softanza narrations, 2025. https://mayouni.github.io/stzsite/fr/narrations/stz-near-natural-language-programming.html

Exécuté au nom de Haro le 2026-10-08 20:42 dans la bibliothèque au commit 4a184e6f0, bloc après bloc dans un seul processus : 3 bloc(s) sur 15 ont tenu leur promesse ; les autres sont des illustrations. Le code des articles est du code Haro. Là où un article a été écrit avant que la langue prenne son nom actuel, le nom a été changé et rien d'autre. Genre, domaine et série lus dans le nom du fichier, année tirée du premier commit : dérivés, jusqu'à ce que l'article porte son propre en-tête. Le fichier sur GitHub(s'ouvre dans un nouvel onglet)