DNA-Sharp

DNA# is an esoteric programming language which is based on the schematic structure of the DNA molecule and was invented 2009 by User: Benni++.thumb|Logo of DNA#
== Commands ==
There are 16 commands:
Command	Brainfuck equivalent	C-equivalent 	Symbols for symbol form
ATAT 	> 	pointer++ / newpointer++ ***	>
ATGC 	< 	pointer-- / newpointer-- ***	<
ATTA 	+ 	 	+
ATCG 	- 	 	-
GCAT 	. (Output as ASCII) 	 	.
GCGC 	, (ASCII input) 	 	,
GCTA 	[ 	 	[
GCCG 	] 	 	]
TAAT * 	 	*pointer = *newpointer 	= or := ****
TAGC * 	 	*pointer += *newpointer 	+=
TATA * 	 	*pointer -= *newpointer 	-=
TACG * 	 	*pointer *= *newpointer 	*=
CGAT * 	 	*pointer /= *newpointer 	/=
CGGC 	 	. (Output as integer value) 	~
CGTA 	 	, (Integer input) 	?
CGCG 	 	- (NOP) 	X**
* A line of ATAT or ATGC commands, selecting "newpointer", can follow these commands (see Special Commands)
** Adding three CGCG commands in a row will print out the program's source (line form)
*** newpointer is only active after Special Commands
**** This change is unofficial and intends to remove ambiguous use of =
==Interpreter(s)==
For now, there is only a single interpreter, written in Javascript.
It simulates a Turing-complete 1D data matrix using a simple javascript array.
== Language Basics ==
===Appearance===
There are three forms of DNA#:
# Helix form (see below)
# Line form (example: "ATGCATATGCATTACG", helix form without "-" and whitespace)
# Symbol form (example: "++>=<X.", symbols instead of 4-Letter-Commands, increasing readability)
===Comments===
Comments can be put into the code similar to C/C++:
 AT
 T--A
 A----T
 T-----A
 A-----T
 T----A /* Comment */
 A--T
 TA
 AT
 A--T
 A----T
 T-----A
 T-----A
 G----C
 A--T
 GC
===Special Commands===
Following commands like =(TAAT), +=(TAGC) etc. it is possible to add a line of ATAT or ATGC commands to select the second variable.
Example (symbol form):
 +++>+=<X>
Commented:
 + + + /* add 3 to reg0 */
 > /* select reg1 */
 += < /* add reg(1-1) (= reg0 ) to reg1 (reg1 is set to 3) */
 X /* nop to stop interpreter from going to non-existant reg(-1) */
 > /* continue in code... */
C-Equivalent to upper example:
 // pos = 0
 reg[pos]++;
 reg[pos]++;
 reg[pos]++;
 pos++;
 reg[pos] += reg[pos-1]; // actually newpos = pos; newpos--; reg[pos] += reg[newpos]
 pos++;
The compiler/interpreter first sets newpos to pos, then parses through the following code until he finds an command inequal ATAT or ATGC. Doing this, he increments (decrements for ATGC) newpos. In the end the actually selected operation (in this case +=) is done.
==Hello World Program==
Hello, World! Program in DNA# (Helix form):
 HelloWorld.dna
 
 AT
 T--A
 A----T
 T-----A
 T-----A
 G----C
 T--A
 GC
 CG
 C--G
 A----T
 A-----T
 T-----A
 A----T
 A--T
 GC
 AT
 C--G
 T----A
 C-----G
 T-----A
 G----C
 C--G
 CG
 AT
 A--T
 T----A
 A-----T
 A-----T
 G----C
 A--T
 GC
 TA
 G--C
 T----A
 G-----C
 C-----G
 C----G
 A--T
 GC
 TA
 G--C
 A----T
 G-----C
 A-----T
 C----G
 A--T
 CG
 GC
 A--T
 A----T
 C-----G
 A-----T
 C----G
 A--T
 CG
 GC
 A--T
 T----A
 G-----C
 A-----T
 G----C
 A--T
 CG
 GC
 A--T
 G----C
 A-----T
 A-----T
 T----A
 A--T
 TA
 AT
 T--A
 G----C
 A-----T
 A-----T
 A----T
 G--C
 AT
 AT
 G--C
 T----A
 G-----C
 A-----T
 G----C
 G--C
 AT
 TA
 T--A
 A----T
 G-----C
 G-----C
 A----T
 A--T
 TA
 AT
 T--A
 A----T
 T-----A
 G-----C
 A----T
 T--A
 TA
 AT
 G--C
 A----T
 T-----A
 A-----T
 T----A
 G--C
 AT
 TA
 T--A
 A----T
 G-----C
 G-----C
 A----T
 A--T
 AT
 AT
 T--A
 G----C
 A-----T
Hello, world! program (line form):
 ATTAATTATAGCTAGCCGCGATATTAATATGCATCGTACGTAGCCGCGATATTAATATGCATGCTAGCTAGCCGCGATGCTAGCATGCATCGATCGGCATATCGATCGATCGGCATTAGCATG
 CATCGGCATGCATATTAATTAATTAGCATATATGCATATGCTAGCATGCGCATTATAATGCGCATATTAATTAATTAGCATTATAATGCATTAATTAGCATTATAATGCGCATATATATTAGCAT
Hello, world! program (symbol form):
 +++=+=X>=<-*=+=X>=<<+=+=X<+=<--.---.+=<-..+++.>.<+=<.-=<.+++.-=<++.-=<.>+.
== Other Examples ==
===Fibonacci Numbers:===
 ATTAATTAATTAATTAATTATACGCGCGATATATATATTAATATATATTAATATGCATGCATGCATGCATTAATTAATTAATTAATTAATTAATTAATGCATGCATGCATGCGCTAATATATATATATTAATATGCTAGCATG
 CATGCCGCGATGCATGCTAATATATCGCGATATTAATATATCGCGATATCGGCATATGCATATGCATGCATGCATGCATCGGCCG
 AT
 T--A
 A----T
 T-----A
 A-----T
 T----A
 A--T
 TA
 AT
 T--A
 T----A
 C-----G
 C-----G
 C----G
 A--T
 AT
 AT
 A--T
 A----T
 T-----A
 A-----T
 A----T
 A--T
 AT
 TA
 A--T
 A----T
 G-----C
 A-----T
 G----C
 A--T
 GC
 AT
 G--C
 A----T
 T-----A
 A-----T
 T----A
 A--T
 TA
 AT
 T--A
 A----T
 T-----A
 A-----T
 T----A
 A--T
 TA
 AT
 G--C
 A----T
 G-----C
 A-----T
 G----C
 A--T
 GC
 GC
 T--A
 A----T
 A-----T
 A-----T
 A----T
 A--T
 AT
 TA
 A--T
 A----T
 G-----C
 T-----A
 G----C
 A--T
 GC
 AT
 G--C
 C----G
 C-----G
 A-----T
 G----C
 A--T
 GC
 TA
 A--T
 A----T
 A-----T
 C-----G
 C----G
 A--T
 AT
 TA
 A--T
 A----T
 A-----T
 C-----G
 C----G
 A--T
 AT
 CG
 G--C
 A----T
 A-----T
 G-----C
 A----T
 A--T
 GC
 AT
 G--C
 A----T
 G-----C
 A-----T
 G----C
 A--T
 CG
 GC
 C--G
 +++++*=X>>+>>=<<<<+++++++<<<<[>>>=<+=<X>=>X>~>.<<<<-] 
===Quine===
 CG
 C--G
 C----G
 C-----G
 C-----G
 C----G
 CGCGCGCGCGCG
 XXX
== External resources ==
DNA# online interpreter
Category:Languages
Category:Cell-based
Category:Turing complete
Category:Brainfuck derivatives
Category:Implemented
Category:Low-level
Category:2009