emoji
๐ Stack-Based Emoji Programming Language
A Forth-inspired stack language where everything is emoji.
Quick Example
๐ญ Hello World
๐คHello, World!๐ค ๐
๐ญ Math with keycap digits
5๏ธโฃ 3๏ธโฃ โ 2๏ธโฃ โ๏ธ ๐ ๐ญ (5 + 3) * 2 = 16
๐ญ Define square function
๐ ๐ช ๐ โ๏ธ ๐
7๏ธโฃ ๐ช ๐ ๐ญ prints 49
๐ญ Factorial with recursion
๐ โ
๐ 2๏ธโฃ โฌ๏ธ ๐
๐๏ธ 1๏ธโฃ
๐
๐ 1๏ธโฃ โ โ โ๏ธ
๐
๐
5๏ธโฃ โ ๐ ๐ญ prints 120
Getting Started
Requirements:
- Crystal - required to run the transpiler
- Python 3 - optional, only needed if using the Python backend
Quick Start:
- Install Crystal.
- Run an example:
crystal src/cli.cr examples/hello.emoji
Installation & Usage
# Run a program with Crystal backend (default - transpiles, compiles, and executes)
crystal src/cli.cr examples/hello.emoji
# Run a program with Python backend (transpiles and executes)
crystal src/cli.cr examples/hello.emoji --backend python
# Show generated code with Crystal backend
crystal src/cli.cr examples/hello.emoji --show-code
# Use Python backend and show generated code
crystal src/cli.cr examples/hello.emoji --backend python --show-code
# Save generated code to file
crystal src/cli.cr examples/hello.emoji -o output.cr
crystal src/cli.cr examples/hello.emoji --backend python -o output.py
Language Reference
Literals
Numbers:
๐ข42- number literal (for any number)3๏ธโฃ- keycap digit (0๏ธโฃ-9๏ธโฃ for single digits)
Strings:
๐คtext๐ค- string literal
Booleans:
โ- trueโ- false
Basic Stack Operations
๐- dup (duplicate top)๐๏ธ- drop (remove top)๐- swap (swap top two)๐- over (copy second to top)
Advanced Stack Operations (Tier 2)
๐- rot (rotate 3 forward: a b c โ b c a)๐- -rot (rotate 3 backward: a b c โ c a b)๐ช- 2dup (duplicate top 2: a b โ a b a b)๐ฎ- 2drop (drop top 2)๐ฏ- pick (copy nth item)
Arithmetic
โ- addโ- subtractโ๏ธ- multiplyโ- divide๐- modulo
Comparison
๐ฐ- equalโฌ๏ธ- greater thanโฌ๏ธ- less than
Boolean Operations
โก- or (logical OR)๐- and (logical AND)๐ซ- not (logical NOT)
I/O
๐- print (with newline)๐ฌ- emit (without newline)๐ค- input (read from stdin)
Control Flow
๐- loop (repeat while true on stack)๐- starts a conditional (then branch first)๐- starts a conditional (else branch first)๐- ends a conditional
Conditional Syntax:
๐ <then> ๐ ๐ญ If true, execute then
๐ <then> ๐ <else> ๐ ๐ญ Then/else (traditional order)
๐ <else> ๐ ๐ญ If false, execute else
๐ <else> ๐ <then> ๐ ๐ญ Else/then (reversed source order)
Word Definition
๐ <emoji>- start word definition๐- end word definition
Variables
๐ฆ <emoji>- declare variable๐พ <emoji>- store to variable (pops value from stack)๐ค <emoji>- fetch from variable (pushes value to stack)
Return Stack
โฌ ๏ธ- push to return stackโก๏ธ- pop from return stack๐๏ธ- peek return stack (non-destructive)
Comments
๐ญ- comment to end of line
How It Works
.emoji source โ Tokenizer โ Parser โ AST โ Backend โ Compile โ Run
- Tokenizer - Converts emoji to tokens
- Parser - Builds Abstract Syntax Tree
- Backend - Code generation (pluggable: Crystal, Python, etc.)
- Transpiler - Ties it together
- Execution - Compiles and runs generated code
Backend Implementations
Crystal Backend:
- Generates Crystal code
- Uses module with class variables for state
- Macros for stack operations
- Fast execution (compiled)
Python Backend:
- Generates Python 3 code
- Uses module-level variables for state
- Helper functions for stack operations
- Emoji names are hex-encoded for Python compatibility
- Interpreted execution
Pluggable Architecture
- Easy to add new backends (Rust, JavaScript, etc.)
- Shared AST representation
- Backend-agnostic tokenizer and parser
Stack-Based Execution:
5๏ธโฃ 3๏ธโฃ โ
โ push 5, push 3, add
โ stack: [8]
Word Definitions:
๐ ๐ช ๐ โ๏ธ ๐ ๐ญ Define ๐ช (square) as: dup multiply
5๏ธโฃ ๐ช ๐ญ Call it: push 5, call square
โ stack: [25]
Recursion:
๐ โ
๐ 2๏ธโฃ โฌ๏ธ ๐
๐๏ธ 1๏ธโฃ
๐
๐ 1๏ธโฃ โ โ โ๏ธ
๐
๐
Testing
- Unit tests:
crystal spec - Integration tests:
crystal src/test_runner.cr tests/; single file:crystal src/test_runner.cr tests/boolean_ops.test.emoji
Design Philosophy
Inspired by Forth and Factor, this is a concatenative language where:
- Everything is a word (function)
- Words consume and produce stack values
- Composition is concatenation (
๐ช ๐ช= square twice) - Minimal primitives, maximum composition
- Optional variables (data flow can use stack or variables)
Credits
Inspired by:
- Emojicode - The original emoji programming language
- Forth - Stack-based concatenative language
- Factor - Modern concatenative language
- Crystal - The implementation language
License
This work is dedicated to the public domain by Todd Sundsted worldwide using the CC0 1.0 Universal Public Domain Dedication.
Repository
emoji
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- 2 months ago
- December 8, 2025
License
Other
Links
Synced at
Wed, 28 Jan 2026 00:50:41 GMT
Languages