Softanza
DémarrerEnglish
Softanza
Recherche · narration

When “different” is not enough: the story behind Diff(), DiffXT() and DiffXTT() in stzList

In Softanza, the question was more intentional:

par Mansour Ayouni · dans le dépôt depuis le 2025-12-25 · essai de fonction · domaine Collections et objets

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

In most programming libraries, diff is treated as a simple operation: compare two collections and list what is not the same.

What does it really mean for two lists to be different?

Not just technically different, but meaningfully different.

This reflection led to the design of a progressive diff mechanism in stzList, articulated in three deliberate levels: Diff(), DiffXT() and DiffXTT().

Each level answers a deeper question than the previous one.

Level 1 — Diff(): seeing what is different

The first level addresses the most immediate need:

Which items are not shared between the two lists?

Haro
o1 = new stzList([ "green", "red", "blue" ])

? @@( o1.Common([ "yellow", "red", "blue", "gray" ]) )
#--> [ "red", "blue" ]

? @@( o1.Diff([ "yellow", "red", "blue", "gray" ]) )
#--> [ "green", "yellow", "gray" ]

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

Here:

  • Common() reveals what overlaps
  • Diff() returns what belongs to only one side

This level is minimal, symmetric, and direct. It is ideal when you only need a factual answer, without interpretation.

Level 2 — DiffXT(): understanding how things differ

Very often, knowing what is different is not enough. The next natural question is:

Are these differences additions, removals, or modifications?

This is where XT — eXTended — comes into play.

Haro
? @@NL( o1.DiffXT([ "yellow", "red", "blue", "gray" ]) )

illustration

Result:

[
	[
		"added",
		[ "yellow", "gray" ]
	],
	[
		"removed",
		[ "green" ]
	],
	[ "modified", [  ] ]
]

The diff now becomes expressive:

  • Differences are classified
  • The structure is stable and predictable
  • Even empty categories are explicitly present

Level 3 — DiffXTT(): understanding why things differ

Some differences are neither pure additions nor pure removals. They are transformations.

To capture that idea, a further extension was introduced: XTT, yet another eXTension.

Haro
o1 = new stzList([ "green", [ "A", "B" ], "rediness", "blues" ])

? @@NL( o1.DiffXTT([ "yellow", "red", [ "A" ], "blue", "gray" ]) )

illustration

Result:

[
	[
		"added",
		[ "yellow", "gray" ]
	],
	[
		"removed",
		[ "green" ]
	],
	[
		"modified",
		[
			[
				[ "A", "B" ],
				[ "A" ]
			],
			[ "rediness", "red" ],
			[ "blues", "blue" ]
		]
	]
]

Here, the diff exposes relationships:

  • A list evolving from [ "A", "B" ] to [ "A" ]
  • Words reduced to their semantic core
  • Elements that changed form but not intent

At this level, DiffXTT() no longer reports differences — it explains them.

A deliberate progression, not increasing complexity

What matters most in this design is not the sophistication of the last level, but the freedom of choice it offers:

  • Need speed and simplicity? → Diff()
  • Need structured meaning? → DiffXT()
  • Need transformation insight? → DiffXTT()

Each level is intentional, additive, and optional.

Why this belongs in stzList

Although this mechanism later proved essential for higher-level structures — including graph comparisons — it belongs first and foremost to stzList.

Lists are the foundational abstraction of Softanza. By teaching lists how to explain their differences, the entire ecosystem gains expressive power.

In Softanza, even a simple list comparison can tell a story — and Diff(), DiffXT() and DiffXTT() are precisely that: narrators of change.

Citer

Mansour Ayouni. « When “different” is not enough: the story behind `Diff()`, `DiffXT()` and `DiffXTT()` in stzList ». Softanza narrations, 2025. https://mayouni.github.io/stzsite/fr/narrations/stzlist-diff.html

Exécuté au nom de Haro le 2026-10-08 20:43 dans la bibliothèque au commit 4a184e6f0, bloc après bloc dans un seul processus : 1 bloc(s) sur 3 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)