Emptiness in Strings, Clear Rules: The Softanza Way
In programming, emptiness—represented as the empty string ""—is often mishandled, leading to unexpected results, bugs, and inconsistencies. Softanza, built on top of the Haro language, provides a clean, logical, and consistent framework for string operations through its stzString class. This design enforces rules that treat emptiness with clear principles, forging explicit, predictable programs.
par Mansour Ayouni · dans le dépôt depuis le 2024-12-07 · essai de fonction · domaine Chaînes de caractères
Cet article est écrit en anglais, comme la bibliothèque.


This article explains Softanza’s handling of emptiness with five rules, using real-world code examples to showcase its logical fluency and how it compares to mainstream languages.
Rule 1: Emptiness Is Uncountable
In Softanza, an empty string has no measurable presence. It cannot be counted inside any string, empty or not:
load "stzlib.ring"
? Q("").Count("")
#--> 0
? Q("text").Count("")
#--> 0exécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
This prevents the confusion found in some languages where empty substrings are implicitly considered "present" at every position in a string.
NOTE: The small
Q(val)function converts the valuevalinto its corresponding Softanza object. In this case,Q("text")returns anstzString("text")object.
Rule 2: Emptiness Is Unfindable
Since emptiness is uncountable (Rule 1), it logically follows that it cannot be found. Searching for the list of positions of"" in any string always returns an empty list:
? @@( Q("").FindAll("") )
#--> [ ]
? @@( Q("text").FindAll("") )
#--> [ ]exécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
Also, finding the first position of "" always returns 0, which means it does not even exist:
? Q("").FindFirst("")
#--> 0
? Q("text").FindFirst("")
#--> 0illustration
This contrasts with languages like C++ or Python, or even the substr() function in Haro, where finding "" may return the first position, misleadingly implying its presence.
NOTE: Softanza originally used Qt for Unicode string management via the RingQt library. It now uses the Zig-based Softanza Engine for all string operations.
Rule 3: Emptiness Is Uncontainable
An empty string contains nothing, and no string (empty or not) contains an empty one. This rule flows naturally from Rules 1 and 2:
? Q("").Contains("")
#--> FALSE
? Q("").Contains("text")
#--> FALSE
? Q("text").Contains("")
#--> FALSEexécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
This behavior eliminates ambiguities in mainstream languages, where "" is often considered contained within any string.
Rule 4: Emptiness Is Irreplaceable but Stretchable
Replacing any value with emptiness has no meaningful effect, nor does replacing an empty string with another empty string.
? @@( Q("").ReplaceQ("", "").Content() )
#--> ""
? @@( Q("").ReplaceQ("text", "").Content() )
#--> ""
? @@( Q("").ReplaceQ("", "text").Content() )
#--> ""
? @@( Q("text").ReplaceQ("", "").Content() )
#--> "text"
? @@( Q("text").ReplaceQ("", "X").Content() )
#--> "text"exécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
However, replacing emptiness with a non-empty string stretches the empty string to host the new content.
? @@( Q("").ReplaceQ("", "X").Content() )
#--> "X"illustration
Softanza enforces this by ensuring replacements involving "" either return the original string or logically adjust to accommodate the replacement.
This avoids surprising behaviors like those in C++, where replacing "" inserts the replacement string between every character ("tXeXtX").
NOTE: The
@@(val)function (resembling two glasses one puts on to improve sight) returns a readable, string-based representation of the valueval, regardless of its type.
Rule 5: Emptiness Is Irremovable
Similarly, emptiness cannot be removed from any string. Softanza guarantees that removal operations involving "" leave the original string unchanged:
? @@( Q("").RemoveQ("").Content() )
#--> ""
? @@( Q("").RemoveQ("text").Content() )
#--> ""
? @@( Q("text").RemoveQ("").Content() )
#--> "text"exécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
This ensures logical consistency and avoids unintended alterations.
Logical Fluency and Real-World Implications
Softanza’s rules for handling emptiness prevent common errors and make programs more predictable.
In many languages, methods like String.indexOf("") or substr("text", "") in Haro return 0 and 1, respectively, when searching for an empty string—positions corresponding to the first character in the string. Using these results can lead to unintended modifications, such as removing the first character.
Illustrating the Case Haro Induces Softanza in Error:
// An empty value we don't control, e.g., from an API or user input
val = ""
// Getting the position
nPosition = substr("haro", val) #--> 1
// Removing the character at that position using Softanza
? Q("Haro").RemoveAt(nPosition) #--> "ing"illustration
Here, val being empty leads to mistakenly identifying position 1 (first character) as a valid match, resulting in an unintended modification.
Softanza’s Secure Approach:
val = ""
// Removing with Softanza
? Q("Haro").RemoveQ(val).Content()
#--> "Haro"exécuté le 2026-10-08 20:44 au commit 4a184e6f0 : a tenu sa promesse
Softanza ensures no modifications occur when dealing with empty strings, preventing such traps and ensuring logical fluency in real-world programming.
Conclusion
By treating emptiness as uncountable, unfindable, uncontainable, irreplaceable, and irremovable, Softanza provides a consistent and logical framework for string operations. These rules eliminate ambiguities found in other languages, fostering clean and maintainable code.
Citer
Mansour Ayouni. « Emptiness in Strings, Clear Rules: The Softanza Way ». Softanza narrations, 2024. https://mayouni.github.io/stzsite/fr/narrations/stzstring-emptiness-narration.html
Exécuté au nom de Haro le 2026-10-08 20:44 dans la bibliothèque au commit 4a184e6f0, bloc après bloc dans un seul processus : 6 bloc(s) sur 9 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)

