stupidBASIC
It reads like BASIC and works like an accumulator machine, and one of its ifs runs when it feels like it.
2021 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
stupidBASIC is a 2021 member of the stupid family of languages, next to stupidc and stupidexpr. Its lines look like BASIC, a command and an argument, but every command works one accumulator, as the Asparagus assembly does. Every value is text and turns into a number only when arithmetic needs one.
Read the story
The argument runs to the end of the line, and its spaces count. store this is a variable and store thisisavariable name two different variables, and set bottles of beer with two spaces sets a text that starts with a space. The specification warns that some commands change the accumulator without telling you, that multiply, divide and modulo are to be removed for extra stupidity, and that ifidk runs its block if the interpreter feels like it.
The machine
| Command | Does |
|---|---|
load x store x | Accumulator from or to a variable |
set text append text newline | Set the accumulator; add text or a line break to it |
add n subtract n multiply n divide n modulo n | Arithmetic on the accumulator |
print print newline say text | Print the accumulator, a line break or the text |
ask text get key get key and wait | Read a line or a key into the accumulator |
get random get timer get time | A random number or the clock |
if n ... end if | Run the block when the accumulator equals n |
ifne iflt ifgt ifle ifge ifidk | The same for other comparisons, and for a whim |
loop ... end loop | Repeat until an exit loop |
program name ... end program | A routine for do name; the one without a name runs |
exit rem | Leave the block named, or the innermost one; a comment |
An argument that starts with a digit is a number, anything else names a variable. This implementation has no clock, so timer and time read 0, and random and ifidk draw from a fixed seed. Every run replays.
Example
The cat echoes one key.
The cat echoes one key.
A countdown prints the accumulator, takes 1 and leaves the loop at 0.
The 99 bottles of beer program counts down the same way and ends with exit program. The specification does not say how a number looks after arithmetic, and this implementation writes 98 as plain digits.
Further
See also
Also in Jokes
Write your own in Run Convert a program from stupidBASIC
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: stupidbasic.
Command line
shib run stupidbasic -e 'program
say Hello, world!
end program'shib manual stupidbasicSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/stupidbasic.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org