DEV Community

Cover image for 🧩 ConcatenativeScript — JavaScript Reimagined as a Stack-Based Language
Pʀᴀɴᴀᴠ
Pʀᴀɴᴀᴠ

Posted on

🧩 ConcatenativeScript — JavaScript Reimagined as a Stack-Based Language

What is ConcatenativeScript?

ConcatenativeScript is an experimental attempt to reimagine JavaScript as a concatenative, stack-based language similar to Joy, Cat, and Forth. Instead of writing functions with arguments, parentheses, and named variables, programs are written as sequences of stack operations, where functions implicitly consume and produce values.

It exists mainly as a proof-of-concept showing that a modern scripting language could adopt point-free computation while still targeting JavaScript runtimes.


Specs

Language Type: Experimental concatenative scripting language

Era: ~2018–2022 hobby project wave

Execution Model: Transpiles → JavaScript → Executes in browser or Node

Typing: Dynamic (inherits JS semantics)

Paradigm: Stack-based, point-free, functional


Example Code (Hello World)

"Hello, ConcatenativeScript!" log
Enter fullscreen mode Exit fullscreen mode

A simple math example:

3 4 + 2 * log
Enter fullscreen mode Exit fullscreen mode

Equivalent JavaScript:

console.log((3 + 4) * 2);
Enter fullscreen mode Exit fullscreen mode

How It Works

ConcatenativeScript replaces JavaScript syntax with stack operations. Every token is either:

  • a literal pushed to the stack
  • a word (operator/function) that manipulates the stack
  • a combinator that controls execution flow

The runtime maps tokens to JavaScript behavior:

Token Meaning
log console.log(pop())
dup Duplicate top value
swap Swap top two values
call Call a JS function reference
map Apply quotation/function to array elements

More advanced versions allow quoting code as list values, giving higher-order functions similar power to Joy or Factor.


Strengths

  • Fun crossover between JavaScript and concatenative languages
  • Easy integration with browser APIs and Node.js ecosystem
  • Simple syntax encourages experimentation and minimalism
  • Helps JavaScript developers learn stack-based thinking

Weaknesses

  • Not a standard or widely adopted language
  • Debugging stack operations can be confusing
  • Lack of mature tooling or editor support
  • Performance depends entirely on JavaScript execution

Where to Run

ConcatenativeScript can be run using:

  • GitHub prototypes and early interpreter builds
  • Browser-based playgrounds with live execution
  • Node.js scripts using custom module loaders
  • TIO.run (limited syntax versions)

Some interpreters include visual stack inspection to help debugging.


Should You Learn It?

  • For real production work: No
  • For learning concatenative thinking from a JS background: Yes
  • For hobby languages, experimentation, and esolang collecting: Absolutely
  • For writing maintainable large codebases: Not practical

Summary

ConcatenativeScript brings the world of stack-based programming into the JavaScript ecosystem, stripping away variables and arguments in favor of pure value flow and function composition. While experimental and niche, it remains an interesting exploration of how modern scripting languages could adopt radically different paradigms — challenging assumptions about what programming must look like.

Top comments (0)