BiTrax

From Esolang
Jump to navigation Jump to search

BiTrax (standing for bit-tracks) is a two-dimensional esoteric programming language invented by User:$M@ in 2011.

Language overview

Programs work on a linear memory tape, infinite to both directions. Each memory cell contains any of two values. The initial value is usually considered 'zero', and the changed value 'one'.

A source code is a bitmap, where each pixel defines a statement:

  • White (FFFFFF): does nothing
  • Yellow (FFFF00): input bit is stored in current cell
  • Black (000000): current cell is written to output
  • Gray (808080): flips current cell
  • Green (00FF00): advances memory pointer to one direction by one cell
  • Red (FF0000): advances memory pointer to the other direction by one cell
  • Blue (0000FF): changes direction of execution, depending on the value of the current cell (see below)
  • Colors other than these should generate a runtime error if reached.

Execution starts at the top left corner going to the right. If a blue pixel is reached, the instrucion pointer turns either left or right by 90 degrees. If the current cell contains its initial value, the instrucion pointer turns right, otherwise it turns left. Note that before turning it goes back by one pixel, like if the blue pixel wasn't reached (this is to ensure Turing-completeness, see image below). If execution reaches any side of the bitmap, the program halts.

BiTraxTurning.PNG

IO functions

Although the exact operation of the black and yellow statements is not strictly defined, it is strongly recommended that any of the following characters is considered as

  • initial cell value: 0 n N f F
  • changed cell value: 1 y Y t T

Examples

Truth-machine

BiTrax truth-machine as seen in BiTrax Editor. The big black arrows indicate the entry and exit points, the small orange arrows show execution direction for each pixel. Unreached pixels are shown in light gray.

This is an implementation of the Truth-machine algorithm: it will take one bit of input, and output that bit either once (if it is zero), or in an infinite loop (if it is one). The image with the arrows is not executable, it is here simply to demonstrate execution direction.

Enlarged view

BiTrax truth-machine

Actual size

BiTrax truth-machine

Addition

The following example inputs a four-digit number (in base two), adds one to it, and then outputs the result as a five-digit number (to handle possible overflow). To make it work with larger numbers, just extend the input and output parts.

Enlarged view

BiTrax addition

Actual size

BiTrax addition

Hello World!

The following example outputs the bits of 'Hello World!':

Enlarged view

BiTrax Hello World!

Actual size

BiTrax Hello World!

Square root

The following code calculates sqrt(2) to infinite precision:

Enlarged view

BiTrax sqrt(2)

Actual size

BiTrax sqrt(2)

Primes

The following code prints all the prime numbers:

Enlarged view

BiTrax primes

Actual size

BiTrax primes

Computational class

BiTrax is Turing-complete.

BiTrax Editor

BiTrax Editor showing an analyzed source code with a debugger, a heatmap and an error browser window.

BiTrax Editor is an integrated development environment (IDE) for BiTrax with the following features:

  • Source code (image) editor with an infinite grid, hotkeys and a convenient UI.
  • Visual debugger with breakpoints and assertations.
  • Batch execution by brute forcing all possible inputs.
  • Heatmap showing you hotspots and unused branches.
  • Modularity through subroutines called insets.
  • Obfuscation.

You can download the beta version of BiTrax Editor here (SHA-1: 014C439396A9DF7A25BCF1DEEB441B6BFB25412D)

See also

Other languages operating on bits (implemented only):