esolang

TrumpScript

A program must end with "America is great", every number must be over a million, and only 2,196 approved words may be used.

2016 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 5 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: hello, world!

The idea

TrumpScript appeared in 2016, during the American presidential campaign, and its README calls it the programming language Trump would approve of. It is a joke about rules more than about syntax. There are no imports and no floating point literals. Numbers below 1,000,000 are refused, because "I'm really rich". Forbes' figure of 4.5 billion is quietly corrected to 10 billion.

Read the story

Under the jokes is a small compiler in Python. It reads the program, lowercases all of it, turns it into a Python syntax tree and runs that.

The machine

WordsDo
make money 5000000 or money is 5000000Assign
money is 5000000?Compare, giving True or False
say money tell moneyPrint
name hearRead a line into name
plus minus times over and + - * /Arithmetic
if, ... ; : ... ! elseA condition in , ; and a block in : !
as long as, ... ; : ... !A while loop
fact lie notTrue, false, not

Any other word must come from the approved list, and is otherwise thrown away unless it follows make or comes before is or hear, which makes it a variable. The parser is rough and this implementation keeps its roughness. less, more, and and or are dropped before parsing, so there is no comparison except equality. After a word, an operator takes only one more word, so count is count minus 1000000 just copies count; write count is 1000000 plus count instead.

Example

Everything in the program is lowercased first, strings included, so Hello, World! comes out in small letters.
Expected: 3000000000000
Expected: 1000000 2000000 3000000
Expected: Donald
Expected: Parsing error: What are you doing on line 1?

Everything in the program is lowercased first, strings included, so Hello, World! comes out in small letters. The last program uses a number that is too small.

Patterns it teaches

  • Camouflage: a program reads as campaign speech, and the vocabulary check enforces the style.

Try this

  1. Print the sum of two million and three million.
  2. Read a number and say whether it is one million.
  3. Hard: count from one million to five million in steps of one million.

Further

The reference flips the meaning of true and false with the minute of the clock; this implementation keeps…

The reference flips the meaning of true and false with the minute of the clock; this implementation keeps them fixed so a run can be replayed.

Pseudonatural

Write your own in Run Convert a program from TrumpScript

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run trumpscript -e 'say "Hello, World!"
America is great.'
shib manual trumpscript

Source

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

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

Source esolangs.org (CC0) · Edit on esolangs.org