Softanza
StartFrançais
Softanza
Research · narration

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.

by Mansour Ayouni · in the repository since 2024-12-07 · feature essay · area String

Emptiness, by Microsoft Image Create AI
Emptiness, by Microsoft Image Create AI

Emptiness, by Microsoft Image Create AI

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:

Haro
load "stzlib.ring"

? Q("").Count("") 
#--> 0

? Q("text").Count("") 
#--> 0

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

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 value val into its corresponding Softanza object. In this case, Q("text") returns an stzString("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:

Haro
? @@( Q("").FindAll("") ) 
#--> [ ]

? @@( Q("text").FindAll("") )
#--> [ ]

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

Also, finding the first position of "" always returns 0, which means it does not even exist:

Haro
? Q("").FindFirst("")
#--> 0

? Q("text").FindFirst("")
#--> 0

illustration

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:

Haro
? Q("").Contains("") 
#--> FALSE

? Q("").Contains("text") 
#--> FALSE

? Q("text").Contains("")
#--> FALSE

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

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.

Haro
? @@( Q("").ReplaceQ("", "").Content() ) 
#--> ""

? @@( Q("").ReplaceQ("text", "").Content() ) 
#--> ""

? @@( Q("").ReplaceQ("", "text").Content() ) 
#--> ""

? @@( Q("text").ReplaceQ("", "").Content() ) 
#--> "text"

? @@( Q("text").ReplaceQ("", "X").Content() )
#--> "text"

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

However, replacing emptiness with a non-empty string stretches the empty string to host the new content.

Haro
? @@( 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 value val, 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:

Haro
? @@( Q("").RemoveQ("").Content() ) 
#--> ""

? @@( Q("").RemoveQ("text").Content() ) 
#--> ""

? @@( Q("text").RemoveQ("").Content() ) 
#--> "text"

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

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:

Haro
// 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:

Haro
val = ""

// Removing with Softanza
? Q("Haro").RemoveQ(val).Content()
#--> "Haro"

run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise

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.

Cite

Mansour Ayouni. "Emptiness in Strings, Clear Rules: The Softanza Way". Softanza narrations, 2024. https://mayouni.github.io/stzsite/en/narrations/stzstring-emptiness-narration.html

Run in Haro's name on 2026-10-08 20:44 inside the library at commit 4a184e6f0, block after block in one process: 6 of 9 blocks kept their promise; the others are illustrations. The code of the articles is Haro code. Where an article was written before the language took its present name, the name was changed and nothing else. Genre, area and series read from the file's name, the year from its first commit: derived, until the article carries its own header. The file on GitHub(opens in a new tab)