FALSE
Encyclopedia
FALSE is an esoteric programming language
Esoteric programming language
An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

 designed by Wouter van Oortmerssen
Wouter van Oortmerssen
Wouter van Oortmerssen, also known as Aardappel , is a Dutch computer programmer notable for his work in game programming as well as having designed several programming languages...

 in 1993, named after his favorite Boolean
Boolean datatype
In computer science, the Boolean or logical data type is a data type, having two values , intended to represent the truth values of logic and Boolean algebra...

 value. It is a small Forth-like stack-oriented
Stack-oriented programming language
A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....

 language, with syntax
Syntax
In linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....

 designed to make the code inherently obfuscated
Obfuscated code
Obfuscated code is source or machine code that has been made difficult to understand for humans. Programmers may deliberately obfuscate code to conceal its purpose or its logic to prevent tampering, deter reverse engineering, or as a puzzle or recreational challenge for someone reading the source...

, confusing, and unreadable. It is also noteworthy for having a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 of only 1024 bytes (written in 68000
68k
The Motorola 680x0/m68000/68000 is a family of 32-bit CISC microprocessors. During the 1980s and early 1990s, they were popular in personal computers and workstations and were the primary competitors of Intel's x86 microprocessors...

 assembly
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

). According to Van Oortmerssen, FALSE provided the inspiration for various well known esoteric languages, including brainfuck
Brainfuck
The brainfuck programming language is an esoteric programming language noted for its extreme minimalism. It is a Turing tarpit, designed to challenge and amuse programmers, and is not suitable for practical use...

 and Befunge
Befunge
Befunge is a stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid...

.

FALSE is notably more tractable than most esoteric programming languages. The fundamental operations that it provides are reasonably sensible, and there is no gratuitous complexity. In these respects it stands in strong contrast to the behemoths Intercal
INTERCAL
INTERCAL, a programming language parody, is an esoteric programming language that was created by Don Woods and James M. Lyon, two Princeton University students, in 1972. It satirizes aspects of the various programming languages at the time, as well as the proliferation of proposed language...

 and Malbolge
Malbolge
Malbolge is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's Inferno, the Malebolge....

. The difficulty of programming in FALSE comes mostly from the low level nature of the language, which has the feel of a Forth-like assembly language. The remainder of the language's awkwardness comes from the concise punctuation-based syntax, which many people find more difficult than a more conventional word-based syntax.

The language features basic arithmetic and logical operations, variables, subroutines as lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, control flow
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 statements, and input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 operations. FALSE operations are done using a stack
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

. Its structure is largely based on the Forth programming language.

The stack

Everything in the language is defined by how it operates on the stack. When a value is encountered, it is simply pushed onto the stack; when an operator is encountered, a number of operands are popped from the stack, the operation is performed on them, and some number of results are pushed back onto the stack. For example, in the expression 1 3_+:
1 : pushes the integer 1 onto the stack
3 : pushes the integer 3 onto the stack
_ : pops 3 from the stack, negates it, and pushes -3
+ : pops 1 and -3 from the stack and pushes their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, -2.

Subroutines also act on the stack – this is the way that they are given arguments and return values; they see the same stack as the rest of the program.

Data types

Data types that can be used in the program are ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 characters (which are preceded by ' (single-quote)), 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

s, boolean values (0 representing false; -1 representing true), and lambda calculus expressions. These can be used on the stack or stored in variables.

Basic operators

FALSE supports binary
Binary operation
In mathematics, a binary operation is a calculation involving two operands, in other words, an operation whose arity is two. Examples include the familiar arithmetic operations of addition, subtraction, multiplication and division....

 and unary operation
Unary operation
In mathematics, a unary operation is an operation with only one operand, i.e. a single input. Specifically, it is a functionf:\ A\to Awhere A is a set. In this case f is called a unary operation on A....

s in reverse Polish notation
Reverse Polish notation
Reverse Polish notation is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed...

, as well as operations that act on the stack alone.

Arithmetic operators are +, -, *, and / (binary operators, which pop two elements from the stack and push (respectively) their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, difference
Subtraction
In arithmetic, subtraction is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with...

, product
Multiplication
Multiplication is the mathematical operation of scaling one number by another. It is one of the four basic operations in elementary arithmetic ....

, or quotient
Division (mathematics)
right|thumb|200px|20 \div 4=5In mathematics, especially in elementary arithmetic, division is an arithmetic operation.Specifically, if c times b equals a, written:c \times b = a\,...

) and the _ (underscore) is unary negation (which pops one element and pushes its negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Logical operators are =, >, &, | (binary operators of equality, greater than, logical conjunction
Logical conjunction
In logic and mathematics, a two-place logical operator and, also known as logical conjunction, results in true if both of its operands are true, otherwise the value of false....

, and logical disjunction
Logical disjunction
In logic and mathematics, a two-place logical connective or, is a logical disjunction, also known as inclusive disjunction or alternation, that results in true whenever one or more of its operands are true. E.g. in this context, "A or B" is true if A is true, or if B is true, or if both A and B are...

), and ~ (unary logical negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Stack operators are (with examples of form example inputresulting stack):
  • $ - Duplicates the topmost element of the stack: 0 1$0 1 1
  • % - Deletes the topmost stack element: 0 1%0
  • \ - Swaps the two topmost stack elements: 0 1 2\0 2 1
  • @ - Rotates the third stack item to the top: 0 1 2 3@0 2 3 1
  • ø - Pick: Copies the n-th stack item to the top: 7 8 9 2ø7 8 9 7

Variables

Variables are single lowercase alphabetical characters (a-z). All variables are global. : (colon) sets a variable to the value at the top of the stack (ie, 3a: assigns the value 3 to the variable a) and ; (semicolon) reads their values (ie, a; would push 3 onto the stack if a has been assigned 3). The heavy use of the stack in FALSE eliminates a great deal of need for variables, and they are mainly used with subroutines.

Subroutines

Subroutines are lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, and are pieces of code contained between [ and ]. The "apply" operator is !. It takes the lambda calculus expression on top of the stack and runs it. Note that if the value on top of the stack is not a lambda expression, the program will behave abnormally.

A very basic example subroutine:
3[1+]!
This pushes 3 on the stack, pushes the expression [1+] (which takes the current stack and increments the top value by 1), and applies this to 3, leaving the stack as 4.

If

The "if" operator is ?. It takes the two top stack elements, the top being a lambda expression; the second being a boolean, and runs the lambda expression if the boolean is true.

For example,
a;1=[3b:]?
tests if the variable a is equal to 1, and if so, runs the expression [3b:] which assigns 3 to b.

While

The "while" operator is #. It takes the top two stack elements, both lambda expressions, and continually evaluates the second element, then the top element, until the second one stops returning true (that is, leaving a true boolean on top of the stack).

For example,
[a;1=][2f;!]#
runs the expression [2f;!] (which puts 2 on the stack and runs whatever lambda expression is contained in the variable f) for as long as the variable a is equal to 1.

Strings

String
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

s are not a real data type in FALSE; they only exist as string literal
String literal
A string literal is the representation of a string value within the source code of a computer program. There are numerous alternate notations for specifying string literals, and the exact notation depends on the individual programming language in question...

s and cannot be stored directly on the stack nor in variables, and cannot be modified. However, they can be contained within lambda expressions (which can be stored). When a string is encountered it is simply printed as output. Strings are any character sequence between double-quotes (""), including newlines. So, a program consisting simply of
"Hello world!
"
would print "Hello world!" followed by a new line.

Lambda expressions can contain strings. For example:
a;1=["true"]?
would print "true" if the variable a is equal to 1.

Input / Output

Apart from strings, which print themselves, FALSE has a number of operators for input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 from and to standard streams
Standard streams
In Unix and Unix-like operating systems , as well as certain programming language interfaces, the standard streams are preconnected input and output channels between a computer program and its environment when it begins execution...

.
  • . (period) prints the topmost stack item out as an integer.
  • , (comma) prints out the topmost stack item as an ASCII
    ASCII
    The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

     character.
  • ^ reads a single character from standard input and pushes it on the stack.
  • ß flushes both standard input and standard output streams.

Code examples

Sample programs taken from the FALSE Programming Language web page:

Hello world
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

:
"Hello world!
"

File copy utility. Usage: copy < infile > outfile
ß[^$1_=~][,]#

Factorial
Factorial
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n...

 calculator for numbers 1 through 8:
[$1=~[$1-f;!*]?]f: { fac in FALSE }
"calculate the factorial of [1..8]: "
ß^ß'0-$$0>~\8>|$
"result: "
~[\f;!.]?
["illegal input!"]?"
"

Write all prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s up to 100:
99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#

See also

  • Forth programming language, from which the structure of FALSE was derived.
  • Esoteric programming language
    Esoteric programming language
    An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

  • Stack-oriented programming language
    Stack-oriented programming language
    A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....


External links


FALSE is an esoteric programming language
Esoteric programming language
An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

 designed by Wouter van Oortmerssen
Wouter van Oortmerssen
Wouter van Oortmerssen, also known as Aardappel , is a Dutch computer programmer notable for his work in game programming as well as having designed several programming languages...

 in 1993, named after his favorite Boolean
Boolean datatype
In computer science, the Boolean or logical data type is a data type, having two values , intended to represent the truth values of logic and Boolean algebra...

 value. It is a small Forth-like stack-oriented
Stack-oriented programming language
A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....

 language, with syntax
Syntax
In linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....

 designed to make the code inherently obfuscated
Obfuscated code
Obfuscated code is source or machine code that has been made difficult to understand for humans. Programmers may deliberately obfuscate code to conceal its purpose or its logic to prevent tampering, deter reverse engineering, or as a puzzle or recreational challenge for someone reading the source...

, confusing, and unreadable. It is also noteworthy for having a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 of only 1024 bytes (written in 68000
68k
The Motorola 680x0/m68000/68000 is a family of 32-bit CISC microprocessors. During the 1980s and early 1990s, they were popular in personal computers and workstations and were the primary competitors of Intel's x86 microprocessors...

 assembly
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

). According to Van Oortmerssen, FALSE provided the inspiration for various well known esoteric languages, including brainfuck
Brainfuck
The brainfuck programming language is an esoteric programming language noted for its extreme minimalism. It is a Turing tarpit, designed to challenge and amuse programmers, and is not suitable for practical use...

 and Befunge
Befunge
Befunge is a stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid...

.

FALSE is notably more tractable than most esoteric programming languages. The fundamental operations that it provides are reasonably sensible, and there is no gratuitous complexity. In these respects it stands in strong contrast to the behemoths Intercal
INTERCAL
INTERCAL, a programming language parody, is an esoteric programming language that was created by Don Woods and James M. Lyon, two Princeton University students, in 1972. It satirizes aspects of the various programming languages at the time, as well as the proliferation of proposed language...

 and Malbolge
Malbolge
Malbolge is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's Inferno, the Malebolge....

. The difficulty of programming in FALSE comes mostly from the low level nature of the language, which has the feel of a Forth-like assembly language. The remainder of the language's awkwardness comes from the concise punctuation-based syntax, which many people find more difficult than a more conventional word-based syntax.

The language features basic arithmetic and logical operations, variables, subroutines as lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, control flow
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 statements, and input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 operations. FALSE operations are done using a stack
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

. Its structure is largely based on the Forth programming language.

The stack

Everything in the language is defined by how it operates on the stack. When a value is encountered, it is simply pushed onto the stack; when an operator is encountered, a number of operands are popped from the stack, the operation is performed on them, and some number of results are pushed back onto the stack. For example, in the expression 1 3_+:
1 : pushes the integer 1 onto the stack
3 : pushes the integer 3 onto the stack
_ : pops 3 from the stack, negates it, and pushes -3
+ : pops 1 and -3 from the stack and pushes their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, -2.

Subroutines also act on the stack – this is the way that they are given arguments and return values; they see the same stack as the rest of the program.

Data types

Data types that can be used in the program are ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 characters (which are preceded by ' (single-quote)), 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

s, boolean values (0 representing false; -1 representing true), and lambda calculus expressions. These can be used on the stack or stored in variables.

Basic operators

FALSE supports binary
Binary operation
In mathematics, a binary operation is a calculation involving two operands, in other words, an operation whose arity is two. Examples include the familiar arithmetic operations of addition, subtraction, multiplication and division....

 and unary operation
Unary operation
In mathematics, a unary operation is an operation with only one operand, i.e. a single input. Specifically, it is a functionf:\ A\to Awhere A is a set. In this case f is called a unary operation on A....

s in reverse Polish notation
Reverse Polish notation
Reverse Polish notation is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed...

, as well as operations that act on the stack alone.

Arithmetic operators are +, -, *, and / (binary operators, which pop two elements from the stack and push (respectively) their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, difference
Subtraction
In arithmetic, subtraction is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with...

, product
Multiplication
Multiplication is the mathematical operation of scaling one number by another. It is one of the four basic operations in elementary arithmetic ....

, or quotient
Division (mathematics)
right|thumb|200px|20 \div 4=5In mathematics, especially in elementary arithmetic, division is an arithmetic operation.Specifically, if c times b equals a, written:c \times b = a\,...

) and the _ (underscore) is unary negation (which pops one element and pushes its negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Logical operators are =, >, &, | (binary operators of equality, greater than, logical conjunction
Logical conjunction
In logic and mathematics, a two-place logical operator and, also known as logical conjunction, results in true if both of its operands are true, otherwise the value of false....

, and logical disjunction
Logical disjunction
In logic and mathematics, a two-place logical connective or, is a logical disjunction, also known as inclusive disjunction or alternation, that results in true whenever one or more of its operands are true. E.g. in this context, "A or B" is true if A is true, or if B is true, or if both A and B are...

), and ~ (unary logical negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Stack operators are (with examples of form example inputresulting stack):
  • $ - Duplicates the topmost element of the stack: 0 1$0 1 1
  • % - Deletes the topmost stack element: 0 1%0
  • \ - Swaps the two topmost stack elements: 0 1 2\0 2 1
  • @ - Rotates the third stack item to the top: 0 1 2 3@0 2 3 1
  • ø - Pick: Copies the n-th stack item to the top: 7 8 9 2ø7 8 9 7

Variables

Variables are single lowercase alphabetical characters (a-z). All variables are global. : (colon) sets a variable to the value at the top of the stack (ie, 3a: assigns the value 3 to the variable a) and ; (semicolon) reads their values (ie, a; would push 3 onto the stack if a has been assigned 3). The heavy use of the stack in FALSE eliminates a great deal of need for variables, and they are mainly used with subroutines.

Subroutines

Subroutines are lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, and are pieces of code contained between [ and ]. The "apply" operator is !. It takes the lambda calculus expression on top of the stack and runs it. Note that if the value on top of the stack is not a lambda expression, the program will behave abnormally.

A very basic example subroutine:
3[1+]!
This pushes 3 on the stack, pushes the expression [1+] (which takes the current stack and increments the top value by 1), and applies this to 3, leaving the stack as 4.

If

The "if" operator is ?. It takes the two top stack elements, the top being a lambda expression; the second being a boolean, and runs the lambda expression if the boolean is true.

For example,
a;1=[3b:]?
tests if the variable a is equal to 1, and if so, runs the expression [3b:] which assigns 3 to b.

While

The "while" operator is #. It takes the top two stack elements, both lambda expressions, and continually evaluates the second element, then the top element, until the second one stops returning true (that is, leaving a true boolean on top of the stack).

For example,
[a;1=][2f;!]#
runs the expression [2f;!] (which puts 2 on the stack and runs whatever lambda expression is contained in the variable f) for as long as the variable a is equal to 1.

Strings

String
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

s are not a real data type in FALSE; they only exist as string literal
String literal
A string literal is the representation of a string value within the source code of a computer program. There are numerous alternate notations for specifying string literals, and the exact notation depends on the individual programming language in question...

s and cannot be stored directly on the stack nor in variables, and cannot be modified. However, they can be contained within lambda expressions (which can be stored). When a string is encountered it is simply printed as output. Strings are any character sequence between double-quotes (""), including newlines. So, a program consisting simply of
"Hello world!
"
would print "Hello world!" followed by a new line.

Lambda expressions can contain strings. For example:
a;1=["true"]?
would print "true" if the variable a is equal to 1.

Input / Output

Apart from strings, which print themselves, FALSE has a number of operators for input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 from and to standard streams
Standard streams
In Unix and Unix-like operating systems , as well as certain programming language interfaces, the standard streams are preconnected input and output channels between a computer program and its environment when it begins execution...

.
  • . (period) prints the topmost stack item out as an integer.
  • , (comma) prints out the topmost stack item as an ASCII
    ASCII
    The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

     character.
  • ^ reads a single character from standard input and pushes it on the stack.
  • ß flushes both standard input and standard output streams.

Code examples

Sample programs taken from the FALSE Programming Language web page:

Hello world
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

:
"Hello world!
"

File copy utility. Usage: copy < infile > outfile
ß[^$1_=~][,]#

Factorial
Factorial
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n...

 calculator for numbers 1 through 8:
[$1=~[$1-f;!*]?]f: { fac in FALSE }
"calculate the factorial of [1..8]: "
ß^ß'0-$$0>~\8>|$
"result: "
~[\f;!.]?
["illegal input!"]?"
"

Write all prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s up to 100:
99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#

See also

  • Forth programming language, from which the structure of FALSE was derived.
  • Esoteric programming language
    Esoteric programming language
    An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

  • Stack-oriented programming language
    Stack-oriented programming language
    A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....


External links




FALSE is an esoteric programming language
Esoteric programming language
An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

 designed by Wouter van Oortmerssen
Wouter van Oortmerssen
Wouter van Oortmerssen, also known as Aardappel , is a Dutch computer programmer notable for his work in game programming as well as having designed several programming languages...

 in 1993, named after his favorite Boolean
Boolean datatype
In computer science, the Boolean or logical data type is a data type, having two values , intended to represent the truth values of logic and Boolean algebra...

 value. It is a small Forth-like stack-oriented
Stack-oriented programming language
A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....

 language, with syntax
Syntax
In linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....

 designed to make the code inherently obfuscated
Obfuscated code
Obfuscated code is source or machine code that has been made difficult to understand for humans. Programmers may deliberately obfuscate code to conceal its purpose or its logic to prevent tampering, deter reverse engineering, or as a puzzle or recreational challenge for someone reading the source...

, confusing, and unreadable. It is also noteworthy for having a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 of only 1024 bytes (written in 68000
68k
The Motorola 680x0/m68000/68000 is a family of 32-bit CISC microprocessors. During the 1980s and early 1990s, they were popular in personal computers and workstations and were the primary competitors of Intel's x86 microprocessors...

 assembly
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

). According to Van Oortmerssen, FALSE provided the inspiration for various well known esoteric languages, including brainfuck
Brainfuck
The brainfuck programming language is an esoteric programming language noted for its extreme minimalism. It is a Turing tarpit, designed to challenge and amuse programmers, and is not suitable for practical use...

 and Befunge
Befunge
Befunge is a stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid...

.

FALSE is notably more tractable than most esoteric programming languages. The fundamental operations that it provides are reasonably sensible, and there is no gratuitous complexity. In these respects it stands in strong contrast to the behemoths Intercal
INTERCAL
INTERCAL, a programming language parody, is an esoteric programming language that was created by Don Woods and James M. Lyon, two Princeton University students, in 1972. It satirizes aspects of the various programming languages at the time, as well as the proliferation of proposed language...

 and Malbolge
Malbolge
Malbolge is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's Inferno, the Malebolge....

. The difficulty of programming in FALSE comes mostly from the low level nature of the language, which has the feel of a Forth-like assembly language. The remainder of the language's awkwardness comes from the concise punctuation-based syntax, which many people find more difficult than a more conventional word-based syntax.

The language features basic arithmetic and logical operations, variables, subroutines as lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, control flow
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 statements, and input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 operations. FALSE operations are done using a stack
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

. Its structure is largely based on the Forth programming language.

The stack

Everything in the language is defined by how it operates on the stack. When a value is encountered, it is simply pushed onto the stack; when an operator is encountered, a number of operands are popped from the stack, the operation is performed on them, and some number of results are pushed back onto the stack. For example, in the expression 1 3_+:
1 : pushes the integer 1 onto the stack
3 : pushes the integer 3 onto the stack
_ : pops 3 from the stack, negates it, and pushes -3
+ : pops 1 and -3 from the stack and pushes their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, -2.

Subroutines also act on the stack – this is the way that they are given arguments and return values; they see the same stack as the rest of the program.

Data types

Data types that can be used in the program are ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 characters (which are preceded by ' (single-quote)), 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

s, boolean values (0 representing false; -1 representing true), and lambda calculus expressions. These can be used on the stack or stored in variables.

Basic operators

FALSE supports binary
Binary operation
In mathematics, a binary operation is a calculation involving two operands, in other words, an operation whose arity is two. Examples include the familiar arithmetic operations of addition, subtraction, multiplication and division....

 and unary operation
Unary operation
In mathematics, a unary operation is an operation with only one operand, i.e. a single input. Specifically, it is a functionf:\ A\to Awhere A is a set. In this case f is called a unary operation on A....

s in reverse Polish notation
Reverse Polish notation
Reverse Polish notation is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed...

, as well as operations that act on the stack alone.

Arithmetic operators are +, -, *, and / (binary operators, which pop two elements from the stack and push (respectively) their sum
Addition
Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign . For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two other apples—which is the same as five apples....

, difference
Subtraction
In arithmetic, subtraction is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with...

, product
Multiplication
Multiplication is the mathematical operation of scaling one number by another. It is one of the four basic operations in elementary arithmetic ....

, or quotient
Division (mathematics)
right|thumb|200px|20 \div 4=5In mathematics, especially in elementary arithmetic, division is an arithmetic operation.Specifically, if c times b equals a, written:c \times b = a\,...

) and the _ (underscore) is unary negation (which pops one element and pushes its negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Logical operators are =, >, &, | (binary operators of equality, greater than, logical conjunction
Logical conjunction
In logic and mathematics, a two-place logical operator and, also known as logical conjunction, results in true if both of its operands are true, otherwise the value of false....

, and logical disjunction
Logical disjunction
In logic and mathematics, a two-place logical connective or, is a logical disjunction, also known as inclusive disjunction or alternation, that results in true whenever one or more of its operands are true. E.g. in this context, "A or B" is true if A is true, or if B is true, or if both A and B are...

), and ~ (unary logical negation
Negation
In logic and mathematics, negation, also called logical complement, is an operation on propositions, truth values, or semantic values more generally. Intuitively, the negation of a proposition is true when that proposition is false, and vice versa. In classical logic negation is normally identified...

).

Stack operators are (with examples of form example inputresulting stack):
  • $ - Duplicates the topmost element of the stack: 0 1$0 1 1
  • % - Deletes the topmost stack element: 0 1%0
  • \ - Swaps the two topmost stack elements: 0 1 2\0 2 1
  • @ - Rotates the third stack item to the top: 0 1 2 3@0 2 3 1
  • ø - Pick: Copies the n-th stack item to the top: 7 8 9 2ø7 8 9 7

Variables

Variables are single lowercase alphabetical characters (a-z). All variables are global. : (colon) sets a variable to the value at the top of the stack (ie, 3a: assigns the value 3 to the variable a) and ; (semicolon) reads their values (ie, a; would push 3 onto the stack if a has been assigned 3). The heavy use of the stack in FALSE eliminates a great deal of need for variables, and they are mainly used with subroutines.

Subroutines

Subroutines are lambda calculus
Lambda calculus
In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus...

 expressions, and are pieces of code contained between [ and ]. The "apply" operator is !. It takes the lambda calculus expression on top of the stack and runs it. Note that if the value on top of the stack is not a lambda expression, the program will behave abnormally.

A very basic example subroutine:
3[1+]!
This pushes 3 on the stack, pushes the expression [1+] (which takes the current stack and increments the top value by 1), and applies this to 3, leaving the stack as 4.

If

The "if" operator is ?. It takes the two top stack elements, the top being a lambda expression; the second being a boolean, and runs the lambda expression if the boolean is true.

For example,
a;1=[3b:]?
tests if the variable a is equal to 1, and if so, runs the expression [3b:] which assigns 3 to b.

While

The "while" operator is #. It takes the top two stack elements, both lambda expressions, and continually evaluates the second element, then the top element, until the second one stops returning true (that is, leaving a true boolean on top of the stack).

For example,
[a;1=][2f;!]#
runs the expression [2f;!] (which puts 2 on the stack and runs whatever lambda expression is contained in the variable f) for as long as the variable a is equal to 1.

Strings

String
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

s are not a real data type in FALSE; they only exist as string literal
String literal
A string literal is the representation of a string value within the source code of a computer program. There are numerous alternate notations for specifying string literals, and the exact notation depends on the individual programming language in question...

s and cannot be stored directly on the stack nor in variables, and cannot be modified. However, they can be contained within lambda expressions (which can be stored). When a string is encountered it is simply printed as output. Strings are any character sequence between double-quotes (""), including newlines. So, a program consisting simply of
"Hello world!
"
would print "Hello world!" followed by a new line.

Lambda expressions can contain strings. For example:
a;1=["true"]?
would print "true" if the variable a is equal to 1.

Input / Output

Apart from strings, which print themselves, FALSE has a number of operators for input/output
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 from and to standard streams
Standard streams
In Unix and Unix-like operating systems , as well as certain programming language interfaces, the standard streams are preconnected input and output channels between a computer program and its environment when it begins execution...

.
  • . (period) prints the topmost stack item out as an integer.
  • , (comma) prints out the topmost stack item as an ASCII
    ASCII
    The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

     character.
  • ^ reads a single character from standard input and pushes it on the stack.
  • ß flushes both standard input and standard output streams.

Code examples

Sample programs taken from the FALSE Programming Language web page:

Hello world
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

:
"Hello world!
"

File copy utility. Usage: copy < infile > outfile
ß[^$1_=~][,]#

Factorial
Factorial
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n...

 calculator for numbers 1 through 8:
[$1=~[$1-f;!*]?]f: { fac in FALSE }
"calculate the factorial of [1..8]: "
ß^ß'0-$$0>~\8>|$
"result: "
~[\f;!.]?
["illegal input!"]?"
"

Write all prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s up to 100:
99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#

See also

  • Forth programming language, from which the structure of FALSE was derived.
  • Esoteric programming language
    Esoteric programming language
    An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

  • Stack-oriented programming language
    Stack-oriented programming language
    A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....


External links





x
OK