Shortest code to produce infinite output

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:

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>

• All answers disqualified because at some point the Earth will be swallowed by the sun, and at some point the universe will die :P – Doorknob Nov 9 '13 at 20:00
• Does "infinite until your computer crashes" count? <_< – Izkata Nov 10 '13 at 1:39
• If I write mine in Piet, can I count the pixels of the text the other programs used? I believe the smallest possible repeating Piet program would be 6 pixels. That beats Befunge if "off" pixels still count. – DampeS8N Nov 12 '13 at 20:27
• @Izkata So any answer that crashes your computer is also allowed :D – ɐɔıʇǝɥʇuʎs Jul 11 '14 at 20:11
• @Doorknob So really, the challenge is to produce infinite output in a finite amount of time. Sounds easy enough. – Sanchises Apr 10 '15 at 21:15

Spice, 26 bytes

Spice module that recursively calls itself. Quite quickly hits a stack overflow.

Given the code is saved to a module named 'x':

;return@OUT a;LOD .\x a a;


Un-golfed explanation

;a;return@    - define variables: "a" and the required "return"
OUT a;   - output a, implicitly "[0]"
LOD .\x a a;  - call this module, passing a, storing result in a


VisiCalc, 3 bytes

You need an extra newline to enter the instruction.

/-/


The trailing newline is significant.

Explanation

/   Start a command:
-  Replicate forever
/ The target for replication is the / character
Extra newline to enter the instruction

You end up with a cell with an infinite number of /'s.
However, the current cell can only show a finite amount
of /'s because cells are trunctuated based on their lengths.
$$$$


Roj, 19 bytes

while(1)do out""end


This produces output because of the [out]: buffer.

T-SQL, 15 bytes

a:PRINT 0GOTO a


6 years and 10 pages of answers, and no SQL versions yet.

Notes:

• PRINT is 1 byte less than a SELECT.
• A label with a goto is 1 byte shorter than the shortest WHILE statement: WHILE 1=1PRINT 1 (you can't just do WHILE 1 in SQL)
• Depending on the version of SQL Management Studio, the "messages" pane (which displays the result of PRINT statements), might not immediately refresh; this is a client-side UI issue only.
• Seriously? 0goto? yuck. – Sapphire_Brick Jun 17 at 0:08
• @Sapphire_Brick You take the bytes where you can get them :) – BradC Jun 17 at 13:29

Go, 59 characters

package main
import "fmt"
func main(){for{fmt.Print(0)}}


International Phonetic Esoteric Language, 6 bytes

10ɑeoɒ


Will print 0 with newlines forever.

Explanation:

10ɑeoɒ
10     (push the bounds for the loop: from 0 to 1)
ɑ    (pop the bounds and start the loop)
e   (push the current index)
o  (print)
ɒ (check if index < start. 0 < 1, so loop)


Ruby, 11 9 characters

loop{p:p}


p 0 while 1


Malbolge, 1505 bytes

b'a;$9"~}HG{iyxwuu?O=pL:]mHj5!3DCezRQ=+^:('&Y$#m!1So.QOO=v('98$65a!}^{@hyf<WV9sr%4#I20FEJVBfw)btOr@#!7~|4{y1xv.us+rp(om%lj"ig}fd"cxuz]rwvYnslkTonPfOjiKgJeG]\EC_X]@[Z<R;VU7S6QP2N1LK-I,GF(D'BA#?>7~;:9y16w43s10)p-,l*#(i&%e#d!~{tyxZpuXsrTTongOkdMhgHd]ba_^W@[ZYXW9UNSRQPOHMLKJ-++FE''<A$?>=<;:387xw43s10/(-&m*)('&}${d!~}|^zyxwvutmVqpiRQlkjiKafedc\E_^@\[ZYX;V9NMRQ42NGLK.IH*F?DCBA$#>7~;{{8xx5uu2rr/oo,ll)ii&f|e"!aw{z\r[vXnmVTpongPkNihgJ_dcFaB^]\UZ=RWV8TSLQ4ON0LE.IHA)E>'BA:?!7~5|38y6/v321q).-&m*)i'&%|{d!~}_{zs\wvutsUqTonPlOjiKgJedFbE_A]@[Z<X;VU7S6QP22GL/JIB+FEDC%;@?>7~;:987w5v32r0)p-,+k)('~g$#"b~w|uz]xwvutsrqTinQlOjLhgfeH]bECB]\>ZSXWVUTSRQPON1LE.I,+*((&&$$""~~||zzxxv4u210/(-n+l)(i&g$ddy~}u^]\ZvutVlUjSQQOOMMKgfeG]F[DBB@@>><X;99NS6QP3NG0KJ-H+F(('<%@#"~~||z876v.u,sqqoommkki'&%e{dyb^^\\ZvuWslUjoRmlNNibgJeHcFDDY^A\[Z=XQV987553311/KJI+A*?(&BA@"8!6}{9zxx/43s1*q(ommkki'h%$ecc~}v_^][wZutWrUpohQlkNiLgIIHcbaZ_B]@[><<QVUT6L5JO2MLK.IHGF?(C&%:#!=<|:3z1xvvttr0/.n&m$ki'&f${dyb^zyxZpYnWUUSSQmPkjLLgfedc\aD_BA?[>YXW:UTSRQJO2ML/J-H**?DC&;$?"!}}{{y765u-t+rppnn%*kii~%f#"!xa|_zyxZpYnWUqpoQgPeNLLJJHHFFDDBB@\?ZY;;PU8S6QPO1G0EJ-HGF)>C&%@#>=~;|92y65v3t1qqp-&ml)j'&gee"!x}|{z]xwYutWlqTonmPkjchgfIHFF[_^@V?T=;;997SRQ3I2G0.JI+G@)>'%%##!!}}{987w/v-2sqq(onI*6FXDDU0S!Q>O{]sKwp$#s!Uj|nPle+vbK'_7$\n!Y|@{?=,XW:('6_^#3NlkKJIBxe?b'a;^#8[<Z|zVy0SetPb=o'm8Hk(E3CCe@Rb<*:sKJ%54"2DS/AQlOj)hKHdGbn2^Az.T<;WV87rRo#m[MLjJVyASdu&<$q"8J}}{z2xwwe3cOa/on,JH#iigCUe"yba+*)][wI$4Wr2CRRz?kN*ht9&^cF!mCB{izyx;vt8'65Q42[Z0.hI+xeRQ


Try it online!

This was built with Prof. Masahiko Sakai's LAL toolchain from the following source code.

PROGRAM_START_TO ENTRY@Argh

ROUTINE Argh {
REV_JMP:REV JMP

ENTRY:

OUTPUT
DUP

JMP REV_JMP
}


Online LAL assembler

q/KDB, 13 chars

while[1;0N!1]


Outputs

1


forever.

Another Solution:

{0N!1}/[0<;1]

• {1}{0N!1}/1 for 11 – tmartin Jan 30 '14 at 20:54

Quomplex, 6 4

[*1]


Infinitely outputs 1.

• Is there an interpreter or compiler for this language? – Sylwester Jan 29 '14 at 23:09
• The link in the title gives a 404 error. – Cyoce Jan 31 '16 at 19:59

Bash - 13 bytes

cat /dev/zero


to see run cat -v /dev/zero

Documentation here: /dev/zero and here Purpose of /dev/zero?

• Why not w&sh $0? – Sapphire_Brick Jun 17 at 17:07 Windows PowerShell (12) for(;;){'-'}  Scala REPL (19 characters) while(true)print(1)  • You could save one character by substituting true for 1>0. – Sapphire_Brick Jun 17 at 14:17 PureBasic - 17 chars r: Debug 0 Goto r  A slight variation on the classic BASIC infinite loop :-) JavaScript, 23 characters while(1)console.log(1);  • while(1)alert(1); – Timtech Feb 4 '14 at 16:41 • @Timtech for(;;)alert(1) is even shorter – user2428118 Nov 20 '14 at 22:14 • @user2428118 Yep, I've known that since then though. I must learn more all the time :) – Timtech Nov 21 '14 at 12:05 Processing, 26 for(int i=0;i<1;)print(1);  Prints 1 continuously. • You might also be able to do for(;;) for an infinite loop and then you can add the print(1); – user41805 Dec 2 '16 at 18:20 Groovy, 14 for(;;)print 1  from the command line: groovy -e "for(;;)print 1" JAVA - 72 chars: counting everything: class T{public static void main(String[]a){for(;;)System.out.print(0);}}  Obviously, Java was not built for code golfing. • Assuming you can import anything, import static java.lang.System.out and you can reduce your "actual code" by 7 characters. – Colton Nov 29 '13 at 19:20 • Also your "for some reason" comment is because print doesn't flush() – Colton Nov 29 '13 at 19:20 • @Sparkis Oh, thank you. Does that remove the characters from the output stream onto the screen? – user10766 Nov 29 '13 at 21:44 • For java, I count everything, including imports, class declaration, and method declaration. – tbodt Dec 13 '13 at 0:09 • @user2509848 When the buffer gets full it will start to print eventually. It didn't take many seconds for me. – Sylwester Jan 29 '14 at 22:28 Java, 74 characters Since Java 7 and later versions seeks for main function at first instead of static block; I think this would be the best option to print infinite loops with small code. For your reference: static block won't execute in Java 7. class I{public static void main(String[]a){for(;;)System.out.println(1);}}  • For Java 7 and later, this is indeed what you'd need to do. Therefore, I recommend that you add #Java 7+, characterCountOfYourProgram to the beginning of your post, then golf the rest some more. Also, instead of using s around your code, just add four spaces before the line. Here are some golfing tricks: change the class's name to 1 char, perhaps I. Change the String args[] to String[]a. Change the System.out.println to System.out.print. – Justin Jun 21 '14 at 19:21 • Couldn't you also remove public, since methods are public by default? – mbomb007 Mar 5 '15 at 1:56 • @mbomb007 public is needed to make the code executable. – user8397947 May 28 '16 at 15:50 C++ 29 main(){while(1)std::cout<<1;}  • The shortest way to do an infinite loop in C/C++ is for(;;). If the condition is missing in a for loop, it becomes infinite. – tbodt Jul 3 '14 at 23:27 SCALA 18 while(1>0)print(1)  AppleScript: repeat until 1 < 0 say "hi" end repeat  • Because the question is a code-golf, could you please include the character count of your code? – ProgramFOX Jul 11 '14 at 18:29 • I'm sorry, I'm new to this :) does that include , returns , spaces and tabs ? – mcgrailm Jul 11 '14 at 18:39 • Yes, it does. If you have written this on Windows, then a word count application might count a newline as 2 characters (\r and \n), but here, newlines count just as one character. – ProgramFOX Jul 20 '14 at 8:29 • You can shorten this a lot - instead of using end repeat, you can use end. You can shorten say "hi" to say"hi", or, using a different method of output entirely towards the Messages tab, you can use log"". You do not need the tab before this. You can remove the until 1 < 0 statement, as repeat is infinite by default. After all these suggestions, you shave off 26 bytes of code. – Addison Crump Oct 29 '15 at 11:14 Groovy - 15 chars for(;;)print 1  Clojure - 18 15 chars (while 1(pr 1))  CoffeeScript, 14 Pretty unoriginal and similar to JavaScript: alert 6while 1  • There is a loop keyword, this could be shortened down to loop alert 1 – eosterberg Apr 11 '15 at 16:03 PHP: 22 chars <?PHP while(true){print(0);} ?>  My first golf, hope I did it right :) It will hang your browser if you do it on a PHP page, but from the command line it does the expected: prints something until you get bored and stop it. • Because you this is php, you can just put while(true){print(0);} the <?php ... ?> isn't actually php anyway – addison Sep 1 '14 at 23:43 • And the php portion of your answer, while(true){print(0);}, is actually 22 characters. – addison Sep 1 '14 at 23:45 Chinese, 2 bytes 谕  Prints ÿ continuously. • Isn't that two bytes? – John Dvorak Jan 29 '14 at 15:54 • @JanDvorak He didn't specify chars or bytes, and chars is default. – Timtech Jan 29 '14 at 16:08 • @Timtech According to the code-golf tag: If you use Unicode, byte count should use UTF-8. – Sylwester Jan 29 '14 at 22:14 • @Sylwester Okay – Timtech Jan 29 '14 at 23:07 I haven't seen Thue used here much, so here we go: Thue (22 19 bytes) a::=ab b::=~1 ::= a  Cardinal, 3 characters .%$


Explanation:

.    print active value
%   start pointers here
$jump to x,y = active, inactive value .%$

Pointers spread out in all cardinal directions from every %
All pointers carry two values, initialized to 0. The upper value is
called the active value, and it can be accessed directly. The lower
value is called inactive value. Inactive values can only be accessed
by flipping both values, switching the active to inactive, and the
inactive to active, or by using instructions like $that grab the inactive value directly to e.g. execute a jump. The < and > below the values are the positional and directional markers of the pointers. In programs, they instruct pointers to change the movement direction. 0 0 At this step, the first active value (from the left pointer) 0 0 gets printed in the console, the right pointer is going to <%> jump to x,y=0,0 0 The jumped (former left) pointer prints out the next 0 0 >%$

0
0     ... travels on ...
.>$0 0 .%> ... reaches the jump instruction again, going to jump to 0,0 again 0 0 >%$    ... print out the next 0... and so on, to infinity.


http://esolangs.org/wiki/Cardinal

Bat, 2 chars

%0


The output is (starting from a blank line, I've added nbsp to make it visible bellow)


d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"

d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"

d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"

d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"

d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"

d:\Temp\Supertemp>"D:\Temp\Supertemp\inf.bat"
`
• This is dependent to where you have stored the file, but it will always output. This is an example output. – Erik the Outgolfer Oct 6 '16 at 19:02
• @EriktheGolfer, yes. – Qwertiy Oct 6 '16 at 21:34