str
A tool for modifying streams, character by character.
Conor O'Brien, 2026 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 7 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
str is a stack language by Conor O'Brien, written in Ruby, built around a stream. The program is cut at ; into up to three parts. The first runs once before any input. The second runs once for every byte of input, with that byte pushed as a one-character string, and whatever is left on top is printed. The third runs once at the end.
Read the story
So a program with no ; at all is a filter. X alone adds one to every character, which turns HAL into IBM. Put the work in front of a ; and it runs once, which is how the Hello World works.
Most commands work on integers and strings alike. On a string, arithmetic goes one code point at a time, so X increments every character and + with a number shifts them all.
The machine
| Command | Does |
|---|---|
12, `text` , 'c, [code] | Push a number, a string, one character, or code as a string |
~ $ d H J | Swap, drop, duplicate, copy the nth item, bring the nth up |
+ - * / % ^ | Arithmetic, or the same on each code point of a string |
< > = N | Compare, giving 1 or 0; N is 1 for 0 |
S X Y _ y c m M | Length, increment, decrement, reverse, code, character, to string, to number |
x : a K k | Repeat, join, index, slices |
o O r R p | Print, with a newline, in backticks, with sprintf |
g G I l | Read a byte, n bytes, a number, the rest |
? , . | If the top is 0 skip to ,; a , skips to . |
! f &:x &x | Run a string; name it as a command; store it; fetch and run it |
b u q W | Buffer a value, take it back, no print this time, show the stack at the end |
Popping an empty stack ends the program. Integers have no size limit.
Example
The fourth one is a quine.
The fourth one is a quine. It pushes the string dro;, duplicates it, prints one copy in backticks with r and the other plain with o. The last counts the input. The preamble pushes 0, the body drops each byte, adds one to the count and turns off its print with q, and the end prints the count.
Patterns it teaches
- Stack machines: one stack, with the input fed onto it a byte at a time.
- Quines:
rprints a string the way it is written in the source, which makes quines short.
Try this
- Turn every letter of the input into upper case.
- Print the input with every
ataken out. - Hard: print the input backwards, using the buffer or the postamble.
Further
Not the same language as the stack roller called Str on esolangs.org.
- The reference interpreter, in Ruby
Not the same language as the stack roller called Str on esolangs.org.
See also
Stack-based
Write your own in Run Convert a program from str
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: str.
Command line
shib run str -e 'X' --input 'HAL'shib manual strSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/str.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org