esolang

RNA

A program is a strand of RNA. Three letters make a codon, and each codon is an amino acid with a job.

Cyrus H., 2008 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: A

The idea

Cyrus H. created RNA in 2008 and first implemented it in 2011. A program is a string of the letters A, U, G and C, read three at a time as codons, the way a ribosome reads a messenger strand. Work starts at the first AUG, the start codon, and ends at the first stop codon. The amino acid a codon codes for decides what it does, so 49 of the 64 codons make 16 instructions and the other 15 do nothing. Every other character is ignored, which leaves room for comments, and the DNA dialect writes T for U.

Read the story

A program has no number literals. The Hello World reads its numbers from the input, and a read keeps 4 bits of what it reads, so it takes 29 numbers from 0 to 15 and builds each letter as a product plus a correction. H is 6 times 12, and e is 10 times 10 plus 1.

The machine

Memory is a row of bytes. strg is an 8-bit register that picks a cell, and ptr points at the current one. In the table x is any of the four letters.

CodonsAmino acidDoes
AUGMethionineStart
UAA UAG UGAStopEnd
UGGTryptophanstrg = 0
AAA AAGLysinestrg + 1
AAC AAUAsparaginestrg - 1
GCxAlaninestrg = *ptr
ACxThreonineptr = &memory[strg]
CCxProlineRead a number into *ptr, low 4 bits
CUx UUA UUGLeucinePrint *ptr as a byte
AGA AGG CGxArginine*ptr += memory[strg]
AGC AGU UCxSerineptr = memory[strg]
CAA CAGGlutamine*ptr -= memory[strg]
CAC CAUHistidine*ptr /= memory[strg]
GAA GAGGlutamic acid*ptr = 1 if it equals memory[strg], else 0
GAC GAUAspartic acidWhile *ptr is not 0
UAC UAUTyrosineEnd of the loop

All arithmetic wraps at 256. The specification's table gives Leucine only the four CUx, but it counts 49 active codons, and the genetic code's UUA and UUG make up the 49, so they print too. The table also says output keeps the low 7 bits, but the C call it shows and its own Fibonacci, which prints 144, give the whole byte, and so does this implementation.

Example

A is 5 times 13.

A is 5 times 13. The first CCC reads 5 into memory[0]. Then strg goes to 1, ptr follows, and the second CCC reads 13 there. Back on memory[0], AGC multiplies it by memory[1] and CUA prints it. The second line is the same program in the DNA dialect.

Expected: A

Hello World with its companion input.

Expected: Hello World!

The Fibonacci program reads 0, 1, a count of 13 and a 1 to count down with. Its loop prints the first 13 Fibonacci numbers as raw bytes, from 0 up to 144.

Patterns it teaches

  • Camouflage: the source reads as a strand of RNA, start and stop codons included.
  • Encoding tricks: every character is built from two 4-bit numbers.

Further

Cell-based

Write your own in Run Convert a program from RNA

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run rna -e 'AUGUGGACACCCAAAACACCCUGGAAAAAAAAAACACCCUGGAAAAAAAAAAAAAAAAAAACACCCUGGAAAAAAAAAACAG
ACUGGACACUAUGGAAAAAAAAAAAAACACAAUGGAGAAAAAGAUGGACACAAAAAAGAUGGAAAACACAAAAAAAAAAAAG
AUGGAAAAAAAAAACAAAAAAAAAACAAUACUAA' --input '0 1 13 1'
shib manual rna

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/rna.js

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

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