Translation

From Esolang
Jump to navigation Jump to search
Translation
Paradigm(s) Concatenative
Designed by Joe
Appeared in 2024
Memory system stack
Dimensions one-dimensional
Computational class Unknown
Reference implementation In Factor (GitHub)
File extension(s) .mrna

Translation is an esolang made by User:Joe, heavily based on the translation of mRNA within ribosomes into polypeptide chains.

Syntax

Translation's syntax models the codons in messenger RNA, which consist of groups of three RNA nucleotides (which are represented by the characters A, U, C, G).

As in human mRNA, every program must start with the codon AUG (which is also a command that can be used later). And the program must also end with the codon UAG, UAA, or UGA.

When writing the program, no special formatting for creating groups of three codons is required, and all characters besides A, U, C and G are ignored. However, it is encouraged to write with grouped formatting. For example, the following programs are equivalent:

 AUG UUA CUU AAU CGU UAG
 AhiUfriendG addUUAone aCgUaUin aAaAdU call CGU end prog U  Aaaaaaaaaaaaa G

Commands

Here is a table of the corresponding Codons and instructions. Some instructions have multiple codons corresponding to them.

Another thing to note is that all commands beside Leu (push 1), Met (push 2), His (push empty quote), Ser (evaluate quote n times), and Arg (evaluate quote on top of stack), push the command within a quotation. To evaluate it, you have to call either Ser or Arg.

(There are 20 instructions because there are 20 amino acids used within the human body, and the codons for each amino acid/instruction are taken exactly from a Codon chart.). TODO: write stack effects

Command Amino acid Description
UUU UUC Phe Read a character from stdin and push it onto the stack.
UUA UUG CUU CUC CUA CUG Leu Push 1 to the top of the stack.
AUU AUC AUA Ile Print number on the top of the stack as character and pop it.
AUG Met Push 2 to the top of the stack.
GUU GUC GUA GUG Val Dip (evaluate quote starting from second value on stack)
UCU UCC UCA UCG AGU AGC Ser Evaluate quote on the top of the stack n times. The number is the first argument.
CCU CCC CCA CCG Pro Combine the two quotations on the top of the stack. Like compose in factor.
ACU ACC ACA ACG Thr Drop the top item on the stack.
GCU GCC GCA GCG Ala Duplicate the top item on the stack.
UAU UAC Tyr Duplicate the second item on the stack.
CAU CAC His Push empty quote onto the stack.
CAA CAG Gln Put the second value on the stack into the quote given as the first argument. Like curry in factor.
AAU AAC Asn Add the top two numbers on the stack. (for numbers)
AAA AAG Lys Subtract the top item on the stack from the second. (for numbers)
GAU GAC Asp Multiply the top two items on the stack. (for numbers)
GAA GAG Glu Divide the second element on the stack by the top element. (for numbers)
UGU UGC Cys Take the second element on the stack to the power of the first element. (for numbers)
UGG Trp Print the number on the top of the stack as a string, and pop it. (different from Ile)
CGU CGC CGA CGG AGA AGG Arg Call and evaluate the quotation on the top of the stack.
GGU GGC GGA GGG Gly Swap the top two items on the stack.
Any other codon, of length 3 or less N/A Ignored.

Mutations

So far this is just another boring stack language. This is where the fun begins.

In cells, mRNA is prone to mutate, causing the polypeptide to possibly be modified. Similarly, programs in Translation also mutate.

Precisely 1/3 of your program will be mutated (this might be customizable in the future). The interpreter then randomly chooses which nucleotides to mutate, and randomly chooses which mutation to apply. There are only 3 kinds:

Also the start codon will never be mutated, nor the ending codon (though the end might change due to insertions and deletions).s

Substitution

 AUG --> ACG

Deletion

This shifts the program after whichever character is deleted

 AUG --> AG

Insertion

Also shifts the program

 AUG --> AUC G

(Though if you are boring, there is an option to disable the mutation when running a program in the factor interpreter).

Writing Deterministic Programs

TODO Using the fact that multiple codons correspond to the same instruction might help. RNA in real life uses that feature to prevent many mutations from having big effects.

Using the fact that codons that don't correspond to a command are ignored could be used to counteract possible mutations and so on.

Computational Class

TODO

Since Translation implements swap, add, sub, mul, div as well as a way to push a 1 to the stack, Translation is an extended pushdown automaton, and assuming unbounded elements, is Turing complete if mutation is disabled. Quotations likely can also be used to perform arbitrary computation. In either case special techniques (currently unknown) would have to be used in order to translate arbitrary programs into deterministically executing Translation programs.

Example Programs

TODO

Implementations