Nullscript
NullScript is an experimental functional programming language centered around the concept of "nothingness." Unlike traditional programming languages that have a single null value, it is characterized by distinguishing between four different states of "nothing."
Overview
NullScript is a functional programming language developed in 2025, aimed at bringing the philosophical concept of "nothingness" into programming. The language's greatest feature is treating "having nothing" as four different concepts, each given its own meaning.
No comments yet
Language Features
Four Void Values
NullScript distinguishes between the following four types of "nothing":
- none - Represents the absence of something. Basic unit for numeric encoding
- nil - List terminator, empty container. Treated as true value in conditional branches
- undefined - Undefined state. Treated as false value in conditional branches
- null - Explicit empty value, representing intentional nothingness
Other Features
- Pure Functional: Function-centered design without side effects
- Pair Structure: All data is represented by pairs (2-element tuples)
- Pattern Matching: Supports structural conditional branching
- Numeric Encoding: No integer literals exist; numbers are represented by nested pairs
- Reference Counting: Automatic memory management
Basic Syntax
Data Types and Values
// Four void values none nil undefined null // Pair (2-element tuple) pair(nil, undefined) // List (chain of pairs) list(none, nil, undefined)
Function Definition
function identity(x) { x } function swap_pair(p) { pair(cdr(p), car(p)) }
Conditional Branching
// if statement (nil is true, others are false) if eq(x, nil) { undefined } else { null } // Pattern matching match value { case nil -> none case pair(x, y) -> x case _ -> undefined default -> null }
Numeric System
NullScript has no integer literals, and numbers are encoded in pair structures as follows:
0 → nil 1 → pair(none, nil) 2 → pair(none, pair(none, nil)) 3 → pair(none, pair(none, pair(none, nil)))
Examples of Numeric Operations
// Increment function inc(n) { pair(none, n) } // Decrement function dec(n) { match n { case nil -> nil case pair(none, rest) -> rest default -> nil } } // Addition function add(a, b) { match b { case nil -> a case pair(none, rest) -> add(inc(a), rest) default -> undefined } }
Hello World
"Hello World" in NullScript involves encoding each character with ASCII values and outputting them:
// Output 'H' (ASCII 72) function print_h() { print(pair(undefined, pair(none, pair(none, /* ...72 nested pairs... */, nil)))) } // More practical example: using numeric constants function _72() { mul(_8(), _9()) } function print_h() { print_char(_72()) } function print_char(c) { print(pair(undefined, c)) }
Built-in Functions
- eq(a, b) - Equality test (returns nil if equal, undefined if different)
- car(pair) - Get first element of pair
- cdr(pair) - Get second element of pair
- print(format_pair) - Output values
- pair(none, value) - Output as number
- pair(undefined, value) - Output as ASCII character
- pair(null, value) - Output as type name
Implementation
The current implementation is written in C and has the following features:
- Lexical Analyzer: Tokenization processing
- Parser: Recursive descent parser
- Evaluator: Abstract syntax tree interpreter
- Memory Management: Reference counting system
- REPL: Interactive execution environment
Build Instructions
make ./build/nullscript # Start REPL ./build/nullscript file.ns # Execute file
Limitations
- No integer or floating-point literals
- No string literals (characters encoded as ASCII values)
- Inefficient representation of large numbers
- Possible memory leaks due to circular references
- Stack overflow from deep recursion