esolang

RProgN

Reverse Programmer Notation. Any expression written in reverse Polish notation should work.

TehFlaminTaco · Turing complete: unknown · ●●○ moderate

Tested with 6 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

RProgN, short for Reverse Programmer Notation, was written in Lua by TehFlaminTaco. The goal was that any expression in reverse Polish notation runs as it is, so 2 3 + 4 * gives 20. Words are separated by spaces. A number pushes itself, a known word runs, and a word the interpreter does not know is quietly skipped.

Read the story

When the program ends, the whole stack is printed from the top, one value per line. So a string on its own is a Hello World.

The machine

WordDoes
5, 2.5Push a number
"text", 'text'Push a string; spaces inside are kept
+ - * /Arithmetic; / always gives a float
] [ \Duplicate, drop, swap
p wPrint with a newline, write without
true falseBooleans

The full language has well over a hundred words for loops, functions, memory, Lua string patterns, and single character aliases for many of them. This implementation has the core above and stops on the rest.

Example

In the last one Hello is not a word RProgN knows, so it does nothing, and the stack is printed from the top.
Expected: 20
Expected: 3 2 1

In the last one Hello is not a word RProgN knows, so it does nothing, and the stack is printed from the top.

Patterns it teaches

  • Stack machines: the stack is the program's only memory and its output.
  • Concatenative: a program is words in a row, each acting on the stack the last one left.

Try this

  1. Print the average of 3, 4 and 8.
  2. Print three lines with p and see where the final stack goes.
  3. Hard: print 1 2 3 on one line with w, leaving nothing on the stack.

Further

Also in Golfing

Write your own in Run Convert a program from RProgN

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: rprogn.

Command line

shib run rprogn -e '2 3 + 4 *'
shib manual rprogn

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/rprogn.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language