Trinary Programming

I used to think of programming as something natively binary. 0's and 1's, [ True, False ], just like the Propositional Logic in first year Philosophy. And filesystems do work that way on the disk - every picture is made of 0's and 1's.

However, Philosophy, or Logic in general, has other systems. Some of them use 'True' and 'False' like tick boxes. So you can still do this:

  • True
  • False

and this:

  • True
  • False

But you can also make something both true and false:

  • True
  • False

or even 'neither true, nor false':

  • True
  • False

I don't program, but I have made some small bash scripts, and bash seems like a native user of 'neither true, nor false'. Instead of asking if something's 'true or false', you can ask if the variable is set.

1[ -v "$backup_successful" ] && sync_backup

This will do sync_backup if the variable $backup_successful is true, or false.

Of course, this sort of thinking is available everywhere. Python might use a try: statement to do similar things. It just feels a little more native in bash.

In any case, no matter how the syntax goes, no language I know of attempts to deal with situations where something is true or false. The options are 'true, false, or neither'. So in general, programming looks like it deals with 'trinary', rather than 'binary'.