From Esolang
Jump to: navigation, search

Tiny is a small floating point RPN based language created by User:Ron.hudson. It is a console/character type interpretive programming language, in which all statements are either assignments or those that print quoted strings.


Each line consists of a floating point line number, followed by any number of commands. Line numbers must floating point numnbers and may have up to 3 digits to the right of the decimal point. The number can have leading zeros. The commands are:

#comment to end of line
"print this string"
[calculates an expression] stores the result into one or more variables

The third command is an assignment, and the fourth command ends the program. Multiple commands can be written on the same line. Escape sequences are allowed inside quoted strings (\n (newline), \e (ASCII 0x1B), \t (tab), \", \\).

Expressions are written in Reverse Polish notation, and can use the following operators:

+ - * / % ^ Arithmetic (add, subtract, multiply, divide, remainder, raise to a power)
< > = Comparison (less than, greater than, equal to;
                  returns 1 for true, 0 for false)
& | ! Logical (and, or, not; uses 1 for true and 0 for false)

The stack is dynamic.


There are three types of variables:

  • a to z. These are floating point numbers.
  • Array members. There is one array, which is sized at compile time. An array element is specified by enclosing an expression in parens. The value of the expression is taken as an index into the array.
  • Special variables. These are used for I/O, storage, and program control, and have names which are punctuation marks.

Special variables[edit]

The following special variables are available:

  • @ The current execution step. Assigning a value to this, other than 0, causes a jump to the line with the number that has been assigned at the end of the line currently running. All elements in the line complete before the jump is taken. Assigning 0 has no effect. Reading from this (before it is assigned) gives the line number of the next line (Useful as a subroutine return address)
  • $ Storage stack. Assigning to $ pushes a number onto the stack; reading from it pops a number from the stack and returns it. The main use for the stack is to store subroutine return addresses. [@]$ [subroutine line number] @ to call a subroutine and [$]@ to return from one.
  • ? Numeric I/O. Reading from ? inputs a number, and writing to it outputs a number. If a null string is entered by the user, 0 is returned.
  • ~ Random number. Reading returns a random number, and writing seeds the random-number generator (with the number given, or with the system time if 0 is given).


0100.00 #squares to 42
0110.00 [?] x
0120.00 [x] ? " Squared is : " [x 2 ^] ? "\n"   [x 42 = ! 110.00 *] @
0130.00 "Thanks for trying Tiny! \n\n"
0140.00 :

Line 100.00 is a comment.

Line 110.00 waits for user numeric input, reads it, and then stores it in the variable x.

Line 120.00 prints x, prints a string, prints x squared, prints a newline, then tests x; if x is not equal to 42, it goes to line 110. (It stores 0 in @ if x is 42; or 110 in @ if x is not 42; storing 0 in @ has no effect.)

Line 130.00 prints a string.

Line 140.00 ends the program and stops execution.

Computational class[edit]

Due to the limits on the range of a variable, Tiny cannot be Turing-complete; the array is effectively finite, as only a finite number of elements can be indexed (due to the range of the variables a-z). The $ stack is infinite; however, there is only one $ stack, which is not enough for Turing-completeness (there is no temporary storage for a bignum anywhere else). Every Tiny program is a (random, if you use ~) push-down automaton. Because jump target line numbers are also limited in size, Tiny can probably not simulate PDAs with arbitrarily many states. The amount of memory available is likely to prove adequate for most programs.


Tiny has simple facilities to load a program, replace lines and save a program from the tiny command line, or you can edit your program in your favorite editor and have tiny run it.

If you execute tiny with the name of a tiny source file (tiny filename<cr>) tiny will load and run that file, and when the program finishes tiny will exit back to the operating system.

When you use tiny to edit your program the comment marker also introduces commands:

#o filename, old, Read program steps from a file, the new steps are merged with the current program.
#b, bye, Exit tiny.
#s filename, save, Save the current program in the file named.
#l, list, Lists the program (the whole program with no paging)
#n, new, Clears the program area.

Because the # is a comment marker, in Linux you can use the #! <path to tiny> and create command line executable in tiny

External resources[edit]

Geocities is being closed by Yahoo, I am looking for a new place to host fltiny. In the mean time check my user page for info on how to get your copy.

Plans and possible extensions[edit]

Line Number Sorting.. Line number sorting has been handled by Bruce Hudson (My brother). Line numbers are now used to sort the program in both executive and interactive mode.

right now you have to say "0 5 -" if you mean -5.

This has changed use the "_" underbar to finish a number and change its sign

Some form of file i/o might be nice.

Since every element of tiny is one character long, The only ones free at the moment are ; {} and , I have not used any of the extended characters because I want to be able to run tiny from a terminal connected to my Linux server.

What can I use  ; and , for? got any ideas?

I suppose a drop command would be good, it would even work outside the [,] of an expression (actually all the operators do [ and ] mainly control reading vs. storing. )

In floating point tiny the list of unused is ; ,

Recently a friend who goes by the handle "Comet" brought up an idea - self modifying programs. Using perhaps ";" I would take array elements as ASCII characters and have tiny act as though the line were typed in at the console parsing line number and code.

Or perhaps it's time to use the curly brackets: {c} where c is some code flag-character

{o filename.ext} change output stream to file {o} to restore

{i filename.ext} change input stream to file {i} to restore

{p "5 [x]?"} Parse string into program, adding or replacing line 5

{s filename.ext} Write the current program out to filename.

{?} Reads a string from input and places each char in the array starting at 1

Has possibilities.

Announcing Floating Point Tiny[edit]

Integer Tiny is not currently available... for now.

Floating point tiny is now available at my geocities website. New note: Geocitites is closing... see below.

The Stack, Variables and array are all now floating point. '%' is an integer function. Line numbers are floating point and are displayed to 4 decimal places. The Random Number is floating point and is in the range {0 <= ~ < 1}.

Since the period is needed as a decimal point, the stop program command is now the ":"

Latest Updates to Tiny[edit]

Added {# comments }

Tiny reads and writes to files now!

Open filename to receive output instead of stdout

  • {o+ filename} open a filename for append
  • {o- filename} open a filename for replace
  • {o*} Closes filename and selects stdout

Open a filename to replace stdin for inputs

  • {i+ filename} open filename
  • {i* } return to stdin

String I/O: Tiny can read and print strings:

  • [{?}] Read a string into the array
  • [ ] {?} Print the array as a string

Strings are placed converting character by character into array elements starting at element 1, up to element 80. element 0 is left alone and no element beyond 80 is changed.

Tiny can do math.h mathematical functions: {f functionname} where function name is: