A Grid Programming Language is a programming model where data is stored and manipulated inside a two-dimensional grid (rows and columns).
Instead of variables and memory addresses, programs operate by:
- Creating a grid
- Moving a cursor to a specific cell
- Reading or writing values at the cursor position
Mars is an experimental grid-based programming language designed to explore this concept.
- Grid: A 2D table of cells (rows × columns)
- Cell: A single position in the grid, which may contain a value or
Null - Cursor: Points to the currently active cell
- All operations act on the current cursor position
Create a new grid.
-
Creates a grid with:
- X rows
- Y columns
-
All cells are initialized to
Null -
The cursor is automatically set to (0, 0)
-
If a grid already exists, it should be closed before creating a new one
Example
CREAT 10, 10
Move the cursor to a specific cell.
-
The grid must be created before using this command
-
Moves the cursor to:
- row X
- column Y
-
Coordinates are zero-based
Example
MOVE 3, 4
Write a value into the current cell.
- Writes
VALUEto the cell at the current cursor position - Overwrites any existing value in that cell
Example
WRITE 3
Print the entire grid.
- Displays the current state of the grid
- Shows all cells, including
Nullcells - Used for debugging or inspecting the grid
Example
READ
Destroy the current grid and free memory.
- Releases all memory used by the grid
- Resets the grid state to
Null - After
CLOSE, no grid exists MOVE,READ, orWRITEcannot be used until a new grid is created
Example
CLOSE
CREAT 5, 5
MOVE 3, 4
WRITE 3
READ
CLOSE
This program:
- Creates a 5×5 grid
- Moves the cursor to cell (3,4)
- Writes the value
3into that cell - Prints the grid
- Frees all allocated memory
-
All commands are executed sequentially
-
Mars is designed for simplicity and experimentation
-
Future versions may include:
-
Reading individual cells
-
Ranges and rows
-
Expressions and formulas
-
Variables and control flow
-