esolang

ORK

Objekts R Kool. Every operation, even adding two numbers, is a request to an object, written as an English sentence.

Gregor Richards, 2005 · Turing complete: yes · ●●○ moderate · esolangs.org

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

Run it

Expected: Hello, world!

The idea

Gregor Richards made ORK in 2005 as, in the words of its spec, the polar opposite of brainfuck. A program is a set of class definitions and a main part, all in sentences. There are no operators at all. To add, you hire a mathematician, give it a first and a second operand, tell it to add, and read its result. To print, you need a scribe; to read, an inputter; to compare words, a linguist.

Read the story
When this program starts:
There is a scribe called Writer.
Writer is to write "Hello, world!"

Classes are described the same way. There is such a thing as a counter. starts one, A counter has a brain which is a mathematician. gives it a member, and A counter can count. declares a method, which When a counter is to count: then defines. I am to loop jumps back to the start of the method, and If brain says it's greater then … tests a flag.

The machine

SentenceDoes
There is a T called NA local object, word or number
X is Y X's Y is ZAssign, also to a member
X is to F [Y] I am to F [Y]Call a method on X, or on this object
If X says it's equal then …Test one of an object's flags
I am to loop I am to quitRun the method again from the top; stop the program
A X has a Y which is a Z A X can F a TA member; a method taking a word, number or object

The built in classes are the scribe (write, asciiWrite), the inputter (read a word or number, readOne a character, it's done at the end), the mathematician (operands, add subtract multiply divide modulo compare floor, result) and the linguist (concatenate, compare), plus word and number arrays.

Try It Online runs ork.c, which turns every sentence into a line of C++ and has the result compiled. This implementation reads the sentences the same way and refuses what the C++ compiler would refuse, so such a program prints nothing. That catches a few programs on the esolangs.org page. Its truth machine defines methods its class never declares, its quine passes a quoted string where a method expects a variable and has a number called char, and its Deadfish interpreter has a member called register. char and register are C++ keywords. The truth machine below has the missing declarations added.

Example

The second program reads one character and writes it back.
Expected: m
Expected: 2.5

The second program reads one character and writes it back. The third divides 10 by 4 the long way. This counter counts down from 3.

There is such a thing as a counter.
A counter has a brain which is a mathematician.
A counter has a voice which is a scribe.
A counter can count.

When a counter is to count:
voice is to write brain's first operand.
brain's second operand is 1.
brain is to subtract.
brain's first operand is brain's result.
brain's second operand is 0.
brain is to compare.
If brain says it's greater then I am to loop.

When this program starts:
There is a counter called c.
c's brain's first operand is 3.
c is to count.
Expected: 321

Patterns it teaches

  • Camouflage: an ordinary object-oriented language, classes, members and methods, disguised as plain English, like ArnoldC disguises its keywords as film quotes.

Try this

  1. Print the numbers 1 to 10, each on its own line (asciiWrite 10 prints a newline).
  2. Read two numbers and print their sum.
  3. Hard: Deadfish, with the member renamed from register.

Further

Object-oriented paradigm

Pseudonatural

Write your own in Run Convert a program from ORK

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run ork -e 'When this program starts:
There is a scribe called Writer.
Writer is to write "Hello, world!"'
shib manual ork

Source

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

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

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