A tiny serialization protocol that removes sentinel values and keeps types precise
> The biggest breakthrough was realizing that I was solving the wrong > problem.
Solution TLDR; In UI, empty value should NOT be represented as “” but rather " ". This is different from what has been the traditional way i.e. empty value is just “”. The difference is minimal and easy to ignore but it is significant. Of course, it is not very safe or convenient due to trims etc. but hear me out. This will be a clean approach to default, empty, and sentinel values in UI: just use single space for a field value!
"" is equivalent to symbol of bottom ⊥
" " means empty string for end-user
Introduction
While designing a generic resource system and form engine, I became convinced that every primitive type needed an “empty value”.
It seemed obvious.
If users can leave a field blank, then surely every type must define what “blank” means.
For weeks I searched for answers:
- empty integer
- empty boolean
- empty date
- empty timestamp
- empty UUID
- empty money
The deeper I looked, the less convincing every answer became.
This article explains why the search itself was misguided and how a surprisingly small serialization protocol solved the problem.
The Wrong Question
Suppose we have the following types:
- string
- text
- integer
- decimal
- boolean
- date
- timestamp
- uuid
- money
- filesize
- ranges
- arrays
- references
- files
- JSON
Now ask:
> What is the empty value of each type?
At first the question feels fundamental.
But it immediately starts falling apart.
0 is not an empty integer.
false is not an empty boolean.
1970-01-01 is not an empty timestamp.
A nil UUID is still a UUID.
The conclusion is unavoidable:
> Sentinel values steal legitimate values from the domain.
Chasing Better Ideas
I explored several directions.
Identity elements
Useful for algebra, but unrelated to missing information.
Empty values
Natural for arrays and some range types, but not for most primitives.
Sentinel values
Practical, but they infect every algorithm with special cases.
Bottom values
Mathematically elegant, but they still leave one unanswered question:
> How does a user enter bottom into a form?
That question turned out to be the key.
The Realization
I wasn’t designing values.
I was designing communication between humans and values.
That is a serialization problem.
Humans never edit integers.
They edit text.
Humans never edit UUIDs.
They edit text.
Even calendars, checkboxes and upload controls eventually produce representations.
Forms are codecs.
Human
│
Representation
(strings)
│
Codec
│
Semantic values
Once viewed this way, the problem changed completely.
Separate the Layers
The architecture became:
Human
│
▼
Form widgets
│
▼
Serialized strings
│
▼
Codec
│
▼
Lifted values (⊥ | T)
│
▼
SQL (NULL or value)
Each layer has exactly one responsibility.
Layer Responsibility
Types Values and validation Codec Serialization SQL Persistence Application Business defaults
Notice what disappeared.
The type system no longer needs empty values.
One Universal Rule
The codec reserves exactly one representation:
"" ⇄ ⊥
That is enough.
Every field shares the same notion of “missing”.
No fake epochs.
No magic UUID.
No special integer.
The Only Exception
Strings are different.
For every other type:
representation ≠ value
For strings:
representation = value
Therefore strings require escaping.
The simple codec is:
Serialized Semantic string
"" ⊥
" " ""
" " " "
" " " "
The leading spaces belong to the serialization protocol, not the string type.
That distinction is crucial.
Why This Matters
This tiny protocol has surprisingly large consequences.
It removes the need for:
- sentinel values
- fake default values
- empty integers
- empty dates
- empty UUIDs
- type-specific missing semantics
Adding a new primitive type becomes routine.
Implement:
- parser
- formatter
- validator
Nothing else.
What Surprised Me
The real mistake was trying to encode “missing” inside every primitive type instead of treating it as a property of serialization and storage.
Once those concerns were separated, the design became simpler, not more complicated.
Principles
- Primitive types should only describe legitimate values.
- Missing information belongs outside the value domain.
- Forms communicate through serialization.
- SQL stores bottom as
NULL. - Only strings require escaping because only strings share their representation language with their value domain.
Closing Thoughts
The final solution was almost embarrassingly small.
Not a new primitive.
Not a new database feature.
Not a new type constructor.
So what is it then? Just one serialization rule and one escape rule for strings:
"" is equivalent to bottom ⊥
" " means empty string for end-user
and one escape rule for strings.
Sometimes the hardest part of designing a system is not inventing a clever mechanism.
It is discovering that the original question was asked at the wrong layer of abstraction.

You must be logged in to post a comment.