[Question]
  [
Write the shortest code you can that produces an infinite output.
That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.
Here's a list of answers that I think are really clever, so they can get credit:
* [The comma is both code and data](https://codegolf.stackexchange.com/a/37210/8611)
* [Infinite errors (that counts)](https://codegolf.stackexchange.com/a/26418/8611)
* [Infinite warnings (that also counts)](https://codegolf.stackexchange.com/a/20902/8611)
* [What's Marbelous?](https://codegolf.stackexchange.com/a/37209/8611)
## Leaderboard
```
var QUESTION_ID=13152,OVERRIDE_USER=8611;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
## Befunge (1)
```
.
```
Outputs `0` forever. It works because in Befunge lines wrap around, and you get `0` if you pop from the empty stack.
[Answer]
# x86 .COM Executable, 7
in hex:
```
b8 21 0e cd 10 eb fc
```
---
The others need kilobytes or more of system libraries and runtime. Back to basics:
```
$ echo -ne '\xb8!\xe\xcd\x10\xeb\xfc' > A.COM
$ dosbox A.COM
```
![output](https://i.stack.imgur.com/72rHt.png)
You can change the 2nd byte (`0x21`, or `!`) to change the output.
Uses a BIOS interrupt for output; doesn't need DOS, but I didn't have QEMU set up.
---
## Explanation
The machine code corresponds with the following assembly:
```
        mov     ax, 0x0e21
again:  int     0x10
        jmp     again
```
The output is all in the `int` call -- per [this reference](http://www.computing.dcu.ie/%7Eray/teaching/CA296/notes/8086_bios_and_dos_interrupts.html#int10h_0Eh), int 0x10 with 0x0e in AH will print the byte in AL to the screen.
Knowing that register AX is a 16-bit word comprised of AH in the high byte and AL in the low byte, we can save an extra load (and thereby a byte in the machine code) by loading them together.
[Answer]
# Windows Batch file, 2 chars
```
%0
```
Calls itself infinitely.
[Answer]
# Befunge 98 - 2
```
,"
```
Outputs ",,,,,,,,,,," for eternity.
[Answer]
# sh, 3 bytes
```
yes
```
outputs `y` continuously
[Answer]
## GHCi + Data.Function, 8 bytes
Old thread, but a fun one is
```
fix show
```
in Haskell, it prints
```
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\‚Ä¶
```
forever since it's basically running
```
let x = show x in x
```
It knows that `x` is a string, so the first character is `"`, so this needs to be escaped with `\"`, but know that `\` needs to be escaped so `\\\x`, and so on and so on.
[Answer]
# Bash, 4 bytes
```
$0&$
```
Outputs `./forever2.sh: line 1: $: command not found` continuously.
Because `$0` is backgrounded, each parent dies after the invalid command `$`, and so stack/memory is not eaten up, and this should continue indefinitely.
Strangely the output gets slower and slower over time. `top` reports that system CPU usage is close to 100%, but there are memory- or CPU-hog processes. Presumably some resource allocation in the kernel gets less and less efficient.
[Answer]
**Windows Batch file, 9 characters**
```
:a
goto a
```
[Answer]
## Java, 54 characters
Best attempt in Java:
```
class A{static{for(int i=0;i<1;)System.out.print(1);}}
```
[Answer]
# Brainfuck, 4
```
+[.]
```
Alternatively,
```
-[.]
```
[Answer]
# LOLCODE (36)
```
HAI IZ 1<2? VISIBLE "0" KTHX KTHXBYE 
```
Thought I'd give LOLCODE a shot, has a surprisingly large amount of functionality.
[Answer]
### JavaScript: 14
> 
> ## WARNING: you really don't want to run this in your browser
> 
> 
> 
```
for(;;)alert()
```
[Answer]
##  Turing Machine - 6 Characters :
```
#s->1Rs
```
where `#` is blank symbol (on the tape by default), `s` describes the only existing (start) state, `1` is printing a digit, `R` means shifting to the right, `s` at the end is staying in the same state.
[Answer]
## C, 23 chars
Slightly shorter than the best C/C++ answer so far. Prints empty lines infinitely (but if compiled without optimizations, overflows the stack).
```
main(){main(puts(""));}
```
[Answer]
# x86 .COM Executable, 5 bytes
[![endless ASCII char set output](https://i.stack.imgur.com/w963S.png)](https://i.stack.imgur.com/w963S.png)
in hex:
```
40 CD 29 FF E6
```
in asm:
```
inc ax
int 0x29
jmp si
```
Explanation:
`inc ax` increments the register AX by one. `int 0x29` is the "fast put char" routine of MSDOS, which simply outputs the value in AL (the low part of AX) and advances the cursor by one. `jmp si` is just a weird way to jump back to the top, since the register SI is 0x100 on almost every DOS-like operating system, which is also where a .com program starts ;) It's also possible to do a short jump instead, which also uses 2 bytes.
Sources:
[MSDOS Start Values](http://www.fysnet.net/yourhelp.htm)
[Sizecoding WIKI](http://www.sizecoding.org)
[Answer]
## Haskell, 10
```
print[1..]
```
I think this is the shortest code to 
1. Print something out.
2. Create an infinite `Show`:able datastructure.
For those interested, it prints:
```
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,...
```
[Answer]
## Python 3: 15, 17, or 18 characters
[mdeitrick's answer](https://codegolf.stackexchange.com/questions/13152/shortest-code-to-produce-infinite-output/15188#15188) is longer in Python 3, which replaces the `print` statement with a function call (15 chars):
```
while 1:print()
```
This remains the shortest I've found in Python 3. However, there are some more-interesting ways of printing in an infinite loop that are only a few characters longer.
* `print()` returns `None`, which != 9, making it an infinite loop; the `8` is a no-op that substitutes for `pass` (18 chars):
```
while print()!=9:8
```
* `iter(print, 9)` defines an iterable that returns the output of `print()` until it equals `9` (which never happens). `any` consumes the input iterable looking for a true value, which never arrives since `print()` always returns `None`. (You could also use `set` to the same effect.)
```
any(iter(print,9))
```
* Or, we can consumer the iterable by testing whether it contains `8` (17 chars):
```
8in iter(print,9)
```
* Or, [unpack it using the splat operator](https://codegolf.stackexchange.com/questions/54/tips-for-golfing-in-python/4389#4389):
```
*_,=iter(print,9)
```
* The weirdest way I thought of is to use splat destructuring inside a function call, `function(*iterable)`. It seems that Python tries to consume the entire iterable before even attempting the function call‚Äîeven if the function call is bogus. This means that we don't even need a real function, because the type error will only be thrown after the iterable is exhausted (i.e. never):
```
8(*iter(print,9))
```
[Answer]
## VBA: 12
Audio is output, right?
```
do:beep:loop
```
Put that in your 'favorite' coworker's favorite macro-enabled MS office file for some 'fun'!
```
Private Sub Workbook_Open()
    Do:Beep:Loop
End Sub
```
Bonus points if they're using headphones.
[Answer]
# [Marbelous](https://github.com/marbelous-lang) 4
```
24MB
```
Marbelous does surprisingy well here. This will post an infinite amount of dollar signs `$`, though it will hit the stack limit rather quickly.
**How it works.**
24 is a language literal, which will fall off the board and be printed to STDOUT as its corresponding ascii character. MB is the name implicitly given to the main board, since the main board has no input, it will fire every tick. And since cells are evaluated from left to right, the literal will always be printed before the next recursive call.
So this is rougly equivalent to this pseudocode:
```
MB() {
    print('$');
    while(true) MB();
}
```
## A solution without infinite recursion 11
```
24@0
@0/\..
```
This one works by looping the literal between two portals `@0`, whenever the 24 hits the lower `@0` it is transported to the cell underneath the upper `@0`. It the lands on the `/\`, which is a clone operator, it puts one copy of the marble (literal) on it's left (back on the portal) and another one to its right. This coopy then falls off the board (since `..` is an empty cell) and gets printed to STDOUT.
In pseudocode, this would translate to:
```
MB() {
    while(true) print '$'
}
```
## A shorter solution without infinite recursion 9
```
24
\\/\..
```
This one constantly tosses the marble around between a cloner and a deflector, putting one copy on the rightmost cell, to be dropped off the board.
In pseudocode that would look something like:
```
MB() {
    List charlist = ['$'];
    while(true) {
        charlist.add(charlist[0];
        charlist.add(charlist[0];
        charlist.pop();
        print(charlist.pop());
        // Wait, what?
    }
}
```
**note**
The `..` cells are necessary on the two last boards since the marbles would land off the board (and be discarded) otherwise. For some extra fun, you replace the `24` marble by `FF` and the empty `..` cell by a `??`, which turns any marble into a marble between 0 and it's current value before dropping it down. Guess what that would look like on STDOUT.
[Answer]
# perl, 10 chars
Here's another 10 char perl solution with some different tradeoffs. Specifically, it doesn't require the -n flag or user input to start. However, it does keep eating memory ad infinitum.
```
warn;do$0
```
save to a file, execute that file and you get eg:
```
Warning: something's wrong at /tmp/foo.pl line 1.
Warning: something's wrong at /tmp/foo.pl line 1.
Warning: something's wrong at /tmp/foo.pl line 1.
```
[Answer]
# piet - 3 codels
![http://www.pietfiddle.net/img/auQXtFXATg.png?cs=15](https://i.stack.imgur.com/NJSmf.png)
Outputs an infinite number of 1's
[Answer]
# [Bitxtreme](http://esolangs.org/wiki/Bitxtreme), 0.25 bytes
Binary representation:
```
00
```
From the documentation:
> 
> The first bit of each pair is a pointer to the memory position which holds the value to subtract from the accumulator. The result is stored in that same memory position pointed to by the operand. If the result is negative (the bits are in two's complement representation) then the second bit of the pair will be added to the current PC, modulo 2.
> 
> 
> 
The program counter and accumulator are initialized to zero; then, the contents of memory location 0 are subtracted from the accumulator. This happens to be 0, leaving the accumulator at zero. Since there was no carry, the second bit is not added to the program counter.
The program counter is then incremented by 2 modulo 2, sending it back to the start, and causing an infinite loop. At each step, the special memory location 0 is modified, causing its contents (a `0`) to be written to output.
It can be argued that this program should be scored as 1 byte, because the official interpreter in Python requires zero-padding. However, I don't think the zero-padding is really *code*.
[Answer]
# ><> [(Fish)](http://esolangs.org/wiki/Fish), 2
A creative way to use the infinite codebox of fish:
```
"o
```
Because the instruction pointer returns back to the beginning of the line after reaching the end, this code can essentially be read as
```
"o"o
```
which means 'read the string "o" and then output it'.
[You can test the code here](http://fishlanguage.com/)
[Answer]
# [Z80Golf](https://github.com/lynn/z80golf), 0 bytes
[Try it online!](https://tio.run/##q7IwSM/PSfsPBAA "Z80Golf ‚Äì Try It Online")
Surprisingly, this is an empty *machine code* program that produces infinite output.
### How it works
Z80Golf machine initializes all the memory and registers to zero, and then loads the code to address 0. But there's nothing to load, so the whole memory becomes a no-op program.
When the PC hits the address `$8000` (`$` indicates hex in Z80 assembly), `putchar` is simulated. It consists of printing the register `a` to stdout and a `ret` instruction. Initially the stack pointer `sp` is zero, and `ret` does `pc <- [sp]; sp <- sp + 2`. The whole memory is zeroed, so the `ret` always returns to the start of the program regardless of `sp`.
The conclusion is that an empty Z80Golf program is a program that infinitely prints null bytes.
[Answer]
# Summary: Ruby - 9, Golfscript - 6, ><> - 2, Whitespace - 19, ~~Perl - 2~~
One language I know, and two I've never, ever, used before :D  
EDIT: Perl one didn't work when I installed Perl to try it :(
## Ruby, 9
```
loop{p 1}
```
Simply prints 1 on separate lines continually.
Also, a bunch of alternatives:
```
loop{p''} # prints [ "" ]  on separate lines continually
loop{p p} # prints [ nil ] on separate lines continually
```
10-char solution:
```
p 1while 1
```
I was actually surprised that I could remove the space between the first `1` and the `while`, but apparently it works
## Golfscript, 6
```
{1p}do
```
My first Golfscript program! :P
## ><> ([Fish](http://esolangs.org/wiki/Fish)), 2
```
1n
```
## [Whitespace](http://compsoc.dur.ac.uk/whitespace/index.php), 19
```
lssslssstltlsslslsl
```
Where `s` represents a space, `t` represents a tab, and `l` a linefeed.
[Answer]
**C, 25 24**
```
main(){main(puts("1"));}
```
[Answer]
## [dc](https://en.wikipedia.org/wiki/Dc_%28computer_program%29), 7
```
[pdx]dx
```
prints 'pdx\n' infinitely many times.
[Answer]
# Minecraft > 1.9 2 + 5 = 7 Bytes
Note that this version of this "language" was created after the question.
Surprisingly good for MineCraft. o-o
This is using [this definition of MineCraft scoring](http://meta.codegolf.stackexchange.com/a/7397/44713).
[![the system](https://i.stack.imgur.com/cQ4lI.png)](https://i.stack.imgur.com/cQ4lI.png)
The command `say 1` put inside of a permanently active repeating command block. It will permanently output `[@] 1` to the chat.
[Answer]
# [Seed](http://esolangs.org/wiki/Seed), 4 bytes
```
99 5
```
[Try it online!](https://tio.run/##K05NTfn/39JSwfT/fwA "Seed ‚Äì Try It Online") Outputs `11` infinitely
Generates the following Befunge-98 Program:
```
[glzgx"Lz^v*M7TW!4:wi/l-[, s44~s;|Sa3zb|u<B/-&<Y a@=nN>Nc%}"gq!kCW $1{2hyzABRj*glr#z(@Zx@xT=>1'.b
/
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//@PTs@pSq9Q8qmKK9PyNQ8JVzSxKs/Uz9GN1lEoNjGpK7auCU40rkqqKbVx0tdVs4lUSHSwzfOz80tWrVVKL1TMdg5XUDGsNsqorHJ0CsrSSs8pUq7ScIiqcKgIsbUzVNdL4tL//x8A "Befunge-98 (PyFunge) ‚Äì Try It Online")
---
The relevant part is just this:
```
[>1'.b
/
```
`b` pushes `11` to the stack and `.` prints it. `1` and `49` are also pushed to the stack, but never actually printed.
Animation of the code running:
[![enter image description here](https://i.stack.imgur.com/tsAk8.gif)](https://i.stack.imgur.com/tsAk8.gif)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes (UTF-8)
```
üç™
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLwn42qIiwiIiwiIl0=)
Outputs `cookie` forever.
]