Generate a quine in Cow:

Cow:

COW
The COW programming language is an esoteric programming language created by Sean Heber in 2003. It is a Brainfuck variant designed humorously with Bovinae in mind. COW has twelve instructions (four more than Brainfuck) and is Turing-complete. Most instructions are moos, only the capitalization varies: mOo, moO, mOO, Moo, and so on. MMM, OOO, oom and OOM are the exceptions. All other character combinations are ignored and treated as comments.


Contents
1	Commands
2	Sample code
2.1	Hello, World!
2.2	Fibonacci sequence
3	See also
4	External resources
Commands
Instruction	Description
moo	This command is connected to the MOO command. When encountered during normal execution, it searches the program code in reverse looking for a matching MOO command and begins executing again starting from the found MOO command. When searching, it skips the instruction that is immediately before it (see MOO).
mOo	Moves current memory position back one block.
moO	Moves current memory position forward one block.
mOO	Execute value in current memory block as if it were an instruction. The command executed is based on the instruction code value (for example, if the current memory block contains a 2, then the moO command is executed). An invalid command exits the running program. Value 3 is invalid as it would cause an infinite loop.
Moo	If current memory block has a 0 in it, read a single ASCII character from STDIN and store it in the current memory block. If the current memory block is not 0, then print the ASCII character that corresponds to the value in the current memory block to STDOUT.
MOo	Decrement current memory block value by 1.
MoO	Increment current memory block value by 1.
MOO	If current memory block value is 0, skip next command and resume execution after the next matching moo command. If current memory block value is not 0, then continue with next command. Note that the fact that it skips the command immediately following it has interesting ramifications for where the matching moo command really is. For example, the following will match the second and not the first moo: OOO MOO moo moo
OOO	Set current memory block value to 0.
MMM	If no current value in register, copy current memory block value. If there is a value in the register, then paste that value into the current memory block and clear the register.
OOM	Print value of current memory block to STDOUT as an integer.
oom	Read an integer from STDIN and put it into the current memory block.
Sample code
Hello, World!
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO
 MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo
 MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo
 MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo
 OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo 
This also prints "Hello, World!" but uses loops and the register to lead to a much shorter program:

 MoO MoO MoO MoO MoO MoO MoO MoO MOO moO MoO MoO MoO MoO MoO moO MoO MoO MoO MoO moO MoO MoO MoO MoO moO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO moO MoO MoO MoO MoO mOo mOo mOo mOo mOo MOo moo moO moO moO moO Moo moO MOO mOo MoO moO MOo moo mOo MOo MOo MOo Moo MoO MoO 
 MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo MMM mOo mOo mOo MoO MoO MoO MoO Moo moO Moo MOO moO moO MOo mOo mOo MOo moo moO moO MoO 
 MoO MoO MoO MoO MoO MoO MoO Moo MMM MMM Moo MoO MoO MoO Moo MMM MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo mOo MoO Moo 
Fibonacci sequence
 MoO moO MoO mOo MOO OOM MMM moO moO
 MMM mOo mOo moO MMM mOo MMM moO moO
 MOO MOo mOo MoO moO moo mOo mOo moo
See also
Similar languages:

Whirl
External resources
COW - Programming For Bovines (from the Wayback Machine; retrieved on 3 April 2013)

COW github.io

COW on Github contains interpreters/compilers in C++ and K.

COW online interpreter in Javascript

C# COW byte-code compiler and interpreter on github


Programming for Bovines:
Other Languages: COW | Whirl | 3code | Taxi
COW

Important news!
Fun logo thanks to <PRESIDIO_ANONYMIZED_PERSON>!
Alex van Oostenrijk and Martijn van Beek have written a paper which analyzes the semantics of COW. The study is available in both Dutch and English. They show a proof that COW is Turing-complete. Check it out today!
Note: If you like COW, you may also enjoy my other languages, check out the links at the top of this page!

The COW programming language was designed with the bovine in mind. Given that cows have somewhat limited vocabulary skills, it seemed natural to incorporate only the words they know into the language. As a result, all instructions are some variation on "moo" which just so happens to be the only word they really understand.

Any other word or symbol that isn't an instruction is ignored entirely. So, spaces can be used or not. Newlines can be used or not. You get the idea. It makes commenting COW programs rather easy as long as you don't use any words that have an instruction embedded in it. All instructions are case-sensitive.

The commands are as follows:

Code	Instruction	Description
0	moo	This command is connected to the MOO command. When encountered during normal execution, it searches the program code in reverse looking for a matching MOO command and begins executing again starting from the found MOO command. When searching, it skips the instruction that is immediately before it (see MOO).
1	mOo	Moves current memory position back one block.
2	moO	Moves current memory position forward one block.
3	mOO	Execute value in current memory block as if it were an instruction. The command executed is based on the instruction code value (for example, if the current memory block contains a 2, then the moO command is executed). An invalid command exits the running program. Value 3 is invalid as it would cause an infinite loop.
4	Moo	If current memory block has a 0 in it, read a single ASCII character from STDIN and store it in the current memory block. If the current memory block is not 0, then print the ASCII character that corresponds to the value in the current memory block to STDOUT.
5	MOo	Decrement current memory block value by 1.
6	MoO	Increment current memory block value by 1.
7	MOO	If current memory block value is 0, skip next command and resume execution after the next matching moo command. If current memory block value is not 0, then continue with next command. Note that the fact that it skips the command immediately following it has interesting ramifications for where the matching moo command really is. For example, the following will match the second and not the first moo: OOO MOO moo moo
8	OOO	Set current memory block value to 0.
9	MMM	If no current value in register, copy current memory block value. If there is a value in the register, then paste that value into the current memory block and clear the register.
10	OOM	Print value of current memory block to STDOUT as an integer.
11	oom	Read an integer from STDIN and put it into the current memory block.


Sample Code

quick exit
OOO
MOo
mOO


simple loop using current memory block as a counter
MOO
MOo
[[ anything in here happens "current" number of times ]]
moo


copy current value to next memory block
MMM
moO
MMM


loop "current" number of times without affecting current's value
MMM
moO
MMM
MOO
MOo
[[ move back so original current is current again ]]
mOo
[[ loop here ]]
[[ move forward so the loop continutes to work on the temp counter ]]
moO
moo


test if current is 3 without affecting current's value
[[ copy current to temp block ]]
MMM
moO
MMM
[[ copy 3 into another new temp block ]]
moO
OOO
MoO
MoO
MoO
[[ loop 3 times (the 3 is still current) ]]
[[  this also decrements the temp value ]]
MOO
MOo
mOo
MOo
moO
moo
[[ move back to first temp value (the copy of the current value) and check if 0 ]]
mOo
MOO
[[ make original current current again ]]
mOo
OOM
[[ gets here if != 3 ]]
[[ skip down to the bottom past the if ]]
moO
OOO
MOO
moo
[[ make original current current again ]]
mOo
OOM
[[ gets here if == 3 ]]
[[ skip down to the bottom of the if ]]
moO
OOO
MOO
moo
moo
[[ set current back ]]
mOo
[[ all execution resumes here ]]


generate fibonacci sequence
MoO
moO
MoO
mOo
[[ main loop ]]
MOO
[[ print first number ]]
OOM
[[ temp copy of first number ]]
MMM
moO
moO
MMM
mOo
mOo
[[ store second number off in the first position now ]]
moO
MMM
mOo
MMM
[[ move back to temp number ]]
moO
moO
[[ use temp to add to first and store in second in loop ]]
MOO
MOo
mOo
MoO
moO
moo
mOo
mOo
moo


SOURCE

Now that you're all pumped up to get your neighborhood cows in on the action, you can download and compile the C++ interpreter source or my new compiler that generates a C++ version of the COW source. Enjoy!

Forget how many bottles of beer you had on the wall? Slarty has contributed a program to help. Enjoy.

Here is a COW interpreter written in the K Programming Language by jjayson. Cool!

NOTICE: Bovine Programming Reseach has contributed a revolutionary new extension to COW they are calling Distributed Digestion eXtentions (DDX). This enhancement allows bovines everywhere to better utilize the hardware they were born with. Read more about DDX here. Grab the code and increase your productivity today! BPR also provided two sample DDX applications to get you started: Fibonacci numbers with DDX and Powers of 7. Thanks BPR!

<PRESIDIO_ANONYMIZED_PERSON> implemented COW in Javascript. Check it out if that's your language of choice. (I'm a fan, myself.)

History

Although I don't quite remember for sure, I believe COW was released sometime in early 2003.