We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

RNA

From Esolang
(Redirected from DNA)
Jump to navigation Jump to search

RNA is an esoteric programming language based on real biological RNA structure. It was created in 2008 by Cyrus H. and first implemented in 2011.

Programs are written as sequences of codons — triplets of the nucleotide letters A, U, G, C — making source code look like actual RNA strands.

Language Basics

Storage Model

RNA provides three storage abstractions:

Name Width Internal type Description
strg 8-bit unsigned char Index register used to manipulate ptr
ptr 32/64-bit unsigned char * Memory index storage, points into memory
memory unbounded unsigned char [] Serial byte storage, limited only by physical RAM

Execution

  • Execution begins at the first Methionine codon (AUG). All codons before it are ignored.
  • Execution ends at the first Termination codon (UAA, UAG, or UGA). All codons after it are ignored.
  • Non-nucleotide characters (whitespace, digits, punctuation, etc.) are silently skipped by the parser, allowing inline comments.

Comments

Any character that is not one of A, U, G, C (or T for the DNA dialect) is treated as whitespace and ignored. This means any text not containing those five letters is effectively a comment. For example:

!! This is a comment — no A/U/G/C/T letters here
UGG ACA CCC  !! set mem[0] via input

Commands

There are 16 active instructions covering 49 codons. 5 additional amino-acid groups are reserved as No-Op.

Active Instructions

# Amino acid Codons Operation Description
1 Methionine (Met) AUG program entry Program activation indicator
2 Termination (Ter) UAA UAG UGA program exit Program termination indicator
3 Tryptophan UGG strg = 0 Reset index register
4 Lysine AAA AAG ++strg Increment index register
5 Asparagine AAC AAU --strg Decrement index register
6 Alanine GCA GCC GCG GCU strg = *ptr Read memory byte into strg
7 Threonine ACA ACC ACG ACU ptr = &memory[strg] Reposition pointer
8 Proline CCA CCC CCG CCU scanf("%d", ptr) Read decimal integer, store low 4 bits at *ptr
9 Leucine CUA CUC CUG CUU printf("%c", *ptr) Output *ptr as ASCII (low 7 bits)
10 Arginine AGA AGG CGA CGC CGG CGU *ptr += memory[strg] Addition
11 Serine AGC AGU UCA UCC UCG UCU *ptr *= memory[strg] Multiplication
12 Glutamine CAA CAG *ptr -= memory[strg] Subtraction
13 Histidine CAC CAU *ptr /= memory[strg] Division
14 Glutamic acid GAA GAG *ptr = (*ptr == memory[strg]) ? 1 : 0 Equality test
15 Aspartic acid GAC GAU while (*ptr) { Loop start. If *ptr == 0, skip to matching Tyrosine.
16 Tyrosine UAC UAU } Loop end. Jump back to matching Aspartic acid.

Reserved Instructions (No-Op)

# Amino acid Codons
17 Cysteine UGC UGU
18 Phenylalanine UUC UUU
19 Isoleucine AUA AUC AUU
20 Glycine GGA GGC GGG GGU
21 Valine GUA GUC GUG GUU

Codon Encoding

Each codon is 3 nucleotides. Internally, nucleotides are mapped to digits: A=1, U=2, G=3, C=4. Three nucleotides are combined as first×100 + second×10 + third×1.

For example, AUG = 1×100 + 2×10 + 3×1 = 123.

Examples

Hello World

Since Proline (scanf) can only read values 0–15, each output character must be decomposed into a product of two small factors plus an optional adjustment: value = a × b + c where a, b ∈ [1,15] and |c| ≤ 15.

Full RNA program (line form), 696 nucleotides:

AUGUGGACACCCAAAACACCCUGGACAAAAAGCCUAUGGACACCCAAAACACCCUGGACAAAAAGCAAAACACCCUGGACAAAA
AAAAGACUAUGGACACCCAAAACACCCUGGACAAAAAGCCUAUGGACACCCAAAACACCCUGGACAAAAAGCCUAUGGACACCC
AAAACACCCUGGACAAAAAGCAAAACACCCUGGACAAAAAAACAACUAUGGACACCCAAAACACCCUGGACAAAAAGCCUAUGG
ACACCCAAAACACCCUGGACAAAAAGCAAAACACCCUGGACAAAAAAACAACUAUGGACACCCAAAACACCCUGGACAAAAAGC
AAAACACCCUGGACAAAAAAACAACUAUGGACACCCAAAACACCCUGGACAAAAAGCAAAACACCCUGGACAAAAAAAAGACUA
UGGACACCCAAAACACCCUGGACAAAAAGCCUAUGGACACCCAAAACACCCUGGACAAAAAGCCUAUGGACACCCAAAACACCC
UGGACAAAAAGCCUAUAA

The companion input file provides the small integers that Proline reads:

6 12 10 10 1 9 12 9 12 8 14 1 4 8 8 11 1 8 14 1 8 14 2 9 12 10 10 3 11

Fibonacci Numbers

This program outputs the first 13 Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144) as raw bytes. It uses a loop with all four arithmetic operations.

AUGUGGACACCCAAAACACCCUGGAAAAAAAAAACACCCUGGAAAAAAAAAAAAAAAAAAACACCCUGGAAAAAAAAAACAG
ACUGGACACUAUGGAAAAAAAAAAAAACACAAUGGAGAAAAAGAUGGACACAAAAAAGAUGGAAAACACAAAAAAAAAAAAG
AUGGAAAAAAAAAACAAAAAAAAAACAAUACUAA

Companion inputs: 0 1 13 1

Dialect

DNA

The DNA dialect replaces U (Uracil) with T (Thymine). All instructions map one-to-one; converting an RNA program to DNA is a simple find-and-replace. For example, AUG becomes ATG, UAA becomes TAA.

Both the original C interpreter and the Python interpreter linked below support the DNA dialect natively.

Implementations

  • Python interpreter — Full-featured, modular implementation with nested-loop support, DNA dialect compatibility, and example programs.
  • C reference implementationOriginal C99 implementation by Cyrus H., compilable with GCC under macOS.