Shortest code to produce infinite output

122

19

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:

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>

tbodt

Posted 2013-11-09T01:51:48.960

Reputation: 2 176

7@Doorknob So really, the challenge is to produce infinite output in a finite amount of time. Sounds easy enough. – Sanchises – 2015-04-10T21:15:31.030

3Perhaps "theoretically infinite" is a better term. – Conor O'Brien – 2015-10-13T02:46:58.553

1I exploited a compile-time behavior specific to GCC to create a temporary file of infinite size. Can it be competing? – user8397947 – 2016-05-29T00:32:55.830

@dorukayhan I would say so. – tbodt – 2016-05-29T00:37:30.367

expression or whole program? – MtnViewMark – 2013-11-09T15:48:55.530

120All answers disqualified because at some point the Earth will be swallowed by the sun, and at some point the universe will die :P – Doorknob – 2013-11-09T20:00:11.597

17Does "infinite until your computer crashes" count? <_< – Izkata – 2013-11-10T01:39:15.130

2@lzkata yes, it does. – tbodt – 2013-11-10T17:08:50.073

5

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 – 2013-11-12T20:27:26.890

3@DampeS8N In Piet, pixels count as characters. Sorry. – tbodt – 2013-11-13T01:29:02.660

@AJMansfield If your Piet interpreter reads compressed images, then by all means your byte count can be shorter. I think standard Piet interpreters have to read the data as a matrix though, so really the number of bytes is the shortest (by bytes) representation that the interpreter/compiler understands. – HyperNeutrino – 2017-10-12T14:16:27.947

2@Doorknob The consciousness of AC encompassed all of what had once been a Universe and brooded over what was now Chaos. Step by step, it must be done. And AC said, "LET THERE BE LIGHT!" – KSmarts – 2017-10-13T13:48:41.500

I think the question should make it clear whether recursive solutions are allowed or not. Because they will crash at some point. I see some recursive solutions here. – microbian – 2014-01-27T16:31:24.517

1

@microbian That would disciminate languages that does not have any other looping construct. Some implementations of a language can have TCO and I'd say it would be ok if that implementation is mentioned in the answer rather than disqualifying it.

– Sylwester – 2014-01-30T14:14:34.337

@tbodt but with a compression scheme optimized for very tiny images, it could end up taking less data than the text. – AJMansfield – 2014-01-31T19:37:22.280

9@Izkata So any answer that crashes your computer is also allowed :D – ɐɔıʇǝɥʇuʎs – 2014-07-11T20:11:35.247

Answers

213

Befunge (1)

.

Outputs 0 forever. It works because in Befunge lines wrap around, and you get 0 if you pop from the empty stack.

marinus

Posted 2013-11-09T01:51:48.960

Reputation: 30 224

Aw, you beat me to it – BlackCap – 2016-02-01T19:14:52.960

1Hole in one! :) – gcampbell – 2016-05-27T16:17:12.947

6I think we have a winner. – primo – 2013-11-09T03:34:51.107

96I swear I had a Java class around here somewhere that was shorter. +1 – l0b0 – 2013-11-09T09:22:40.373

57This one dot has now gotten me more reputation than my next two answers combined. – marinus – 2013-11-11T14:32:21.693

2I just submitted a solution that uses 100% less characters than this solution AND prints an infinite amount of Dollars. That has to count for something? :) – Benjamin Podszun – 2014-01-30T23:33:24.150

1@BenjaminPodszun: if you code in Piet you have to count pixels instead of characters, sorry – marinus – 2014-01-31T01:11:34.687

3Aw... That's not fair :) Let's do it like this: I reduce the size of that image by a couple pixels and we display it very small.. So that it looks like a dot? And call it even? :) – Benjamin Podszun – 2014-01-31T07:47:55.827

4Why is this not the accepted answer? – Claudiu – 2014-09-03T22:30:07.947

101

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

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, 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.

AlliedEnvy

Posted 2013-11-09T01:51:48.960

Reputation: 1 384

LOL! You talk of how other answers use kilobytes of libraries to support them, then you run your answer in DosBox. (Also, +1.) :-D – Hand-E-Food – 2015-11-12T22:38:35.687

2Wow. That's really good – tbodt – 2014-01-16T01:43:21.947

46low machine code length should be worth more points than high level languages. – pwned – 2014-01-23T11:33:13.707

12This is the shortest code in real sense. – microbian – 2014-01-29T04:51:41.720

Is it allowed to not give value to AL? – l4m2 – 2018-03-29T03:09:16.600

I've got it in 6 bytes in PDP-11 machine code, and requires no BIOS (writes directly to the UART tx register). – greggo – 2014-02-02T01:02:46.093

6 bytes on an Apple ][ with 6502 as well. – LAK – 2014-02-03T23:00:47.363

Change 21 to 41 and it outputs AAAAAAAAAAAAAAAA. – Joe Z. – 2014-04-24T16:08:00.877

4Not only does it work, it works faster than all the other entries. :) – Thane Brimhall – 2014-04-29T19:46:46.227

14@ThaneBrimhall Which is of course the most important criteria by far for an infinite loop... If my computer hangs up, I want it to do it in the most efficient way! – kratenko – 2014-04-30T10:17:02.550

1Not sure to -1 because now my computer won't stop silently screaming at me. Thanks. ;) – Jwosty – 2014-06-22T04:12:59.183

91

Windows Batch file, 2 chars

%0

Calls itself infinitely.

teh_senaus

Posted 2013-11-09T01:51:48.960

Reputation: 1 039

This is awesome! – Patrick Purcell – 2015-12-13T01:16:14.933

How it works: %0 doesn't have an @, so it would constantly output something like ...> %0. This might just eat the whole RAM up sometime though, since it is recursive. – Erik the Outgolfer – 2016-10-06T10:37:15.303

2@EriktheOutgolfer might? How will this not crash at some point due to infinite recursion? I don't see how this could go on for multiple hours – phil294 – 2017-06-03T04:04:32.570

Actually it will be able to continue indefinitely. Naming a batch file to run without using call replaces the prior batch execution with the new one. So this is a tail-call, not recursion. – Miral – 2018-02-22T07:03:02.393

12Close second place, man. Well done. I've only ever seen one answer where Batch has won it. – unclemeat – 2014-02-13T02:21:31.177

It's really great!!! – Qwertiy – 2014-11-20T19:57:56.423

68

Befunge 98 - 2

,"

Outputs ",,,,,,,,,,," for eternity.

AndoDaan

Posted 2013-11-09T01:51:48.960

Reputation: 2 232

@AndoDaan: ", creates a string of a comma and INT_MAX-2 spaces, and then prints the last space. So the stack will fill itself with a comma INT_MAX-3 spaces, not really efficient. – YoYoYonnY – 2015-07-15T09:29:28.653

@YoYoYonnY Thanks for taking the time to explain what was happening! – AndoDaan – 2015-07-16T10:27:17.820

@AndoDaan: Befunge-98 treats any string of consecutive spaces as one (contrary to what YoYoYonnY said), and treats the area "off the map" as spaces. So ", pushes a comma and a space, then prints the space, repeatedly. In Befunge-93, all the spaces actually are pushed, but then the playfield's only 80 characters wide so it's less inefficient – None – 2016-11-26T21:51:45.493

@JamesHolderness: Although it's implementation-dependent, I believe it will always either leave a comma or a space on top of the stack. (The interpretation where it prints commas is based on assuming that the lines wrap around as soon as you reach the end of the line, which doesn't seem to contradict the spec but which isn't orthogonal with the rest of the langugae.) – None – 2017-01-24T18:21:50.250

2Actually somewhat clever. – tbodt – 2014-09-02T20:16:22.003

Thank you. It's strange, the ", version outputs spaces (or ". outputs 32 32 32) using the most common b98 implementation. No idea where it gets it from. – AndoDaan – 2014-09-02T20:20:53.723

1It's too bad it's buried under 82,395 really crappy answers. – tbodt – 2014-09-03T02:57:27.580

7@tbodt Well, according to the spec, my little program has all of eternity to inch its way up. So... fingers crossed... – AndoDaan – 2014-09-03T03:21:50.177

62

sh, 3 bytes

yes

outputs y continuously

klingt.net

Posted 2013-11-09T01:51:48.960

Reputation: 876

2As technosaurus says, in busybox it is a builtin, but in sh it isn't so you must say sh+coreutils instead. – Erik the Outgolfer – 2016-04-12T12:53:48.257

10Though yes is an external binary, and not part of bash (strictly speaking). – Bob – 2013-11-09T12:35:21.400

@Bob: That is true, but this requirement wasn't specified in the question. – klingt.net – 2013-11-09T18:03:21.523

56In bash, (almost) everything is an external binary. – Johannes Kuhn – 2013-11-10T22:42:28.647

That would also mean that if I suppose I have an alias y=yes, then y in one char would work. After all, the above example also implies that "yes" is properly in the $PATH. – Pierre Arlaud – 2013-11-28T08:44:53.347

5

Normally you don't have an alias y=yes and if your system isn't esoteric you can assume that yes is in your $PATH (see GNU Core Utilities). With your logic it is possible to assume weird constellations for every solution.

– klingt.net – 2013-11-28T09:21:25.743

5Right, but this is not only a bash capability: I'ts a POSIX shell basic part of core utils. (Ie: please change title for sh: 3 chars ;-) – F. Hauri – 2014-01-29T06:34:02.233

It should be completely legitimate to use things like coreutils, wget... – None – 2014-03-21T21:01:03.610

in busybox shells yes is a fully builtin "no forking" function that operates like a builtin ... see http://git.busybox.net/busybox/tree/include/applets.src.h

– technosaurus – 2014-06-21T23:35:05.727

42

Haskell: 8 Characters

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.

Daniel Gratzer

Posted 2013-11-09T01:51:48.960

Reputation: 953

7Because this requires import Data.Function, and because it returns the string rather than printing it, I question the fairness of the character count. Also, the string is actually ""\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\…". – Anders Kaseorg – 2016-02-20T10:18:07.450

... wow. Now I'm wondering if fix$show would have been more aesthetic :-) – John Dvorak – 2014-03-04T05:26:14.897

36

Windows Batch file, 8 characters

:a
goto a

Patrick Purcell

Posted 2013-11-09T01:51:48.960

Reputation: 639

1@WChargin I just checked using a hex editor. 3a 61 0a 67 6f 74 6f 20 works on my windows 8... :P – YoYoYonnY – 2015-07-01T22:44:00.977

@YoYoYonnY are you missing a 61 at the end there? – wchargin – 2015-07-02T06:27:35.187

Probably, my hex editor isnt the greatest – YoYoYonnY – 2015-07-02T07:40:21.623

It's 10 bytes, literally. Also, if someone has turned off echo before executing this it will output nothing. – Erik the Outgolfer – 2016-04-12T12:55:51.913

1This does not produce infinite output, does it...? – Doorknob – 2013-11-09T02:28:24.047

38it does...without @echo off, it prints "goto a" until you close it – Patrick Purcell – 2013-11-09T02:30:55.497

Does %0 eventually halt? – l4m2 – 2018-03-29T03:02:58.280

11we need mor BAT around here – Einacio – 2014-01-29T20:44:50.620

35I count ten characters: :a\r\ngoto a because Windows uses CRLF – wchargin – 2014-02-03T23:31:11.027

32

Brainfuck, 4

+[.]

Alternatively,

-[.]

cardboard_box

Posted 2013-11-09T01:51:48.960

Reputation: 5 150

8Neither \x01 nor \xFF are printable characters. I guess that wasn't a requirement, though :-/ – John Dvorak – 2013-11-09T05:37:37.390

A way to make it output printable characters would be to replace the + with , It does mean it requires an input though – Prismo – 2018-10-03T23:01:49.520

31

Java, 54 characters

Best attempt in Java:

class A{static{for(int i=0;i<1;)System.out.print(1);}}

Rich Smith

Posted 2013-11-09T01:51:48.960

Reputation: 411

7Functional, complies with the rules, golfed. Wondering why it was downvoted. – manatwork – 2013-11-11T15:03:20.950

14Does java forbid the classic for(;;) pattern? What about while(true)? – CodesInChaos – 2013-11-21T13:38:44.283

17@CodesInChaos, Java doesn't normally disallow those patterns and normally I would consider them cleaner and more idiomatic. Here though we are trying to sneak an infinite loop past the compiler (those forms cause the compiler to complain about the static {} block not exiting). – Rich Smith – 2013-11-21T17:56:12.540

In Java 8 you can do for(;;) – Oliver Ni – 2017-08-06T12:00:41.997

1@OliverNi But you can't use the static block. – Okx – 2017-09-01T15:17:42.870

class A{static{while(0<1)System.out.print(1);}} – Phillip Scott Givens – 2014-01-14T22:35:31.593

@psgivens: javac 1.7.0_51 rejects that as non-terminating. – Mechanical snail – 2014-02-03T03:38:41.367

2@Mechanicalsnail Yes, static blocks can't execute alone since java 7. – Fabinout – 2014-02-04T14:51:33.897

+1 for the idea; stupidly therea re no more ways to shave off bytes :( – masterX244 – 2014-03-06T13:06:37.457

30

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.

Digital Trauma

Posted 2013-11-09T01:51:48.960

Reputation: 64 644

1freeing resources is competing with forking processes/ To stop it you cannot kill the process as the PID changes only way to stop it is to rename the script so $0 fails. – Emmanuel – 2016-11-25T14:44:14.347

2maybe a behavior of stdout or similar... – masterX244 – 2014-06-24T19:08:58.477

29

LOLCODE (36)

HAI IZ 1<2? VISIBLE "0" KTHX KTHXBYE 

Thought I'd give LOLCODE a shot, has a surprisingly large amount of functionality.

Giraffestock

Posted 2013-11-09T01:51:48.960

Reputation: 421

2Don't need to ask about stdio. – cat – 2016-07-18T04:13:23.940

In the repl.it version of LOLCODE, you don't need HAI and KTHXBYE – MilkyWay90 – 2019-05-13T02:58:46.997

24

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.

Serge

Posted 2013-11-09T01:51:48.960

Reputation: 241

3I count 7 chars!? – F. Hauri – 2013-11-10T23:24:31.427

9

In maybe the most-common 5-tuple notation, this would be written simply as the 5 characters s#1Rs (current-state, current-symbol, symbol-to-write, direction-to-shift, next-state).

– r.e.s. – 2013-11-21T04:17:58.807

24

JavaScript: 14

WARNING: you really don't want to run this in your browser

for(;;)alert()

zzzzBov

Posted 2013-11-09T01:51:48.960

Reputation: 2 915

31Just check "Prevent this site from opening more dialogs". – Johannes Kuhn – 2013-11-11T08:42:15.620

1@JohannesKuhn don't check this and you need a reboot – Ilya Gazman – 2013-11-11T11:48:33.860

8Or just do nothing and it don't display any further output. – Johannes Kuhn – 2013-11-11T12:02:39.183

just running alert() gives me this error Error: Not enough arguments [nsIDOMWindow.alert] – Clyde Lobo – 2014-03-10T09:21:30.867

3Is it really infinite output, when the process is blocked and execution halted until humanoid interaction? – Morten Bergfall – 2014-05-27T15:25:39.477

Doesn't crash my browser.. but I like the thinking! – Seth – 2014-06-23T20:24:36.863

19

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,...

shiona

Posted 2013-11-09T01:51:48.960

Reputation: 2 889

4Is there any reason you chose the magic number 32 to stop at? – ike – 2013-11-10T16:21:37.513

12It seemed nice and round, at it also filled the code-block space as well as possible without the need for a next line. – shiona – 2013-11-12T01:22:01.820

2If the machine has a finite amount of memory, it might terminate when the integer grows too huge to hold in memory? – Jeppe Stig Nielsen – 2013-11-29T08:40:18.747

3@JeppeStigNielsen Yes. However an integer that would fill even one megabyte of memory would be 2^(2^20), or around 6.7 * 10^315652. Up that to a gigabyte of memory and the number would become 2^(2^30), a monster with almost half a billion digits. I'm quite sure that if we tried printing the series the heat death of the universe would hit us before the memory ran out. And HDD failure way before that. – shiona – 2013-11-29T10:05:38.830

5In the comments below the OP it is mentioned that 'infinite untill your computer crashes' counts as well. – 11684 – 2013-11-29T18:22:32.883

@shiona strictly speaking, you don't need an HDD to execute this program, only to load it in memory. In any case, typing the array to [Int] would solve the issue of the number overflowing the memory in only 7 or 9 bytes extra. – John Dvorak – 2014-03-04T05:09:50.930

Unfortunately [1..] :: Int is actually finite-length, I believe -- it doesn't overflow, just ends the list. – Ben Millwood – 2014-05-03T00:10:45.337

actually, (on my computer) GHC defaults [1..] to [Integer], so in fact, [1..] will be infinite, and eat up all your memory. – proud haskeller – 2014-07-11T17:00:44.637

19

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(""));}

ugoren

Posted 2013-11-09T01:51:48.960

Reputation: 16 527

why not f(){f(puts("");}? A function is sufficient. – GPS – 2018-04-02T05:31:49.423

122 chars: putc(0) (or 1, or 2, ..., or 9). Would that work? – CompuChip – 2014-03-10T22:59:28.993

@CompuChip, putc requires 2 parameters. – ugoren – 2014-03-11T07:26:01.603

10

@tdbot, Just notice that this is the accepted answer. I appreciate the compliment, but can't understand why. There's an obviously shorter answer

– ugoren – 2014-03-11T07:28:10.993

@tbodt, not tdbot. ftfy – nyuszika7h – 2014-07-05T12:35:52.450

5@nyuszika7h, This way I could show how modest I am, while holding on to the 15 rep. – ugoren – 2014-07-06T11:20:39.773

19

Marbelous 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.

overactor

Posted 2013-11-09T01:51:48.960

Reputation: 3 500

make your "//" "\/" to avoid producing an extra marble off the left edge? purely aesthetic improvement. – Sparr – 2015-03-05T17:07:56.157

@Sparr, point taken, I've edited the post. – overactor – 2015-03-05T21:30:15.087

5Shouldn't this solution be 25165824 bytes (24MB)? ;P – HyperNeutrino – 2017-10-12T14:19:16.590

15

x86 .COM Executable, 5 bytes

endless ASCII char set output

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

Sizecoding WIKI

HellMood

Posted 2013-11-09T01:51:48.960

Reputation: 276

14

Python 3: 15, 17, or 18 characters

mdeitrick's answer 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:

    *_,=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))
    

Mechanical snail

Posted 2013-11-09T01:51:48.960

Reputation: 2 213

*iter(print,1), works and has only 15 chars, but does consume quite a bit of memory. – ivzem – 2018-09-25T19:54:26.570

14

piet - 3 codels

http://www.pietfiddle.net/img/auQXtFXATg.png?cs=15

Outputs an infinite number of 1's

captncraig

Posted 2013-11-09T01:51:48.960

Reputation: 4 373

13

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.

lirtosiast

Posted 2013-11-09T01:51:48.960

Reputation: 20 331

12

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), 2

1n

Whitespace, 19

lssslssstltlsslslsl

Where s represents a space, t represents a tab, and l a linefeed.

Doorknob

Posted 2013-11-09T01:51:48.960

Reputation: 68 138

11Every time someone types the words, "I don't have Perl," God kills a kitten. – primo – 2013-11-09T03:37:24.710

2@primo :P Well at least now I do. – Doorknob – 2013-11-09T04:48:26.523

1To make the Whitespace program work, you need to move the lsssl ("label 0") to the beginning, because the output instruction tlss pops the top-of-stack. (To be technically correct, the program may also need lll at the end.) – r.e.s. – 2013-11-10T06:02:54.057

@r.e.s. Ah, thanks, I don't have an interpreter, but since it's an infinite loop, I don't need a lll at the end, right? – Doorknob – 2013-11-10T13:50:32.910

My bad -- I think you're right. Ending execution requires an lll, but that's irrelevant if execution is not supposed to end. – r.e.s. – 2013-11-10T14:45:12.990

2This is code golf. Please create one answer per submission. – J B – 2014-01-15T08:35:27.703

21@primo Good, I hate cats. And I don't have Perl. – SQB – 2014-01-15T09:12:59.957

5The GS program {1p}do only prints 1 and quits, because the do is an exec-pop-test sequence that continues only if it tests true. (Since there's no input, the stack is initially "", which, after exec of 1p, gets popped and tests false.) Just adding a dup will work though, i.e. {1.p}do (at 7 bytes). – r.e.s. – 2014-01-26T17:22:17.653

12

C, 25 24

main(){main(puts("1"));}

Rozuur

Posted 2013-11-09T01:51:48.960

Reputation: 501

4s/while/main/ – ugoren – 2013-11-10T14:05:52.330

2I am not sure that there are stackoverflow exception in C, but something bad will happen when you run out of memory. – Ilya Gazman – 2013-11-11T11:46:54.150

9Tailcall optimisation ftw. – Johannes Kuhn – 2013-11-28T08:38:42.257

4@JohannesKuhn: that's not a tail call. If it'd been return main(puts("1")) then it'd been a tail call. – marinus – 2013-12-30T13:39:15.563

Am I missing something? Shouldn't main take a parameter in order to take a parameter? – Phillip Scott Givens – 2014-01-14T22:33:02.580

4@psgivens. In c a function without any parameters can take any amount of parameters. Only a signature of methodName(void) accepts exactly zero parameters. – James Webster – 2014-01-27T16:59:30.723

1@marinus 'main' returns int; with no 'return' the return value is unspecified. So it is an opportunity to use a tail call; the return value from caller 'main' can be whatever the called function 'main' leaves in the register (which in this case, of course, is whatever 'main' leaves in the register, which is nothing since it never returns..) – greggo – 2014-02-07T14:52:16.157

12

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.

JesterBLUE

Posted 2013-11-09T01:51:48.960

Reputation: 696

Dang, I was looking through the answers to see if anyone had thought about printing the bell char yet. +1 – mbomb007 – 2015-04-10T20:55:30.010

12

><> (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

Thijs ter Haar

Posted 2013-11-09T01:51:48.960

Reputation: 752

11

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.

skibrianski

Posted 2013-11-09T01:51:48.960

Reputation: 1 197

Couldn't you make this shorter using say (which always prints a newline even if it can't find an argument from anywhere) rather than warn? (This requires the selection of a modern Perl variant using -M5.010, but that doesn't count against your character count.) – None – 2016-11-26T21:54:50.103

10

dc, 7

[pdx]dx

prints 'pdx\n' infinitely many times.

r.e.s.

Posted 2013-11-09T01:51:48.960

Reputation: 2 872

9

Seed, 4 bytes

99 5

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!


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

ovs

Posted 2013-11-09T01:51:48.960

Reputation: 21 408

1Won't this eventually run out of memory if values are continually pushed to the stack without being popped? – caird coinheringaahing – 2018-04-04T18:54:02.830

8

C, 26 25 24 (no recursion)

main(){for(;;puts(""));}

Prints endless '\n' characters. This is a byte longer than the shortest C answer, but doesn't rely on tail call optimization to avoid overflowing the stack.

Stuntddude

Posted 2013-11-09T01:51:48.960

Reputation: 586

2You can shave off a character by using for(;;) in place of while(! – Alex Gittemeier – 2013-11-12T14:09:07.033

1no ! as it keeps outputting \n – l4m2 – 2018-03-29T03:06:31.880

7

R, 13 characters

repeat cat(1)

plannapus

Posted 2013-11-09T01:51:48.960

Reputation: 8 610

repeat cat(1) should work – Dason – 2013-11-09T19:40:32.007

@Dason you're right. I have no idea why i insist on putting them every time. – plannapus – 2013-11-11T07:57:34.483

7

PowerShell 2.0: 17 11 8

My initial solution:

while(1 -eq 1){1}

Thanks to r.e.s.:

while(1){1}

I think Danko Durbić has the winner, here. I'm not even sure why this should work, but it does and I can't think of anything shorter so far.

for(){1}

Iszi

Posted 2013-11-09T01:51:48.960

Reputation: 2 369

It makes sense, you're creating a loop. What do you expect a loop without conditions to do? Right! It will loop – Metoniem – 2017-02-20T12:33:27.463

1Try while(1){1}. – r.e.s. – 2013-11-12T02:18:24.977

@r.e.s. I was going to trim it by two with while($true){1} but your solution definitely wins - I forgot that in PowerShell $true -eq 1. Post that as an answer, and I'll give you a vote. – Iszi – 2013-11-12T02:21:07.040

Feel free to edit it into yours, if you like. – r.e.s. – 2013-11-12T02:35:06.440

6Try for(){1} . – Danko Durbić – 2013-11-14T13:22:22.173

@DankoDurbić Can you explain why that works? I don't quite get it. Seems it should error to me. – Iszi – 2013-11-14T14:15:06.017

I'm not sure. for(;;) works, and you can use carrige returns instead of semicolons, so if for(<CR><CR>) works, so should for(), if you collapse the white space.

– Danko Durbić – 2013-11-14T15:48:02.653

@DankoDurbić For() does indeed work, but I'm trying to understand why. I don't even get why for(;;) should work. I would expect that, without any defined conditions, the loop should fail to run and/or output an error. – Iszi – 2013-11-14T17:30:36.470

In C, C++, C#, and Java, all of the expressions that define a for statement are optional. I guess the Powershell creators chose to do the same.

– Danko Durbić – 2013-11-15T09:23:08.063

See also: http://codegolf.stackexchange.com/a/199/1308

– Danko Durbić – 2013-11-15T09:48:30.377

7

Postscript 9

{1 =}loop

Output 1 in an infinite loop.

luser droog

Posted 2013-11-09T01:51:48.960

Reputation: 4 535

7

C#, 57

Another C# entry, with a twist:

class M{static int Main(){for(;;)System.Console.Beep();}}

This interpretation of "output" may be stretching, but still valid I think (and saves 4 characters! :)

Nick

Posted 2013-11-09T01:51:48.960

Reputation: 941

Doesn't work on 64 bit – Cole Johnson – 2014-03-04T02:15:38.400

@ColeJohnson Works fine for me: copy con test.cs, paste that string, ^Z and press Enter. csc /platform:x64 test.cs shows no errors. test.exe gives beep beep beep... – Nick – 2014-03-04T20:09:45.607

I meant that the internal speaker won't work. You'll hear the beeps, but they're "artificial" beeps from your desktop speakers. – Cole Johnson – 2014-03-07T00:17:35.310

@ColeJohnson Ah, that is true. Starting with Windows 7 64-bit the PC speaker driver (beep.sys) was changed to direct output to the sound card. – Nick – 2014-03-07T00:30:00.133

7

BASIC

10 PRINT "HELLO WORLD"
20 GOTO 10

Adam Speight

Posted 2013-11-09T01:51:48.960

Reputation: 1 234

3Gotta love the classics. – Michael Stern – 2016-03-21T04:07:37.907

2Is it required to use 10 20 not 1 2? – l4m2 – 2018-04-02T02:49:09.660

need to print DURAN DURAN RULEZ!!1!! for proper 80s vibe :) – roblogic – 2019-07-29T10:39:55.363

7

Windows Batch File, 1 character

Create a file called a.bat containing:

a

When you execute this batch file, it executes itself. The Windows Command Prompt by default echos every command to the console, so the output resembles:

C:\>a

C:\>a

C:\>a

C:\>a

Hand-E-Food

Posted 2013-11-09T01:51:48.960

Reputation: 7 912

7

C, 20 bytes (competing according to the challenge's creator)

Suppose the following code is contained in e.c:

int i;
#include"e.c"

In a machine with infinite system resources, GCC will create an infinitely big temporary file trying to resolve a recursive #inclusion.

user8397947

Posted 2013-11-09T01:51:48.960

Reputation: 1 242

6

sed 7 5 chars (version 4.2)

sed -e ':;p;b' <<<'Hello world!'

Unfortunely, this won't work anymore, from version 4.4 of GNU sed:

sed -e ':a;p;ba' <<<'Hello world!'

F. Hauri

Posted 2013-11-09T01:51:48.960

Reputation: 2 654

sed (GNU sed) 4.4: -e expression #1, char 1: ":" lacks a label – Alexx Roche – 2017-10-14T12:24:18.637

6

Python, 17 13

while 1:print

Thanks to Ben and r.e.s.

Rob

Posted 2013-11-09T01:51:48.960

Reputation: 1 277

@Willem Absolutely wrong. Literals are not allowed by themselves on executed programs. – Erik the Outgolfer – 2016-04-12T13:10:22.663

1You can shorten it to 15 by not printing a string and removing the brackets in the while... while 1:print 1 – Ben – 2013-11-10T21:03:52.737

5Or 13 characters: while 1:print produces "infinite output" composed of newlines. – r.e.s. – 2013-11-10T21:40:38.547

How about while 1:1 ? – Willem – 2014-04-28T18:18:30.577

which @KaranGoel found below as well – Willem – 2014-04-28T18:23:59.870

6

Z80Golf, 0 bytes

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.

Bubbler

Posted 2013-11-09T01:51:48.960

Reputation: 16 616

6

Xojo, 18 12 chars

Again, please don't actually run this (same reason as the JavaScript answer):

do
Beep
loop

Never said the output couldn't be audio...

silverpie

Posted 2013-11-09T01:51:48.960

Reputation: 139

6

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.

the system

The command say 1 put inside of a permanently active repeating command block. It will permanently output [@] 1 to the chat.

Addison Crump

Posted 2013-11-09T01:51:48.960

Reputation: 10 763

1I believe this is technically invalid, because it uses a version of the language from after the challenge :P – lirtosiast – 2015-11-12T22:40:26.690

Never mind. I'll mark it as invalid. ;D – Addison Crump – 2015-11-12T22:43:14.140

It's valid now; we had a rule change. – wizzwizz4 – 2019-07-31T12:46:47.137

6

Brachylog, 3 bytes

=w\

Try it online!

Not only does it print infinitely, this prints something much more interesting than most answers here: all integers.

Explanation

=       Assign an integer value to the input ; since it is not constrained, it can take any
          value in (-∞, +∞), meaning there is an infinite number of choice points
        The way = is implemented makes it so that the order of choices it will try is:
          0, 1, -1, 2, -2, 3, -3, …

 w      Write that integer to STDOUT
  \     False (i.e. go back to = and try the next integer choice point)

Fatalize

Posted 2013-11-09T01:51:48.960

Reputation: 32 976

5

Perl 6, 13 11 characters

Using some nice Perl6 syntax for infinite lazy lists:

.say for ^∞

The code will print all integers from 0 upto infinity or until RAM runs out to store single big integers, whichever comes first.

Matt Oates

Posted 2013-11-09T01:51:48.960

Reputation: 298

whichever comes first I think it's safe to say that RAM is infinite – MilkyWay90 – 2019-03-17T22:27:04.713

4

Haskell, 18 chars

a=1:a;main=print a

N.B.: No new line at end!

MtnViewMark

Posted 2013-11-09T01:51:48.960

Reputation: 4 779

17 bytes – dfeuer – 2019-04-14T04:09:16.597

4

Perl, 10 chars

TIMTOWTDI:

$ perl -nE 'say;redo' <input>   # 10 chars (1+8+1)
$ perl -E 'say while+1'         # 11 chars
$ perl -E 'o:say;goto o'        # 12 chars
$ perl -E 'for(;;){say}'        # 12 chars
$ cat inf.pl
warn;exec$^X,$0                 # 15 chars

If you have infinite RAM (maybe in the cloud ;-)

$ perl -E 'sub o{say;&o}o'      # 14 chars
$ perl -E '&{*1=sub{say;&1}}'   # 17 chars, just kidding *gg*

Matthias

Posted 2013-11-09T01:51:48.960

Reputation: 222

4

Wolfram Language ( Mathematica ) 14 bytes 12 characters

Do[Echo@1,∞]

Vitaliy Kaurov

Posted 2013-11-09T01:51:48.960

Reputation: 1 561

Do these 12 characters not need 14 bytes? – Jonathan Frech – 2017-09-26T08:27:42.500

@JonathanFrech yes, thank you, I corrected it. – Vitaliy Kaurov – 2017-09-26T10:16:45.767

4

PHP - 17 16 13 11 bytes

<?for(;;)echo O;

Oh well, I guess PHP can't ever always win... Thank you, m.buettner

Edit:

<?for(;;)0/0;

As it turns out, division by zero triggers a warning in php. So, even though the output it produces goes to STDERR, it's still infinite!

Edit 2:

for(;;)0/0;

(Run with php -r)

Aurel Bílý

Posted 2013-11-09T01:51:48.960

Reputation: 1 083

You don´t need the tags either if you use -r. Apart from that, this can´t be done any shorter (yet). – Titus – 2017-01-08T16:54:59.307

@Titus Or can it :) Thanks for pointing out this answer to me :D – Aurel Bílý – 2017-01-08T19:09:24.563

Wish I could upvote it again. :) Nice! You can still remove <?. Oh and if notices were in the default config ... _ or any letter instead of 0/0. Unfortunately they aren´t. – Titus – 2017-01-08T23:21:42.650

@Titus Yeah, I wasn't sure. I had to check here: http://meta.codegolf.stackexchange.com/questions/2424/running-php-with-r-instead-of-code-tags

– Aurel Bílý – 2017-01-09T14:29:20.307

9 chars: for(;;a); or while(a); Output will be a notice, needs error_reporting(E_ALL). Run like this php -r 'for(;;a);' – Vlad Preda – 2017-08-07T11:56:31.440

Do you really need that 1 in there? – Martin Ender – 2014-07-03T19:00:10.190

Huh. Apparently I don't. – Aurel Bílý – 2014-07-03T19:51:57.777

3

Matlab, 13

while 1
1
end

This prints

ans =

 1

infinitely many times.

Sven Hohenstein

Posted 2013-11-09T01:51:48.960

Reputation: 2 464

3

TeX, 14 12 bytes

\def~{x

~}~

Less infinite than the other solutions, though, as TeX writes its output to a file.

siracusa

Posted 2013-11-09T01:51:48.960

Reputation: 623

1A blank line inside the definition would still make a \par token with 2 bytes less :-) – Phelype Oleinik – 2019-05-14T17:55:06.397

3

Java (JDK 10), 32 bytes

a->{for(;;)System.out.print(1);}

Try it online!

DevelopingDeveloper

Posted 2013-11-09T01:51:48.960

Reputation: 1 415

3

Japt, 4 bytes

i@Oo

Try it online!

How it works

Ui@Oo

Ui     Call every 10 milliseconds...
  @Oo    the function that prints `undefined`.

Without input, U is initialized to zero, and 0 .i is the wrapper for setInterval JS function. According to its spec, the interval is low-capped at 10, so the target function is called every 10ms (approximately).

Oo prints its arguments to output, and with no arguments, it prints undefined.


The following is only correct with unbounded call stack (and therefore not a valid submission). When run on an actual browser, it overflows the stack in an instant.

3 bytes

ßOo

Try it online!

ß recursively calls the program. The whole source is translated to rp(O.o()) which first calls O.o() and then calls the program again.

Bubbler

Posted 2013-11-09T01:51:48.960

Reputation: 16 616

Your second solution doesn't qualify. .a() doesn't create an endless loop, it simply runs for all integers up to 1e8. See the language source code.

– Nit – 2018-05-17T08:05:16.913

The 4 byte answer doesn't qualify either, it will reach the stack limits very quickly, according to this SO question in under 50k iterations on most browsers.

– Nit – 2018-05-17T09:58:17.463

The new 9 byte solution doesn't qualify either, once the array reaches the maximum size allowed by the spec, the runtime will throw and the execution will stop. In V8, for example, the error is Uncaught RangeError: Invalid array length.

– Nit – 2018-05-17T10:09:32.527

@Nit Do you mean any code that uses ß for infinite execution is invalid, including this and this? Or is it fine under "unbounded call stack" assumption? For the array limit, ECMA spec says "If len + argCount > 2**53‑1, throw a TypeError exception" for arr.push, so I agree that the 9-byte one isn't strictly correct. But then it only leaves the boring $while(1)$ though...

– Bubbler – 2018-05-17T23:59:26.617

Where did you find the "unbounded call stack assumption"? I don't see it anywhere in the question. Nice work on that 4 byte solution, by the way. – Nit – 2018-05-18T07:17:52.030

3

Brainfuck, 8 bytes

+[[+.]+]

Assumes wrapping.

I'm aware that a solution was already posted by @cardboard_box - allthough his doesn't print any printable characters.

FIQ

Posted 2013-11-09T01:51:48.960

Reputation: 519

3

Rebol, 18 chars

forever[print now]

Can shave off 1 perhaps even 2 more characters by choosing something different to now (for eg. pi).

However I like that it prints the time forever :)

draegtun

Posted 2013-11-09T01:51:48.960

Reputation: 1 592

3

Haskell, 9 characters

show[1..]

Prints an infinite list of integers starting from 1, exploiting the lazy evaluation of Haskell.

Towerism

Posted 2013-11-09T01:51:48.960

Reputation: 31

3

Piet, 3 codels

==> Piet_infinite_output_codel_size_1 <== here it is ;)

Just to make it visible, the same at codel size 10:

Piet_infinite_output_codel_size_10

This program bounces forward and backward, executing:

forward direction:

1
PSH (push on stack)
OUN (output number)

backward direction:

MUL (multiply)
POP (pop from stack)

The backward instructions are ignored because the stack is empty.

So, the program prints an infinite amount of 1’s in the console.

Edit: I just noticed that captncraig came up with the same answer before me. Sorry for that. Please upvote captncraig’s answer instead.

M L

Posted 2013-11-09T01:51:48.960

Reputation: 2 865

1I suggest you make this CW and/or suggest that others upvote captncraig's answer if you think it's good. – lirtosiast – 2015-06-14T01:49:51.223

3

Emotinomicon 18 bytes, 5 chars

⏪⏩

Explanation:

 - push 0 to the stack
⏪ - open loop
 - push 0 to the stack
 - pop top of the stack, and output it as a number
⏩ - end loop

As long as there's something on the stack, it's going to loop indefinitely

Bálint

Posted 2013-11-09T01:51:48.960

Reputation: 1 847

Golfs two bytes, and saves precious RAM: ℹ⏪ℹ⏩. – Erik the Outgolfer – 2016-10-08T18:27:11.430

3

GNU sed, 5 bytes

:;l;b

Any sed script requires input to start executing. With echo|sed ':;l;b', a line with a single $ character on it is printed continuously.

seshoumara

Posted 2013-11-09T01:51:48.960

Reputation: 2 878

2

Commodore Basic, 5 bytes

1?:R╭

PETSCII substitution: = SHIFT+U

Prints a newline, then runs itself. Forever.

Mark

Posted 2013-11-09T01:51:48.960

Reputation: 2 099

2

Emojicode, 41 bytes

.

betseg

Posted 2013-11-09T01:51:48.960

Reputation: 8 493

2

Chip-8, 5 bytes

Sound output counts, right?

0x6F 0xFF 'set register 15 to 255
0xFF 0x18 'set sound timer to the value of register 15
0x12      'jump to first instruction (second byte is 00 so it can be omitted)

If drawing graphics counts, 3 bytes:

0xD0 0x0F 0x12

12Me21

Posted 2013-11-09T01:51:48.960

Reputation: 6 110

2

TCL (15)

while 1 puts\ x

(kind'a silly that we must write at least 30 characters per reply :)

Rolazaro Azeveires

Posted 2013-11-09T01:51:48.960

Reputation: 141

Just improved it a bit. Ignore the "always brace your expr" and other rules in code golf ;) (I forgot that I could edit without approval) – Johannes Kuhn – 2013-11-10T22:49:58.393

1And if you use the interactive command line (tclsh), you could do w 1 pu\ x – Johannes Kuhn – 2013-11-10T22:55:00.960

@JohannesKuhn Nice! Tks. – Rolazaro Azeveires – 2013-11-11T00:36:31.510

Indeed, a character minimum on a code golf site is a bit odd even though it's standard across other SE sites. I usually pad with &nbsp; when necessary - though it rarely is for me, since I usually add an explanation of my scripts as well. – Iszi – 2013-11-14T17:50:47.203

2

TI-Basic, 5

Pause

It does produce infinite output; in the top right hand corner, the pixels are alternating ;)

Game Maker Language, 11

while(1){a}

The a produces errors infinitely ;)

Timtech

Posted 2013-11-09T01:51:48.960

Reputation: 12 038

8Submitting the TI-BASIC entry is like saying any zero-character command-line entry counts because the cursor is blinking. – lirtosiast – 2015-06-14T02:12:44.643

The last one is bad. The code itself doesn't run for infinite times, but it's called infinite times – l4m2 – 2018-04-02T02:45:48.023

@l4m2 Good point, I'll take that one out. – Timtech – 2018-04-02T14:18:04.197

1This should be two answers. – 12Me21 – 2018-06-05T13:40:54.227

5

Well, the "Pause" token in TI-Basic (z80, at least), is actually 1-byte in memory :) (see http://tibasicdev.wikidot.com/pause)

– Adriweb – 2014-09-02T19:11:34.100

2

F# - 22

while 1=1 do printf"x"

goric

Posted 2013-11-09T01:51:48.960

Reputation: 271

2

APL, 7

{∇⎕←⍵}1

Defines a function which output its argument and call itself with the same argument, then call it once with argument 1

TwiNight

Posted 2013-11-09T01:51:48.960

Reputation: 4 187

2

Shakespeare Programming Language, 116 bytes

.
Puck, a pig.
Page,.
Act I:.
Scene I:.
[Enter Puck and Page]
Page:
Open thy heart! Let us return to act I.
[Exeunt]

Will output -1 forever.

chocochaos

Posted 2013-11-09T01:51:48.960

Reputation: 547

What interpreter are you using? This doesn't seem to work on the official one. (nvm, found it)

– Jo King – 2018-08-27T07:38:33.970

2

HTML + JavaScript, 35 bytes

This alerts repeatedly. For some reason, it alerts 8. It also produces a 404 error in the console each iteration.

<img onerror=alert(this.src=x) src=

JSFiddle


This is 32 bytes, but is far less interesting:

<img onerror=for(;;)alert() src=

mbomb007

Posted 2013-11-09T01:51:48.960

Reputation: 21 944

2

Alchemist, 10 bytes

_->_+Out_a

Try it online!

Explanation

Initially the universe contains the _-atom, there is only one reaction consuming _ and creating a new _ with the side-effect of printing a. This will go on until the real universe terminates.

ბიმო

Posted 2013-11-09T01:51:48.960

Reputation: 15 345

2

Lean Mean Bean Machine, 5 bytes

O
$
~

Try it online!

Endlessly output 0

O spawns a marble, which drops and runs the operation there each tick. New marbles have a value of 0.
$ prints the marble's value.
~ teleports the marble to the top of the current column.

Skidsdev

Posted 2013-11-09T01:51:48.960

Reputation: 9 656

2

Keg, 4 characters

{A,}

This outputs "A" to the console infinitely.

Non-completing forms

This simply auto-completes the } at the end.

{A,
{

This uses a later-added feature of auto-pushing & printing.

user85052

Posted 2013-11-09T01:51:48.960

Reputation:

3 bytes by removing the } – Lyxal – 2019-12-24T07:16:01.200

You are right. But back then I wouldn't have known that Keg is going to have auto-completion. – None – 2019-12-24T08:45:50.310

Heh, I know. I just was going around reading old Keg answers to see what has changed since then. – Lyxal – 2019-12-24T08:46:52.827

2 bytes – Lyxal – 2020-01-18T07:17:49.270

2

bitch, 3 characters

Yet another answer(am I supposed to be doing that?)

>/<

This program outputs infinite 0's to the console.

user85052

Posted 2013-11-09T01:51:48.960

Reputation:

2

Bitwise Cyclic Tag But Way Worse, 9 1 byte

2

Turns out that this is a valid answer, I over-complicated that way too much. Outputs endless null characters

Try it Online!

EdgyNerd

Posted 2013-11-09T01:51:48.960

Reputation: 1 106

2

Rust, 23 bytes

fn main(){loop{dbg!()}}

Try it online!

Outputs infinitely:

[src\main.rs:1]
[src\main.rs:1]
[src\main.rs:1]
[src\main.rs:1]
[src\main.rs:1]
[src\main.rs:1]

ruohola

Posted 2013-11-09T01:51:48.960

Reputation: 414

2

PowerShell (8)

Save "a.ps1" file with following script code:

1
.\a.ps1

from command line run the script.

My initial solution was different, but I found that it has already been answered by Iszi.

I managed to write another solution with same byte length.

microbian

Posted 2013-11-09T01:51:48.960

Reputation: 2 297

2

Mathematica, 11 bytes (invisible) or 17 bytes (visible)

Clearly not going to win here, but it works

For[,0<1,1]

If you actually want to see the characters streaming down the screen, use

For[,0<1,Print@1]

(20 bytes). I had thought I might do well with

Range@∞

or even

1~Table~{∞}

But to my surprise, the Kernel checks for infinite bounds and disallows them.

Michael Stern

Posted 2013-11-09T01:51:48.960

Reputation: 3 029

1Echo@1 is shorter than Print@1. – Roman – 2019-07-23T13:01:46.357

2You'll definitely need the Print version. But that can be golfed further: 1>0 is shorter than True, Print@1 is shorter than Print[1] and you can leave out one of the two consecutive commas to use the 3-argument version of For. – Martin Ender – 2014-09-02T14:41:47.937

2

Zozotez LISP: 7

When started with the minimal interactive session dictated in the documentation:

(:'r p)

How it works is that it redefined read so the REPL prints what print returns rather than keyboard input. The never ending output is continious lines of: Zozotez-moi~>NILNIL

When started with the full interactive session it gets longer, but does the same (10 bytes):

(:'read p)

Without a bootstrap Zozotez does just (eval(read)) thus we need to implement a loop in one expression (16 bytes):

((:'z(\()(p)(z))))

The : is set to it binds z to the lambda expression (\()(p)(z)), when called without arguments calls print (p) with default argument NIL, then calls z (recurses).

: returns the value (the function) so wrapping it all in parenthesis makes the initial call.

Common Lisp: 15

(loop(print())) ; prints infinite lines of NIL

Racket: 21

(let z()(print'N)(z))

Works similar. The names let makes and calls the proecdure l that takes no arguments. The body prints N, then recurses. print without arguments displays data quoted so it prints 'N'N'N....

Scheme: 23

(let z()(display'N)(z))

Same as Racket version only that display is used which don't quote output. NNNN...

Sylwester

Posted 2013-11-09T01:51:48.960

Reputation: 3 678

2

I've got two:

C - 27 26 24 bytes

main(){for(;;)puts("");}

This one infinitely prints \n, due to the behavior of puts(3)

Brainfuck - 13 4 bytes

+[.]

This one infinitely prints the invisible Start Of Heading control character.


(Thanks to scottinet, Sylwester and Erik the Golfer for suggestions that helped shorten the answer)

Braden Best

Posted 2013-11-09T01:51:48.960

Reputation: 161

The BF answer is already posted. – NoOneIsHere – 2016-11-25T03:23:26.650

@SeeOneRhino code golf is not a Q&A site – Braden Best – 2016-11-25T22:29:46.407

(NB: SeeOneRhino is an anagram of NoOneIsHere) – Braden Best – 2017-02-25T23:16:17.023

1Use puts("") for -2 bytes (prints \n infinitely) – scottinet – 2017-09-01T18:46:16.640

@scottinet done – Braden Best – 2017-09-04T20:10:21.827

I have something shorter. – tbodt – 2014-01-30T20:22:16.710

@tbodt Oh, I didn't know null counted. I thought it had to be visible – Braden Best – 2014-01-30T20:33:45.507

3@B1KMusic, If you have 2 (or more) answers, it's best to post them separately. – gnibbler – 2014-02-02T09:38:14.097

2

Piet (135 codels/pixels)

Prints an infinite sequence of $ signs (arbitrary, could've been anything. Loaded in the upper right corner of course).

The awesome program

Run with npiet -v11 the.gif

Benjamin Podszun

Posted 2013-11-09T01:51:48.960

Reputation: 121

2In Piet, pixels count as characters. – tbodt – 2014-02-02T23:40:51.707

@tbodt - It's 135 pixels, but 112 bytes (if I'm not mistaken) -- byte-count is supposed to be the code-golf criterion. – r.e.s. – 2014-02-03T00:24:28.443

3what if you save it in a different image format? for piet, I count number of pixels. – tbodt – 2014-02-03T00:26:40.200

2

Thue, 19

b::=~1
a::=ba
::=
a

The code prints an infinite stream of 1's.

The code is quite simple and easy to understand.

  • b can be expanded as "output 1" (then b is replaced with empty string)
  • a can be expanded as/replaced by ba
  • ::= on its own ends the list of rules
  • a on the last line represents the initial state.

n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

Posted 2013-11-09T01:51:48.960

Reputation: 5 683

2

Brainfuck - 6/4

Brainfuck does this easily:

-[.>-]

If we assume that the interpreter didn't zero the cells on startup but instead gave us already-initialised cells, the count goes down by two:

[.>]

Darkgamma

Posted 2013-11-09T01:51:48.960

Reputation: 181

2Why not just -[.]? – Justin – 2014-04-23T18:51:05.060

Hm, I haven't thought of that really, good idea. – Darkgamma – 2014-04-24T13:34:00.830

But that is actually a duplicate of another answer here. – Justin – 2014-04-24T17:32:16.757

I haven't seen the others before now, really, though even just -[.] is shorter than the other answers given. – Darkgamma – 2014-04-25T12:06:05.760

You should really go through other answers, especially of the same language, before posting. – Justin – 2014-04-25T15:19:36.967

2

Bash, 9 characters

echo 1;$0

Because the $0 variable always holds the filename.

user241920

Posted 2013-11-09T01:51:48.960

Reputation: 31

1I'm not sure this will really have an infinite output. You'll run out of memory before reaching infinity. echo 1;exec $0 would be better (but also has more characters). – gniourf_gniourf – 2014-04-26T09:22:40.377

2

C# (16)

Directly executable in LinqPad:

for(;;)0.Dump();

EvilFonti

Posted 2013-11-09T01:51:48.960

Reputation: 301

2

Ruby: 9 charecters

loop{p 1}

p 1 is equivalent to puts 1.inspect

addison

Posted 2013-11-09T01:51:48.960

Reputation: 993

2

Shell, 16 Chars

cat /dev/urandom

Thomas Junk

Posted 2013-11-09T01:51:48.960

Reputation: 131

1also grep -r / . for 12 bytes – roblogic – 2019-07-29T10:36:06.350

2

Pyth, 2

#G

(or # followed by any normal variable, actually).

# is while True. Variables are printed implicitly, and since G is 'abcdefghijklmnopqrstuvwxyz', that gets printed infinitely.

isaacg

Posted 2013-11-09T01:51:48.960

Reputation: 39 268

This makes me want to learn Pyth myself. – DJgamer98 – 2015-11-13T08:33:36.030

2

x86 machine code, 6 bytes

b40e cd10 ebfc

Assembly version of the code:

mov ah, 0Eh;    bios teletype output
code_golf:
int 10h;        print character(ascii 0)
jmp code_golf;  loop

This code constantly prints ASCII 0 (NULL).

This was run using DOSBOX

SirPython

Posted 2013-11-09T01:51:48.960

Reputation: 178

What OS is this for? (DOS? Linux?) Can you put that in your answer? – tbodt – 2015-03-05T22:24:41.663

@tbodt I did specify: x86. But, I can see how some people might be confused so I included how I ran the code. – SirPython – 2015-03-05T23:14:01.670

2

The Hexadecimal Stacking Pseudo-Assembly Language (24):

000000
400000
120000
010000

Continuously prints 0s.

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

1Now that's a long language name – Benjamin Urquhart – 2019-06-01T17:47:18.350

2

APL, 6 4 bytes

→⍞←1

A traditional style APL function, so even works on all legacy APLs.

Adám

Posted 2013-11-09T01:51:48.960

Reputation: 37 779

2

Jelly, non-competing

2 bytes This answer is non-competing, since the challenge predates the creation of Jelly.

Ȯß

Try it online!

How it works

Ȯß  Main link. Implicit argument: 0

Ȯ   Output/print the implicit argument.
 ß  Recursively call the main link.
    Thanks to tail call optimization, this results in an actual infinite loop.

Dennis

Posted 2013-11-09T01:51:48.960

Reputation: 196 637

2

Desmos, 1 byte

x

Graphs y=x forever.

weatherman115

Posted 2013-11-09T01:51:48.960

Reputation: 605

Look, submitting Desmos answers is my job :P Good job anyway. – Benjamin Urquhart – 2019-06-01T17:48:49.477

2

APL, 4 bytes

1
→1

This code must be put in a function, since the →(goto) operator has only sense in a function.

TuxCrafting

Posted 2013-11-09T01:51:48.960

Reputation: 4 547

2

Oration, 21 bytes (non competing)

to iterate, 1
listen,

40 bytes:

to iterate, 1
listen,
capture,
that's it

The first does print() (but it's python 2, so prints infinite ()), the second does print('') (the capture begins a string and the that's it ends it).

Żáłģó

Posted 2013-11-09T01:51:48.960

Reputation: 71

2

Sesos, 2 bytes (non-competing)

0000000: 2c06                                              ,.

Prints an infinite amount of ones.

Try it online! Check Debug to see the generated binary code.

How it works

The binary file above has been generated by assembling the following SASM code.

set numout ; Switch to numeric output

add 1      ; Set the current cell to 1.
jmp        ; Jump to the corresponding exit marker.
    put    ; Print the integer in the current cell to STDOUT.
           ; (implicit jnz)
           ;     If the integer in the current cell is non-zero,
           ;     jump to the previous instruction.

Dennis

Posted 2013-11-09T01:51:48.960

Reputation: 196 637

2

Cubix, 2 bytes

.O

Test it online!

Cubix is a stack-based 2D language, created by me in March 2016. Cubix differs from ordinary 2D languages in that it's not strictly 2D: the code is wrapped around a cube. This program wraps to this cube net:

   .
>O . . .
   .

where the IP (instruction pointer) starts at the arrow. O outputs the item on top of the stack as a number; if the stack is empty, it outputs 0. . is a no-op.

When the IP reaches the right side of the cube net, it simply wraps back around to the left and runs O again. Thus, this code outputs 0 forever.

ETHproductions

Posted 2013-11-09T01:51:48.960

Reputation: 47 880

2

Retina, 4 bytes (non-competing)

The language is newer than the challenge.

+:`0

Try it online

Doesn't match, so output 0, then it does match so output 1, now it doesn't so output 0, etc...

mbomb007

Posted 2013-11-09T01:51:48.960

Reputation: 21 944

2A paradox in action :) – ETHproductions – 2016-11-15T23:05:43.543

1

zsh (8 chars)

</dev/z*

Analogous to cat /dev/zero.

Note: This does depend on there not being any other files in /dev starting with z, other than /dev/zero.

apricot boy

Posted 2013-11-09T01:51:48.960

Reputation: 281

Given that this particular configuration of /dev is the default on many UNIX-like operating systems (e.g. Ubuntu, which I had easily available to test), I'm pretty sure there are "implementations" where this works. – None – 2016-11-26T21:36:20.923

1

TI-83 Hex Assembly, 6 bytes

PROGRAM:I
:AsmPrgm
:EF0A45
:C3959D

Run with Asm(prgmI). Prints garbage over and over again. The only way to stop the printing is to physically remove the batteries from the calculator and re-insert them, at which point the calculator's RAM will be cleared. I count each hex digit pair as one byte.

Harry

Posted 2013-11-09T01:51:48.960

Reputation: 1 189

1

Casio FX-7000G, 6 bytes

Lbl 0◢
Goto 0

This uses the calculator's own encoding, where each token is stored as a byte.

Lbl 0 sets the label of the first line to 0. The triangle means "print last value", which is in this case 0. The next line is your standard Goto statement, jumping back to the top so the value can be printed again.

Due to the calculator's limitations, the user must press EXE after each printed value before the next can be displayed.

FlipTack

Posted 2013-11-09T01:51:48.960

Reputation: 13 242

Very cool. The FX-7000G was cutting-edge tech in the mid 80s. Reminds me of my old FX-3900P (RIP)

– roblogic – 2019-07-29T10:20:18.543

1

Labyrinth, 1 byte

!

Labyrinth's stack has implicit zeroes at the bottom and the ! character outputs the integer representation of top of the stack. Since the program never finds anywhere else to go besides this single character, it keeps repeating that instruction.

Robert Hickman

Posted 2013-11-09T01:51:48.960

Reputation: 661

1

8th, 24 19 bytes

: f 0 . recurse ; f

The word f pushes a 0 on the stack and print it in a recursive way

Chaos Manor

Posted 2013-11-09T01:51:48.960

Reputation: 521

Won't that fail with a "stackoverflow" ? (i.e. does 8th recognize the tail recursion?) – zeppelin – 2017-01-17T22:30:36.347

@zeppelin - 8th implements "tail-call elimination" and the above mentioned code runs smoothly. See this post for further explanation.

– Chaos Manor – 2017-01-18T06:45:03.237

1

GO, 13 bytes

for{print(0)}

Try it online!

powelles

Posted 2013-11-09T01:51:48.960

Reputation: 1 277

1

SmileBASIC, 6 bytes

?EXEC.

? is print, EXEC runs a program, and . is the same as 0.0.

If newlines don't count as output, here's a 7 byte answer:

?.EXEC.

?. = PRINT 0.0, EXEC. = EXEC 0.0

12Me21

Posted 2013-11-09T01:51:48.960

Reputation: 6 110

1

Commodore 64/VIC-20 assembly, 8 bytes (assembled)

033C LDA #$40
033E JSR $FFD2
0341 JMP $033E

When executed with SYS 828, this will continuously output the @ character to the screen using the Kernal routine to print. If you don't care what you're outputting, then you can remove 033C LDA #$40 and save two whole bytes (the last thing in the accumulator will be outputted).

Shaun Bebbers

Posted 2013-11-09T01:51:48.960

Reputation: 1 814

If you remove the code at 033C then you will need to execute with SYS 830, unless you start the code at 033C and change JMP 033E accordingly. – Shaun Bebbers – 2017-02-16T12:16:32.750

1

√ å ı ¥ ® Ï Ø ¿ , 3 bytes

(o)

Will output:

===== OUTPUT =====

0 0 0 0 0 etc.

==================

followed by execution information.

TIO Compiler. Enter the code as the first input and None as the second.

caird coinheringaahing

Posted 2013-11-09T01:51:48.960

Reputation: 13 702

It seems that the language was implemented recently. Should this be marked as non-competing? – fergusq – 2017-03-13T18:47:31.310

Oh yeah forgot to do that. Update added – caird coinheringaahing – 2017-03-13T18:48:22.167

1

Alice, 1 byte

o

Prints null bytes indefinitely.

Martin Ender

Posted 2013-11-09T01:51:48.960

Reputation: 184 808

1

Braingolf, 6 bytes

[1+!_]

Try it online!

totallyhuman

Posted 2013-11-09T01:51:48.960

Reputation: 15 378

1

Check, 3 bytes (non-competing)

#<#

Outputs infinite newlines.

Check is my new esolang. It uses a combination of 2D and 1D semantics.

Explanation

This uses a bit of a hack in the language - namely, that < means "print a newline" in 1D mode, and "move left" in 2D mode.

The IP first runs into a #, which turns it into 2D mode. However, it runs into <, which immediately points it back. It runs into the first # again and switches back to 1D mode. The IP then hits <, which outputs a newline, and then hits the second #, which switches it back to 2D mode again. The IP wraps around to the first #, where it switches back to 1D mode. It hits < again, printing another newline, and the process repeats.

Esolanging Fruit

Posted 2013-11-09T01:51:48.960

Reputation: 13 542

...how is that 7 bytes? – MD XF – 2017-06-06T04:11:19.193

@MDXF I guess I awarded myself extra bytes for not being able to count. – Esolanging Fruit – 2017-06-06T05:00:01.783

1

Decimal, 12 bytes

11D91D30191D

Try it online!

Explanation:

11D   ; push whatever's in RAM to the stack as an INT
91D   ; declare jump 1
301   ; print
91D   ; goto jump 1

Another version that does not invoke undefined behavior:

82D   ; builtin - push random INT to stack
91D   ; declare jump 1
301   ; print
91D   ; goto jump 1

MD XF

Posted 2013-11-09T01:51:48.960

Reputation: 11 605

1

Unreadable, 16 bytes

'"""""'"""'"'"""

Try it online!

Skidsdev

Posted 2013-11-09T01:51:48.960

Reputation: 9 656

Aren't Unreadable programs supposed to use the > '"""""'"""'"'""" markdown, to live up to its name? – caird coinheringaahing – 2017-12-10T14:52:21.977

1

MOO, 39 38 bytes

while(!suspend(player:tell()))endwhile

Huge abuse of side effects; player:tell() by default does not return a value, which means it implicitly returns zero, and the resulting suspend(0) is necessary to avoid running out of ticks.

pppery

Posted 2013-11-09T01:51:48.960

Reputation: 3 987

1

Cubically, 3 bytes

%0)

This should look like this:

(%0)
(    open loop that can always be jumped to
 %0   print 0th face sum as integer (0)
   ) jump back to loop regardless of faces

However, ) will just jump back to the start of the file if no jump point is provided.

MD XF

Posted 2013-11-09T01:51:48.960

Reputation: 11 605

1

Dreaderef, 9 8 7 bytes

5?1 1-1

Try it online!

Explanation:

In a more readable form (which can still be fed into the preprocessor), this program is:

numo 0
deref 1 -1

The numo (numeric output) statement does just about what you'd expect: it outputs 0. I could have used chro, but that makes it output unprintables and doesn't affect the byte count.

To understand the second line, you have to know a little bit about Dreaderef:

  • Programs are loaded into the data space at the beginning of execution.
  • The pointer to the current instruction is located at position -1.

What deref 1 -1 does is:

  • Dereferences 1 (takes the value of the cell at index 1). This always returns 0.
  • Stores the result in cell -1, which is effectively a GOTO to instruction 0.

Dreaderef doesn't have a "load constant" instruction, so the best way to load a constant into a cell is to use some sort of arithmetic instruction or copy it from some other cell with deref, which is what I do here.

Esolanging Fruit

Posted 2013-11-09T01:51:48.960

Reputation: 13 542

1

Dyalog APL, 5 bytes

⍞←⍣⊢0

⍞← character output

(f⍣g)Y power operator repeatedly applies left operand to the argument until (f Y) g Y returns true. In this case f is the assignment to output and g is which returns the right argument, which is always 0 as the assignment doesn't modify it.

Note that the right operand could also be any of ⊣≠≢

I hesitate to add a link to try it online :)

Gil

Posted 2013-11-09T01:51:48.960

Reputation: 141

Nothing to worry about, TIO limits you to 128 kb and 1 minute: Try it online!

– Adám – 2017-08-22T15:47:11.707

1

JavaScript, 20 bytes

for(;;)console.log()

Sends infinite undefined output.

user74919

Posted 2013-11-09T01:51:48.960

Reputation: 11

1

PHP, 16 bytes 8 bytes

My first attempt and this Code Golf :)

while(a)

I'm sure I could make it better without that echo? hmm...

Shaun Moore

Posted 2013-11-09T01:51:48.960

Reputation: 11

1Welcome to PPCG! Hope you stick around! – Rɪᴋᴇʀ – 2017-10-12T14:58:42.653

Thanks! How was my attempt? Not as good as the others how do thy do it? :L – Shaun Moore – 2017-10-12T16:27:01.553

It was pretty good! Best I could have gotten, at least. Most of the other answers are in golfing languages, which are much shorter, but don't let that discourage you! – Rɪᴋᴇʀ – 2017-10-13T15:30:39.017

2First, you can leave out the curcly braces, since there is only one statement in the loop anyway: while(1)echo 0;. To golf it further, you can use print instead of echo. Print allways returns 1, so you can then use it inside your while, golfing it to while(print 0);. You can get it even smaller if you're going for infinite error output: while(a);. – chocochaos – 2018-02-13T09:04:45.950

1

Pyth - 2 bytes

#0

Exlanation:

#0
#  Loop forever
 0 Print 0

Tornado547

Posted 2013-11-09T01:51:48.960

Reputation: 389

1

C#, 60

class A{static void Main(){for(;;System.Console.Write(1));}}

It'sNotALie.

Posted 2013-11-09T01:51:48.960

Reputation: 209

1

Golf-Basic 84, 2 characters

p`

Causes upper-right line of 5 pixels to alternate continuously.

Timtech

Posted 2013-11-09T01:51:48.960

Reputation: 12 038

1

TIS -n 1 1, 12 bytes

@0
MOV 0 ANY

Try it online!

Just shoves a bunch of 0\n to the output. On TIO, reached the 128KiB cutoff quite quickly. Without the -n flag, prints null bytes instead.

If you are familiar with TIS-100, you will be used to a 3x4 array of computational nodes, however, this solutions only uses one such node, nominally giving the zeroes downward as output.

The only instruction that send data out of a computational node is MOV, and that requires a source and a destination. the smallest possible source is a single digit number, and the smallest possible destination is UP. However, to produce actual output, the data needs to travel downwards, restricting the choice to either DOWN or ANY.

Phlarx

Posted 2013-11-09T01:51:48.960

Reputation: 1 366

1

Gol><>, 1 byte

D

Try it online!

D is a command designed for debugging, which prints the entire stack (from bottom to top) between brackets. D on empty stack generates []\n to stdout, and the IP loops through the row endlessly.

Alternative solution, 1 byte

Credits to Jo King

N

Try it online!

Unlike ><>, Gol><> has infinite zeroes at the bottom of the stack, which allows to print the top without pushing anything. Any of Nno will do; N prints 0\n, n prints 0, and o prints null bytes.

Alternatively, there are many 2-byte solutions:

  • One of 0-9a-f, l, or m followed by one of NnoD; Try it online!
    • Any of 0-9a-f pushes a hexadecimal digit to the stack, l pushes the current stack size, and m pushes -1.
    • N prints the top as number with newline, n is the same without newline, and o prints as a char.
  • S"; Try it online!
    • Initially S" is interpreted as one command which prints the encountered chars up to ending ". The next loop of S" is interpreted as a literal S and then closing ", which prints a single S to stdout.
  • " followed by any of NnoD; Try it online!
    • Use " as both opening and closing quote, then print the char.

Bubbler

Posted 2013-11-09T01:51:48.960

Reputation: 16 616

1

Ahead, 1 byte

O

Prints 0 forever. O pops the stack and prints that value as a number written out (as opposed to a Unicode character). Like Befunge, the empty stack pops 0, so this will print 0.

Since this is a 1x1 board, the head has nowhere to go and will stay on this cell forever, outputting forever.

snail_

Posted 2013-11-09T01:51:48.960

Reputation: 1 982

1

Prolog (14 bytes)

a:-write(0),a.

Simple tail recursive predicate in swi-prolog. Called like so a.

Khepu

Posted 2013-11-09T01:51:48.960

Reputation: 11

Welcome to PPCG! – Laikoni – 2018-06-06T14:16:32.713

@Laikoni it's nice to be here :) thank you. – Khepu – 2018-06-06T16:59:09.753

1

Shakespeare Programming Language, 89 bytes

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Scene V:.Ajax:Speak thy!Let usScene V!

Try it online!

I haven't used this language before, this is mostly based on tips from "Tips for golfing in The Shakespeare Programming Language", so I think it can be made shorter.

12Me21

Posted 2013-11-09T01:51:48.960

Reputation: 6 110

You can reduce this to one Scene for 86 bytes

– Jo King – 2018-08-27T07:34:09.110

1

Flobnar, 4 bytes

0,_@

Try it online!

Outputs 0x00 bytes indefinitely.

This works because _ is said to get the conditional from the cell on the other side of it, and then use its value to choose between the east and west cells. It is expected to be evaluated from a vertical direction, but it doesn't have to be.

@ indicates the starting point for the program and evaluates to the return value of the cell to its west (_). _ evaluates what's on the other side (0,) to print 0. , always has a return value of 0, however, and this causes the horizontal if to choose the branch to its east. This is @, which evaluates the cell to its west, continuing the cycle.

Flobnar doesn't have decimal output by default, but the linked implementation has a -d flag which enables . for decimal output. This allows a slightly prettier version that outputs printable characters instead.

0._@

Try it online!

Esolanging Fruit

Posted 2013-11-09T01:51:48.960

Reputation: 13 542

1

Taxi, 377 369 bytes

-8 bytes by getting rid of the quotes.

Go to Post Office:w 1 l 1 r 1 l.
[B]
! is waiting at Writer's Depot.
! is waiting at Writer's Depot.
! is waiting at Writer's Depot.
Go to Zoom Zoom:s 1 l 1 l 4 l 2 r.
Go to Writer's Depot:w.
Pickup a passenger going to Post Office.
Pickup a passenger going to Post Office.
Pickup a passenger going to Post Office.
Go to Post Office:n 3 r 2 r 3 r 1 l.
Switch to plan B.

The repetition of the passengers is needed for the driver to get enough fare to get enough gas to continue forever.

Try it online!

JosiahRyanW

Posted 2013-11-09T01:51:48.960

Reputation: 2 600

1

Perl 6, 8 bytes

Thanks to nwellnhof for this solution.

.say xx*

Try it online!

Prints (Any) infinitely.

Perl 6, 10 bytes

1...!*.say

Try it online!

Defines a list that increments until the result of printing the current number is false (which never happens).

Jo King

Posted 2013-11-09T01:51:48.960

Reputation: 38 234

1

Clean, 7 bytes

f=[0:f]

Try it online!

Gives [0,0,0,0,...

Οurous

Posted 2013-11-09T01:51:48.960

Reputation: 7 916

1

Muriel, 39 bytes

A:"\";.A;@\"A:\\\"\"+|A+A";@"A:\""+|A+A

Try it online!

This is near identical to the Muriel quine, except I've changed the print command in the last instruction to an eval command, and the addition of .A; in order to print something (in this case, the shortest thing was a part of the source code ("+|A+A";@"A:\""+|A+A) itself).

Jo King

Posted 2013-11-09T01:51:48.960

Reputation: 38 234

1

Gol><>, 1 byte

n

There we go, I feel like this cheats a little bit, but it works! Now to golf this more... ;)

Try it online!

KrystosTheOverlord

Posted 2013-11-09T01:51:48.960

Reputation: 681

1

Voovoos, 3 bytes

x.<

Pretty much just endlessly bounces between the . and <
. pops the top of the stack and prints it, but if you pop an empty stack in voovoos you get 0, so it just endlessly prints 0.

Skidsdev

Posted 2013-11-09T01:51:48.960

Reputation: 9 656

1

TI-BASIC, 5 bytes

Disp 1:prgmA

This solution requires that the program's name is prgmA.

Displays 1 on a new line forever, or at least until the calculator runs out of free RAM.


Here's an alternative 7 byte solution that is guaranteed to never terminate:

While 1:Disp 1:End

It has the same output as the above solution.


Notes:

  • Each successive prgmA call uses up 16 bytes of free RAM.

  • If there aren't 16 free bytes, then the program crashes with an ERR:MEMORY error.

Tau

Posted 2013-11-09T01:51:48.960

Reputation: 1 935

1

YABALL, 3 bytes

!.?

Try it online!

Explanation

!                  Go off of "reverse mode" (a mode where the IP goes left instead of right) if in reverse mode, otherwise no-op
.                  Print current cell, which is NUL
?                  Go in "reverse mode"

Basically an infinite loop printing NULs.

The commands are executed like so: !.?.!.?.!.? ...

MilkyWay90

Posted 2013-11-09T01:51:48.960

Reputation: 2 264

1

Turing Machine But Way Worse, 27 13 bytes

0 0 0 1 0 1 0

Try it online!

Outputs infinite NUL characters.

u_ndefined

Posted 2013-11-09T01:51:48.960

Reputation: 1 253

1

MINOL, 5 bytes

GOTO0

Any expression in MINOL that isn't entered as part of a program (that is, isn't assigned a line number by the user) is considered line 0. While seemingly not a part of the official spec (which, as far as I can tell, is a series of letters sent to and subsequently reformatted and published by 'Dr. Dobb's Journal of Computer Calisthenics and Orthodontia' in 1976), lines executed this way always seem to spit out a newline. This obviously wouldn't be the case in a full program, which would take 11 bytes (inc. the trailing CR):

1 PR:GOTO1

brhfl

Posted 2013-11-09T01:51:48.960

Reputation: 1 291

1

Intercept 1.1, 37 bytes

Almost exact copy of my answer to a different question.

malware bm bitminer
software install 1

Prints newlines to the terminal. You'll probably have to leave this one overnight, as there is a delay of 5-15 minutes between each newline.

Will print infinitely as long as:
Your internet connection does not drop.
Nobody runs an antivirus program on your system.

Input is marked with a >>. The command prompt is the empty >>.

Assuming a system with only TZ_INFECT installed...


>> malware bm bitminer
creating bm (bitminer)
... wait a minute ...

finished creating bm (bitminer)
>> software install 1
Success
bm installed

...wait...
(newlines)








>>

Note that I'm using a custom client that prefixes [BROADCAST] to all broadcast events.

How???

TZ_INFECT is Intercept's malware generator. We can generate a bitminer by running malware <name> bitminer. This will create a new piece of software with the given name of type bitminer

We then install the bitminer: software install <index>, where index is the 0-based index of the software as given by software list. This is why I made sure the only piece of software on the system was the malware generator. This places our new bitminer at index 1.

There is a bug in the implementation of bitminer that results in an empty broadcast event to be sent to the client whenever bits are generated. Since bits are generated at random intervals, the broadcasts are sent at random intervals. Forever.

Note: the newlines are harder to detect using the official game client, but you can see them by running a command and watching the newlines slowly push the resulting output off the screen.

Intercept

Benjamin Urquhart

Posted 2013-11-09T01:51:48.960

Reputation: 1 262

1

Bash, 3 bytes

top

Haven't seen anyone do this yet. It's tied with the yes answer.

Benjamin Urquhart

Posted 2013-11-09T01:51:48.960

Reputation: 1 262

1

Triangular, 4 bytes

,%0/

Prints 0 repeatedly.

Try it online!


Ungolfed:

  ,
 % 0
/

Reinstate Monica

Posted 2013-11-09T01:51:48.960

Reputation: 1 382

1

Rabbit~, 3

]:[

Prints the number 93 (Int representation of ']') infinitely.

Inverted brackets loops until input is equal, doesn't terminate since input is always ']'

Adam

Posted 2013-11-09T01:51:48.960

Reputation: 131

1

Underload, 8 bytes

(:S:^):^

Endlessly outputs :S:^

Try it Online!

EdgyNerd

Posted 2013-11-09T01:51:48.960

Reputation: 1 106

1

Pyth, 3 2 bytes

#d

Try it online!

Prints the string " " (single space) until a print instruction produces an error (which, I mean, I guess could happen).

hakr14

Posted 2013-11-09T01:51:48.960

Reputation: 1 295

1

PDP-11 Machine Code: 2 bytes (or 6 if you actually want output)

mov -(pc),-(sp)    ; octal opcode = 014746

On many PDP-11's, this instruction will actually do what it says - back the PC up, push its own opcode onto the stack, and repeat until all 64K ram is used up and then just keep filling circularly (or until something like a segfault happens). Not really infinite output, but it's in the spirit.

In 6 bytes you could do this, sending characters directly to the console

mov #SerialPortTxRegAddr,r0  ; oct= 012700 177562 hex = 0x15C0  0xFF72
movb -(pc),(r0)              ; oct= 114710        hex = 0x99C8 

Which would send a series of 0xC8 characters (these would be probably be seen as 'H' by any terminal which would be attached to the PDP-11)

Yes, I'm actually that old :-)

greggo

Posted 2013-11-09T01:51:48.960

Reputation: 231

1

Intcode, 8 bytes

4,0,5,0,1

Outputs "4" an infinite number of times.

pppery

Posted 2013-11-09T01:51:48.960

Reputation: 3 987

1

Shakespeare Programming Language, 86 bytes

8.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]Ajax:Speak thy.Let usAct I.

Try it online!

Prints infinite literal NULs. Since all characters initialize to 0, we can just print the value of one of them and loop back to Act I. I use Jo King's trick of beginning Scene I with Exeunt to save bytes over using a second scene. Pretty simple stuff.

Hello Goodbye

Posted 2013-11-09T01:51:48.960

Reputation: 442

1

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

Slord6

Posted 2013-11-09T01:51:48.960

Reputation: 71

1

Atari 8-bit Basic — 7 characters

1L.:G.1

This is what you can type. Internally, it expands to:

1 LIST : GOTO 1

In Atari 8-bit Basic you can use LIST in a program.

I seem to remember this shorter sequence:

1L.:R.

Which expands to:

1 LIST : RUN

This would work, but I'm not sure if R. corresponds to RUN.

user15259

Posted 2013-11-09T01:51:48.960

Reputation:

1

Assembly X86 - 44

Ok Im not a geek with assembly x86 but I wanted just to add this as a possible solution. COnsidering the number of dependencies needed by assembly code this code should be the shortest, a simple infinite loop that prints "x":

loop:
  movl $120, %rdi
  call putchar
  jmp loop

Fez Vrasta

Posted 2013-11-09T01:51:48.960

Reputation: 1 078

1

awk, 15/19 chars

Canonical version, 19 characters:

BEGIN{for(;;)print}

Version requiring user input (one newline will do), 14 chars (scores as 15 because of the required input):

{for(;;)print}

skibrianski

Posted 2013-11-09T01:51:48.960

Reputation: 1 197

1

~-~! - 17 bytes, with cheating 14 bytes

'=|@*:'&*|:'&|.|:

~-~! has a very limited set of characters, and does not support explicit numbers, so yeah. Outputs infinite .s.

If I sway the rules a bit and have the user input the character to be output infinitely, I can have 15 bytes:

'=|@*:'&*|:'&^:

Depending on the implementation, the last : for both of these can be left out, lowering the byte counts to 16 and 14.

cjfaure

Posted 2013-11-09T01:51:48.960

Reputation: 4 213

Please link to a web page describing this language. Google turns up nothing, because the language name is just punctuation. – tbodt – 2014-03-10T23:24:49.443

@tbodt It's over here; the language is unimplemented but it wasn't designed for this question and I didn't influence it's development at all. :P

– cjfaure – 2014-03-11T08:19:51.550

1

J 11

echo@-^:_]1

Outputs 0's because inversion (-) does not converge when repeated ad infinitum (^:_).

jpjacobs

Posted 2013-11-09T01:51:48.960

Reputation: 3 440

1

A couple of attempts for AVR, starting with one of the older MEGA/TINY models:

inc r1
out DIRC, r0
out DIRC, r1
rjmp .-2

And for XMEGA:

inc r0
sts PORTC_DIR, r0
rjmp .-2

Both of these rely on registers being cleared at reset. The output is toggling the direction of PORTC pin 0 (input/output). You need to connect a pull-up resistor to this pin to create a square wave.

user

Posted 2013-11-09T01:51:48.960

Reputation: 233

1

Coffeescript 15

 alert 0 while 1

zsitro

Posted 2013-11-09T01:51:48.960

Reputation: 151

Or: loop alert() – eosterberg – 2015-04-11T15:57:53.597

1

Bash - 13

cat /dev/zero

OK, not the shortest, but I'm surprised this isn't here already.

Jwosty

Posted 2013-11-09T01:51:48.960

Reputation: 3 530

Even shorter: cat /dev/zero. – tbodt – 2014-06-22T22:05:30.180

Ah, thanks! I knew I was forgetting something :) – Jwosty – 2014-06-22T22:07:50.407

1

Bash - 7 Characters

echo
$0

Prints endless newlines, at least until your computer crashes.

Ian D. Scott

Posted 2013-11-09T01:51:48.960

Reputation: 1 841

1

k4/q (11)

{x}{x""}/-1

The second function, {x""}, sends the empty string to x. If x is an integer, it's interpreted as a file descriptor. If x is 1 or 2, this means to print to stdout or stderr. If x is -1 or -2, this means to additionally print a newline. The result of sending a string to a file descriptor is that file descriptor.

The first function {x} is an idempotent function. (k has an actual idempotent function, ::, but in this context, it would have to be written (::), so this is shorter.)

The construct g f/x, where g and f are functions, is a variation on functional "fold": f x is called, then g f x is tested as a boolean; if it is false, execution stops; if not, f is called on the result of the prior call. (The return value is the result of the last call to f.) Every integer but 0 is truthy, so the -1 returned by {x""} -1 allows the execution to continue.

As a bonus, and at no extra character cost, if you swap the / for a \, you'll waste infinite amounts of RAM too: g f\x does the same thing, but it saves all the intermediate results as it runs--its return value is the full list of intermediate returns of f.

Just for fun, here's another alternate version. It's the same length, but only valid in k (not q):

`{x}{x@$x}/1`

This one prints "1"s forever, through more or less the same method, but a couple details are slightly different.

Aaron Davies

Posted 2013-11-09T01:51:48.960

Reputation: 881

1

Simplefunge, 3 chars

Does it count if, you know, it is your own language?

>o<

Prints 0 over and over again, as the tape is initialized as a tape of infinite zeros.

Aearnus

Posted 2013-11-09T01:51:48.960

Reputation: 251

1

CJam, 6 bytes

1{1p}h

or

{1p1}g

which prints an infinite number of 1\n without risk of stack overflow (as there's no recursion).

I think CJam might be younger than the question, but this answer isn't a winner, so I don't see any harm.

Martin Ender

Posted 2013-11-09T01:51:48.960

Reputation: 184 808

1

QBasic, 6 (5?) characters

?1:RUN

? is short for PRINT, and RUN without arguments runs the current file from the top. This is the shortest (and most interesting) way to get an infinite loop in QBasic.

If, as in the accepted answer, infinite newlines count, then I present this 5-character version:

?:RUN

DLosc

Posted 2013-11-09T01:51:48.960

Reputation: 21 213

1

LOOP, 1

.

Outputs 000000000...

blutorange

Posted 2013-11-09T01:51:48.960

Reputation: 1 205

1

This Programming Language, 2

In the spirit of the Befunge answer,

i'

Outputs 105 indefinitely.

BobTheAwesome

Posted 2013-11-09T01:51:48.960

Reputation: 509

1

Turing Machine Code (9)

(This is the dialect of turing machine code used by many online turing machine simulators)

0 * 1 r *

It will endlessly ouput ones while moving rightward along the tape.

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

1

Forth, 24 bytes

Defines then calls a word that loops forever, pushing and printing <0> each iteration.

: f begin .s 0 until ; f

Try it online


With a do-loop (25 bytes):

: f 0 0 do 0 .s +loop ; f

Prints <1> 0 forever.

mbomb007

Posted 2013-11-09T01:51:48.960

Reputation: 21 944

I know this is a bit late, but technically the do loop isn't infinite, as eventually the counter will wrap around and reach 0 again (albeit it will possibly take years depending on speed and implementation). Use : f begin .s 0 until ; instead (plus it saves a byte) – reffu – 2018-02-12T14:15:28.463

1@reffu That's actually a byte longer. You have to call the function. – mbomb007 – 2018-02-12T16:33:51.947

good point, I didn't realize this one had slightly different rules than the typical codegolf challenge. – reffu – 2018-02-12T17:07:04.827

1

Mathematica, 34 33 bytes

$IterationLimit=∞;#0@Print@1&[]

If there were no limitation on the maximum length of evaluation chain in Mathematica, #0@Print@1&[] is only 13 bytes, 4 bytes shorter than For[,0<1,Print@1].

alephalpha

Posted 2013-11-09T01:51:48.960

Reputation: 23 988

1

Qt 5.4 QMake pro file, 42 chars

defineReplace(A){log(A)return($$A())}$$A()

Is an infinite loop, but sadly gets caught out by qmake interpreter before it can get very far.

AAAA[...]Ran into infinite recursion (depth > 100).

Not sure if that counts under disqualification.

ForemanBob

Posted 2013-11-09T01:51:48.960

Reputation: 61

1

Self-modifying Brainfuck, 4 bytes

Prints ] forever. Note that the traditional BF programs work as well.

<[.]

The pointer starts one to the right of the source code on the tape, so moving left once puts the pointer at ].

mbomb007

Posted 2013-11-09T01:51:48.960

Reputation: 21 944

1

ArnoldC, 81 bytes

IT'S SHOWTIME
STICK AROUND 1
TALK TO THE HAND 0
CHILL
YOU HAVE BEEN TERMINATED

Prints 0 forever.

Explanation

IT'S SHOWTIME            # start program
STICK AROUND 1           # infinite while loop (since 1!=0)
TALK TO THE HAND 0       # print 0
CHILL                    # end loop
YOU HAVE BEEN TERMINATED # end program

Mama Fun Roll

Posted 2013-11-09T01:51:48.960

Reputation: 7 234

1

PlatyPar, 3 Bytes

1WA

Explanation:

1    ## push 1 to the stack
 W   ## while(stack[-1])
  A  ## alert(stack[-1])

Works the same as my truth machine, except manually inputting the 1 instead of asking for it.

Try it online!

Cyoce

Posted 2013-11-09T01:51:48.960

Reputation: 2 690

1

Detour, 1 bytes

,

Try it online!

, outputs its contents, and passes it on to the next cell (,). In the event of not being given input, a 0 will be passed in.

Cyoce

Posted 2013-11-09T01:51:48.960

Reputation: 2 690

1

BASTARD 30 Bytes

{(., <> {fi out {t 0}(.)})(.)}

This makes use of a few things that are still in question with the spec, but I'm the authour, so what the hell.

Note: BASTARD is still under development, and I haven't finished the spec, or even a rough REPL, so it probably should be disqualified for everything.

Explanation:

  1. Everything has to sit in a {} block.
  2. We define a function called . that takes no arguments.
  3. The function prints an undefined variable from the stack, which equates to 'nil'.
  4. The function also calls itself, thus an infinite loop.
  5. We call the infinite function.

Note: Anonymous functions may or may not be introduced in the future. The current syntax proposed would reduce the above to 24 bytes:

{(<> {fi out {t 0}(@)})}

The only new concept here is @, which is a self-reference to the anonymous function.

s4b3r6

Posted 2013-11-09T01:51:48.960

Reputation: 31

2I suggest deleting this answer temporarily until you have released the language – SuperJedi224 – 2016-03-01T18:03:19.583

1

Quetzalcoatl (non-competing), 14 chars

while 1: ::' '

This is for an older version of Quetzalcoatl.

NoOneIsHere

Posted 2013-11-09T01:51:48.960

Reputation: 1 916

The latest revision of your answers makes it identical to this answer.

– Dennis – 2016-05-06T15:41:19.973

1

Fuzzy Octo Guacamole, 3 bytes (Non-Competing)

(non-competing, FOG is newer than the challenge)

(1)

Infinitely outputs 1.

Due to weird implicit output and recursive loops (it executes the code inside the loop using recursion), 1 is outputted by the implicit output.

Rɪᴋᴇʀ

Posted 2013-11-09T01:51:48.960

Reputation: 7 410

1Since FOG is newer than this challenge, you should state that in your answer. – Dennis – 2016-03-21T03:39:05.383

@Dennis thanks for catching that. – Rɪᴋᴇʀ – 2016-03-21T16:06:07.853

1

Reng v.1.2, 1 byte

Try it here!

n

Pops N and prints N. N is always zero, popping off the empty stack.

Conor O'Brien

Posted 2013-11-09T01:51:48.960

Reputation: 36 228

2If Reng is newer than this challenge, you should state that in your answer. – Dennis – 2016-03-21T03:39:26.133

1

Sonic Pi, 19 Bytes

loop do puts "" end

Sonic Pi is a sound language, but it's also fully a programming language.

Mega Man

Posted 2013-11-09T01:51:48.960

Reputation: 1 379

1What is sonic pi, for those who don't know? – Rɪᴋᴇʀ – 2016-05-06T15:33:55.963

1

Scratch, 3 bytes

Script
(scoring used)
Adds a blank item to list = repeatedly and indefinitely.

weatherman115

Posted 2013-11-09T01:51:48.960

Reputation: 605

2I can't see your script because of a 503 error. I think that using the button to upload an image is better, since it uploads to i.stack.imgur.com. – Erik the Outgolfer – 2016-10-06T18:57:21.233

That's because CubeUpload is down at the moment. – weatherman115 – 2016-10-08T18:05:28.177

Well, can you posts the ScratchBlocks version of the script at least (golfed)? – Erik the Outgolfer – 2016-10-08T18:11:09.707

1

Burlesque - 2 Bytes

bc

basically just creates an infinite list and outputting infinite lists will obviously produce infinite output.

Don't try this in the online shell because some browsers freeze when trying to render the result because it's huge :) (at some point either the browser stops rendering or the webserver closes the stream).

mroman

Posted 2013-11-09T01:51:48.960

Reputation: 1 382

1

Hexagony, 1 byte

This answer is non-competing, as Hexagony is newer than this challenge.

!

Try it online!

Prints an infinite amount of 0s by printing the value of the initial memory edge (which happens to be 0) over and over. The ! is executed in a loop because the source code is toroidal.

Martin Ender

Posted 2013-11-09T01:51:48.960

Reputation: 184 808

1

Woefully, 49 bytes (newer than challenge)

||| |
|| |
| |
|| |
||| |
|||| |
||||| |
|||||| |

Explanation

v     v represents char pointer, instruction pointer finds first space after the char
|||A|                                                      pointed at by char pointer
||A|  A- Push zero
|A|
||B|
|||B| B- Pop and print (number)
||||B|
|||||B|
||||||B|
    [end] End- go back to character char pointer is pointing at. Char pointer has not moved
so it will just execute the same again

Destructible Lemon

Posted 2013-11-09T01:51:48.960

Reputation: 5 908

0

Kitanai, 24 bytes

#print"0"&2&1#print"1"&~

The "#" defines a flag, the first "print" displays 0, then the "&2" jumps to the second "#", it then prints "1", goes to the origin ("&~") which is just after "&2", then it jumps to the first "#" thanks to the "&1". And it does all that infinitely :)

Sygmei

Posted 2013-11-09T01:51:48.960

Reputation: 1 137

0

FALSE, 8 bytes

Interpreter.

There are many programs that work, each 8 bytes. The one I find the most interesting is:

[1$][.]#

This is a while loop (#). [1$] is the condition, and it pushes two 1s. The last is popped for the condition (true), and then [.] is executed, which prints the number.

Here are some other programs (including the above):

[1$][.]#
[1][1.]#
[1$.][]#
[^^.][]#
[^.^][]#
[^][^.]#

A more interesting 9-byte (arbitrary 1-char repeated):

['c$,][]#

I feel that the following 7-byte programs should work on some FALSE interpreters, but I haven't found any such yet:

[1"][]#
[.1][]#

Conor O'Brien

Posted 2013-11-09T01:51:48.960

Reputation: 36 228

0

QBIC, 3 2 bytes

{?

Explanation:

{   Start a DO-loop 
 ?  PRINT nothing, followed by \n
    The DO-loop is implicitly closed by QBIC.

steenbergh

Posted 2013-11-09T01:51:48.960

Reputation: 7 772

0

Haxe, 19 bytes

while(1>0)trace(1);

There are several things about Haxe that make this challenge more difficult than in similar languages:

  1. Its lack of a for(;;) loop
  2. Its unwillingness to consider anything other than true or false truthy or falsy
  3. Its unwillingness to print an empty line (with trace();)

If not for these things, this program might have been 15 bytes:

for(;;)trace();

Test it online here, though you may not want to, as it freezes your browser.

ETHproductions

Posted 2013-11-09T01:51:48.960

Reputation: 47 880

0

Pushy, 3 bytes

(Non-competing as language post-dates challenge)

3[_

Explanation:

3 \ pushes 3 to the stack

[ \ starts an infinite loop

_ \ prints out the contents of the stack

user63571

Posted 2013-11-09T01:51:48.960

Reputation:

[" Infinitely prints newlines (and you need to mark this answer as non-competing) – FlipTack – 2017-01-22T15:55:20.107

0

C++, 23 bytes

main(){for(;;)puts(";");}

I was too lazy, but hey, It outputs a javascript script, which does absolutely nothing!

Matthew Roh

Posted 2013-11-09T01:51:48.960

Reputation: 5 043

This submission is neither a full program nor a function and thus is invalid (since snippets are disallowed). – user41805 – 2017-01-23T16:36:31.550

1Now with FULL program! – Matthew Roh – 2017-01-23T23:40:37.443

0

QC 6 bytes

Not competing because language is newer than the question

A00$00

A00 prints nothing(because memory is empty) and a new line
$00 jump to start(no recursion, sets instruction pointer to 00)

cookie

Posted 2013-11-09T01:51:48.960

Reputation: 271

0

Fith, 16 bytes

{ 1 . q } :: q q

{ 1 . q } pushes to the stack an anonymous function which prints 1 then calls a function named q. :: q binds this function to the word q, then the final q calls the new infinitely-recursing function.

Non-recursive version (19 bytes):

{ 1 } { 1 . } while

This pushes a condition function, which will always push 1, and a body function, which prints 1. The while word continues to run the body as long as the condition leaves a truthy value on top of the stack.

jqblz

Posted 2013-11-09T01:51:48.960

Reputation: 2 062

0

Röda, 12 bytes (non-competing)

{[0]while{}}

This is an anonymous function that prints zeros infinitely.

fergusq

Posted 2013-11-09T01:51:48.960

Reputation: 4 867

0

Whitespace, 16 bytes




	
 	



Try it online!

Saves 3 bytes on the previous Whitespace answer by abusing empty labels and declaring the value 0 as a 0-bit number (the spec unfortunately requires a sign bit). Posting as a new answer as the previous answer combines multiple unrelated entries.

Explanation

(s - space, t - tab, n - newline)

nssn # Declare label ''
sssn # Push +0 onto the stack
tnst # Pop and output the stack value as a number - outputs the character '0'
nsnn # Jump to label ''

Ephphatha

Posted 2013-11-09T01:51:48.960

Reputation: 581

I'm kinda pleased that this answer uses four 4-byte instructions – Ephphatha – 2017-05-27T13:23:57.100

0

shortC, 5 bytes

AWP'1

Prints 1 forever. Explanation:

A     main function
 W    forever
  P   print char
   '1 char '1'

Try it online!

MD XF

Posted 2013-11-09T01:51:48.960

Reputation: 11 605

0

Fission 2, 2 bytes

R"

Try it online!

Same concept as the Befunge answer. An atom is spawned at the R, and moves right. It reaches the " and enters string mode, wraps to the beginning of the line and prints an R, then exits string mode and wraps again.

Outside of string mode, R simply changes the atom's direction to right, which is the direction it's already moving in.

Skidsdev

Posted 2013-11-09T01:51:48.960

Reputation: 9 656

0

Add++, 9 bytes

+1
W,+1,O

Prints 1 Followed by a newline for ever.

Try it online!

caird coinheringaahing

Posted 2013-11-09T01:51:48.960

Reputation: 13 702

0

AHK, 11 bytes

Loop
Send,a

Pretty boring but couldn't find an AHK answer in here and thought it worthy of submission.

Engineer Toast

Posted 2013-11-09T01:51:48.960

Reputation: 5 769

0

Bitwise, 19 bytes

OUT 0 &1
JMP &-2 &1

Prints a load of null bytes. Try it online!

OUT 0 &1 prints the 0th register when a literal 1 is truthy. JMP &-2 &1 jumps back two (one) lines when a literal 1 is truthy.

MD XF

Posted 2013-11-09T01:51:48.960

Reputation: 11 605

0

Evil, 4 bytes

Continuously prints the Start of Heading character:

amwb

If NUL is allowed you could do mwb.

An alternative, that goes through the ASCII characters, would be:

mawb

Quick explanation of commands:

  • m = marking character;
  • a = increment accumulator;
  • w = write accumulator to STDOUT;
  • b = go backwards to marking character and continue execution from there.

XavCo7

Posted 2013-11-09T01:51:48.960

Reputation: 274

0

J-uby, 11 Bytes

-:p|:+&1!~0

Explanation

!~ is iterate until constant: x = f(x) until x == f(x)

-:p is the global print function, and :+&1 increments a number

So -:p|:+&1 prints a number and returns the next integer

We start at 0

Cyoce

Posted 2013-11-09T01:51:48.960

Reputation: 2 690

0

VBA, 18 Bytes

Anonymous VBE immediate window that outputs an infinite quantity of newline characters vbCrLf to the VBE immediate window

Do:DoEvents:?:Loop

Taylor Scott

Posted 2013-11-09T01:51:48.960

Reputation: 6 709

0

VBScript, 23 characters

Do:Wscript.Echo"C":Loop

Needs to be run with cscript.exe for command-line output. If run with wscript.exe (default action), it opens infinite dialog boxes.


Also, here's a shorter (17 character) version which opens boxes regardless of whether it's running using cscript.exe or wscript.exe.

Do:MsgBox"C":Loop

However I'm not sure if that counts too, as it doesn't print anything and just opens dialog boxes indefinetely.

user72779

Posted 2013-11-09T01:51:48.960

Reputation:

0

R, 15 chars (or 6)

repeat print(1)

or, you could cheat slightly with just

repeat

which will invisibly return NULL for each time through the loop. Thus it will return NULL infinite times, you just can't tell.

user5957401

Posted 2013-11-09T01:51:48.960

Reputation: 699

0

Jq 1.5, 9 bytes

repeat(1)

Try it online! (truncated at 128K)

jq170727

Posted 2013-11-09T01:51:48.960

Reputation: 411

0

GW-Basic, 9 bytes (tokenised)

TRON:RUN

This will output [0] until the cows come home. Actually only 3 bytes are actual tokens; here's the full content of the file:

255      unprotected
xxx xxx  offset, recalculated on LOAD
0 0      line number 0
162      TRON
':'      :
138      RUN
0        line terminator

You can often delete trailing zeroes, but this one was required because when GW-Basic starts up, another value is at the memory location where that zero will get loaded, so without it you'd get a syntax error.

Anonymous

Posted 2013-11-09T01:51:48.960

Reputation: 161

0

cQuents 0, 1 byte

$

Try it online!

Outputs 1,2,3,4,5,6... up to Python's int cap (aka as long as you have memory).

Alternately, any number would work, printing that number separated by commas infinitely:

7

Try it online!

This may work at some point with an empty program once I finish this language - theoretically it should print 0,0,0,0,0,0... for an empty program but I haven't implemented empty nodes.

Stephen

Posted 2013-11-09T01:51:48.960

Reputation: 12 293

0

Funky, 13 bytes

for()print(1)

Try it online!

ATaco

Posted 2013-11-09T01:51:48.960

Reputation: 7 898

0

Whispers, 28 bytes

> 1
>> Output 1
>> While 1 2

Try it online!

caird coinheringaahing

Posted 2013-11-09T01:51:48.960

Reputation: 13 702

0

Aceto, 2 bytes

pO
p  prints the top stack element (implicit 0)
O  returns to the origin of the program

Try it online!

alternate version:

nO
n prints a newline, O returns to origin

FantaC

Posted 2013-11-09T01:51:48.960

Reputation: 1 425

0

C, 29 28 26 bytes

main(){for(;;)putchar(0);}

-2 @steadybox

gcc won't like it, but it compiles.

Outputs null bytes continuously. You can swap out the 0 for anything 0-9.

You can use 7 if you really hate your speakers.

SIGSTACKFAULT

Posted 2013-11-09T01:51:48.960

Reputation: 585

26 bytes: main(){for(;;)putchar(0);} – Steadybox – 2017-12-25T01:55:26.627

0

Flipbit, 4 bytes

^[.]

Try it online!

Yay for Bra*nfuck derivatives!

caird coinheringaahing

Posted 2013-11-09T01:51:48.960

Reputation: 13 702

did you just censor the i in brain? – FantaC – 2018-02-12T16:06:44.877

@tfbninja Yes, I did – caird coinheringaahing – 2018-02-12T16:36:00.457

0

PHP, 9 chars

for(;;)a;

Assumes error_reporting includes notices, and you can run it like this:

php -r "for(;;)a;"

The output is the following (repeated until the script is stopped):

PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP Notice:  Use of undefined constant a - assumed 'a' in Command line code on line 1

Note: 11 characters if code is written in a file: <?for(;;)a;

Vlad Preda

Posted 2013-11-09T01:51:48.960

Reputation: 181

3Php is not that bad :) <?for(;;a); 11 chars – tacone – 2013-11-30T22:01:22.033

@primo I do lol – Oliver Ni – 2017-08-06T12:02:33.660

1This assumes not only that E_NOTICE is enabled, but also that display_errors is set to STDOUT - no one in their right mind does this. – primo – 2014-02-02T07:17:14.610

0

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.

user10766

Posted 2013-11-09T01:51:48.960

Reputation:

Assuming you can import anything, import static java.lang.System.out and you can reduce your "actual code" by 7 characters. – Colton – 2013-11-29T19:20:06.313

Also your "for some reason" comment is because print doesn't flush() – Colton – 2013-11-29T19:20:40.677

@Sparkis Oh, thank you. Does that remove the characters from the output stream onto the screen? – None – 2013-11-29T21:44:58.663

2For java, I count everything, including imports, class declaration, and method declaration. – tbodt – 2013-12-13T00:09:39.590

Oh. That would be 87 characters. – None – 2013-12-13T05:44:13.157

Why use println? You should use print instead, and it saves two characters. – Tyzoid – 2014-01-29T03:24:02.217

@Tyzoid If I use print, it does not print the output until the program is stopped because print does not flush(), as the comment says. Either way, I won't win, so it doesn't matter. – None – 2014-01-29T19:31:13.433

2@user2509848 When the buffer gets full it will start to print eventually. It didn't take many seconds for me. – Sylwester – 2014-01-29T22:28:00.360

@user2509848 you could remove the first public and change Test to T cand args to a and you are down to 72. – Sylwester – 2014-01-30T16:43:05.810

@user2509848 72 is without the first public :) – Sylwester – 2014-01-30T23:03:18.853

@Sylwester Oops, sorry. – None – 2014-01-31T17:03:00.677

0

Forked, 1 byte

%

Prints the top of stack (0 if empty). The IP wraps upon hitting the edge of the playing field, looping infinitely.

MD XF

Posted 2013-11-09T01:51:48.960

Reputation: 11 605

0

Wumpus, 2 bytes

OO

Try it online!

Outputs infinite 0s

Funnily enough, even though a single O causes an infinite loop, a new command is only executed once it leaves the current cell, meaning the pointer gets trapped inside the O triangle, bouncing off the walls. Adding another cell (which could be almost any cell that doesn't end the program such as @ or %) allows the pointer to escape and execute the Output instruction again.

Jo King

Posted 2013-11-09T01:51:48.960

Reputation: 38 234

0

Momema, 5 bytes

j0!j1

Try it online! Outputs to STDERR. Requires the -d interpreter flag.

The Momema interpreter has a -d (debug) flag that enables a ! instruction, which outputs some debugging information to STDERR.

Explanation

j  0  #  label j0: jump past label j0 (no-op)
!     #            debug
j  1  #  label j1: jump past label j0 (back to start)

Esolanging Fruit

Posted 2013-11-09T01:51:48.960

Reputation: 13 542

Remember, non-standard flags add to byte count by default – Draconis – 2018-05-18T03:11:24.177

@Draconis Per a five-month old meta consensus they dont.

– Esolanging Fruit – 2018-05-18T03:35:44.453

Ah, my bad! Apologies! – Draconis – 2018-05-18T03:54:44.893

0

axo, 2 bytes

{_

Try it online!

Implicit 0 on top of the stack
{  prints it
_  returns to origin, or 0,0

FantaC

Posted 2013-11-09T01:51:48.960

Reputation: 1 425

0

FALSE, 7 bytes

[^.^]3#

This works in some FALSE interpreters (http://www.quirkster.com/iano/js/false-js.html (Paste the code, click "show", then click "step" a bunch of times (not "run" because it's an infinite loop!))). Outputs an infinite amount of -1s.

Explanation:

Some versions of FALSE are weakly typed, so a normal number can be used as a function pointer.

[^.^] pushes a function to the stack. (specifically, the character in the code that is starts at.) In this case, it pushes the number 0.

3 Pushes the number 3, which when called as a function will start execution at the ] of the previous function (meaning that it skips all the code)

# Is a "while" loop. It pops two functions, then calls the first function (that is, the one which was PUSHED first). It then pops a value from the stack, and if this value is true, it runs the second function and repeats. If the value is false, it continues.

Our function [^.^] will first use ^ to push the next character of STDIN (if input is empty, it pushes -1), then . prints the numerical value (-1), and ^ pushes the next value of input again. This is the value which will be "returned" and used in the loop. Because it is non-zero, the second "function" is called (which is just a number pointing to a location in the code), and the interpreter immediately sees a ], causing it to return from the function.

12Me21

Posted 2013-11-09T01:51:48.960

Reputation: 6 110

0

PHP, 14 bytes

for(;;)echo 0;

try it online

ArtisticPhoenix

Posted 2013-11-09T01:51:48.960

Reputation: 329

0

Quomplex, 6 4

[*1]

Infinitely outputs 1.

Timtech

Posted 2013-11-09T01:51:48.960

Reputation: 12 038

1The link in the title gives a 404 error. – Cyoce – 2016-01-31T19:59:35.513

2Is there an interpreter or compiler for this language? – Sylwester – 2014-01-29T23:09:34.253

0

Stax, 3 bytes

W1P

Run and debug it

Outputs 1 forever. Since Stax terminates when trying to peek or pop an empty stack, I am not sure how to do it in 2 bytes or less.

Weijun Zhou

Posted 2013-11-09T01:51:48.960

Reputation: 3 396

Since W1Q also works and differs in only the final bit, the first 23 bits of this work regardless of the 24th; could it be claimed that this is 2.875 bytes? Is this a dumb question?

– Khuldraeseth na'Barya – 2018-04-06T11:21:50.430

Interesting idea, but I honestly don't know. Sadly W1Q will stack overflow after some time ... – Weijun Zhou – 2018-04-07T00:30:20.947

0

MathGolf, 4 3 bytes

Äo↔

Try it online!

Explanation

Ä     start block of length 1
 o    print TOS without popping
  ↔   do while false without popping

maxb

Posted 2013-11-09T01:51:48.960

Reputation: 5 754

0

ORK, 170 bytes

There is such a thing as a o
A o can i

When a o is to i:
I have a scribe called W
W is to write "!"
I am to loop

When this program starts:
I have a o called O
O is to i

Try it online!

Objects R Kool. Maybe, but they're inconvenient (why can't I just loop the main function?).

JosiahRyanW

Posted 2013-11-09T01:51:48.960

Reputation: 2 600

0

Burlesque - 2 bytes

bc

bc box cycle

Rather boring. bc encloses the top of the stack in a block and then infinitely repeats this block and thus when the value is printed when the program stops it'll obviously never stop producing output.

mroman

Posted 2013-11-09T01:51:48.960

Reputation: 1 382

0

JavaScript + HTML, 56 bytes

(g=_=>requestAnimationFrame(_=>document.writeln(g())))()

guest271314

Posted 2013-11-09T01:51:48.960

Reputation: 1

0

Aheui (esotope), 6 bytes

박망

Try it online!


or simillar codes with same length like following;

반망
받망
...
박맣
...

will produce infinite output.

cobaltp

Posted 2013-11-09T01:51:48.960

Reputation: 401

0

bitch, 3 bytes

>/<

Try it online!


Explanation

>      Begin loop
 /     Print accumulator value (intialised to 0)
  <    Loop back to beginning of loop

Helen

Posted 2013-11-09T01:51:48.960

Reputation: 125

0

Turing Machine But Way Worse, 13 bytes

0 0 1 1 0 1 0

Try it online!

prints chr(128),chr(128+64),chr(128+64+32),...,chr(128+64+...+2+1) infinitely.

No explanation since the code is self-explanatory.

MilkyWay90

Posted 2013-11-09T01:51:48.960

Reputation: 2 264

0

JVM bytecode (OpenJDK asmtools JASM), 194 bytes

enum i {public static Method main:"([Ljava/lang/String;)V" stack 2 locals 1 {l:getstatic java/lang/System.out:"Ljava/io/PrintStream;";ldc 0;invokevirtual java/io/PrintStream.print:(I)V;goto l;}}

Ungolfed

enum i {
    public static Method main:"([Ljava/lang/String;)V" stack 2 locals 1 {
    l:
        getstatic java/lang/System.out:"Ljava/io/PrintStream;";
        ldc 0;
        invokevirtual java/io/PrintStream.print:(I)V;
        goto l;
    }
}

First we get a reference to System.out, then we just invoke void print(int) with zero. Repeat until the heat death of the universe, since this method never returns.

Using enum instead of class saves 1 byte, along with using ldc 0 instead of iconst_0 to save 2 more bytes.

Bonus points for not decompiling correctly in the Fernflower decompiler, no?

Kitten

Posted 2013-11-09T01:51:48.960

Reputation: 161

0

Python: (16 characters)

while 1:print(0)

Merin Nakarmi

Posted 2013-11-09T01:51:48.960

Reputation: 247

2I don't believe you need the parentheses around the 1. while 1:print(0) should work just fine. – Post Rock Garf Hunter – 2019-02-14T20:30:58.213

You can also save a byte on the print by using python 2 – Beefster – 2019-02-14T21:34:49.607

1you don't even need the 0 since python prints a newline – Jo King – 2019-02-14T22:11:48.463

You are right @Joking. New line is invisible output. – Merin Nakarmi – 2019-02-14T22:14:40.643

while 1:print() would print a newline – MilkyWay90 – 2019-03-03T17:45:35.013

0

Tamsin, 15 bytes

main={print 1}.

Try it online!

Esolanging Fruit

Posted 2013-11-09T01:51:48.960

Reputation: 13 542

0

Perl 6, 11 bytes

loop {.say}

Try it online!

bb94

Posted 2013-11-09T01:51:48.960

Reputation: 1 831

0

05AB1E, 2 bytes

Version 1 (3 bytes)

[A,

prints out the alphabet

Version 1 (2 bytes)

[,

Outputs infinite newlines

Try it online!

Jackson

Posted 2013-11-09T01:51:48.960

Reputation: 101

0

q/KDB, 13 chars

while[1;0N!1]

Outputs

1 

forever.

For more information on q/KDB :

Another Solution:

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

nyi

Posted 2013-11-09T01:51:48.960

Reputation: 448

1{1}{0N!1}/1 for 11 – tmartin – 2014-01-30T20:54:02.323

0

Brian & Chuck, 8 bytes

!{?
!{.?

Try it online!

Brian simply restarts Chuck and Chuck sets Brian's instruction pointer to the left end, prints it and restarts Brian.

Produces endless "!!!!!!..."

Dorian

Posted 2013-11-09T01:51:48.960

Reputation: 1 521

0

Brain-Flak, 10 bytes

(()){(())}

Try it online!

I don't know if this counts as a valid answer because Brain-Flak prints the contents of the active stack and this code just fills the stack.

(())    push 1 on stack
{       while top of stack != 0
  (())  push 1 on stack
}

Dorian

Posted 2013-11-09T01:51:48.960

Reputation: 1 521

0

Lua, 18 bytes

::a::print()goto a

Try it online!

Shortest I was able to came up with (beats any loop). Prints newlines forever.

val says Reinstate Monica

Posted 2013-11-09T01:51:48.960

Reputation: 409

0

33, 5 bytes

1a[o]

Explanation:

1a    (Set the accumulator to 1, to allow the loop to continue to run)
  [o] (Print the accumulator, 1, forever)

TheOnlyMrCat

Posted 2013-11-09T01:51:48.960

Reputation: 1 079

0

MarioLANG, 7 bytes

>:<
===

Try it online!

Infinitely prints zeroes; not much else to say about it.

Reinstate Monica

Posted 2013-11-09T01:51:48.960

Reputation: 1 382

0

Element, 5 bytes

!{A`]

This outputs A to the console forever.

TIO

user85052

Posted 2013-11-09T01:51:48.960

Reputation:

0

TeX, 11 bytes

The following results in an infinite amount of Undefined control sequence. errors (if run in batch mode no human interaction needed):

\def~{\[~}~

TeX, 14 bytes

The following creates a PDF with infinite lines each containing a dot (theoretically that is, since the process never terminates, the file isn't finalized so not really created). I've stopped the process after more than 1000000 pages were output. At some point memory wouldn't suffice anymore for this.

\def~{.\par~}~

Skillmon

Posted 2013-11-09T01:51:48.960

Reputation: 431

0

TSQL, 16 17 bytes

l:PRINT'1'GOTO l

WHILE 1=1PRINT'1'

Jan Drozen

Posted 2013-11-09T01:51:48.960

Reputation: 491

0

MarioLANG, 7 bytes

>:<
===

Mario will walk back and forth, printing as he does.

Try it online!

atirit

Posted 2013-11-09T01:51:48.960

Reputation: 217

0

Chinese, 2 bytes

Prints ÿ continuously.

Timtech

Posted 2013-11-09T01:51:48.960

Reputation: 12 038

Isn't that two bytes? – John Dvorak – 2014-01-29T15:54:09.807

@JanDvorak He didn't specify chars or bytes, and chars is default. – Timtech – 2014-01-29T16:08:19.273

5

@Timtech According to the code-golf tag: If you use Unicode, byte count should use UTF-8.

– Sylwester – 2014-01-29T22:14:56.033

@Sylwester Okay – Timtech – 2014-01-29T23:07:33.047

0

C, 25 bytes

main(){while(puts("1"));}

Raghuram

Posted 2013-11-09T01:51:48.960

Reputation: 109

0

Golfscript - 7

{1a}:a~

I'm still learing golfscript, but unless I'm mistaken, this puts 1 on the stack, then starts over?

But apparently, the stack only prints when the program terminates, so perhaps this is better:

{1.p}do

(thanks Dennis)

McKay

Posted 2013-11-09T01:51:48.960

Reputation: 382

Edited as per @Dennis – McKay – 2016-09-07T21:42:33.940

You need a space between 1 and a, otherwise it's a single variable. I suggest using a non-alnum as a variable name {1?}:?+. Also, this doesn't print anything. – John Dvorak – 2014-03-04T05:31:15.367

1This won't work, it will just print a stack level too deep error. Also, the stack is printed when the program finishes, so you have to print explicitly. Example: {1.p}do (7 bytes) @JanDvorak: [A-Za-z]+[0-9]+ is a single token, but [0-9]+[A-Za-z]+ is not. – Dennis – 2014-06-21T18:46:35.707

I would downvote, but my vote is locked in. Help me out! – tbodt – 2014-09-03T21:54:48.403

0

Bash - 13 bytes

cat /dev/zero

to see run cat -v /dev/zero

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

Eduard Florinescu

Posted 2013-11-09T01:51:48.960

Reputation: 1 863

0

Windows PowerShell (12)

for(;;){'-'}

Merin Nakarmi

Posted 2013-11-09T01:51:48.960

Reputation: 247

0

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.
```

user85052

Posted 2013-11-09T01:51:48.960

Reputation:

0

Clojure

(repeat 1)

Returns a lazy seq of 1's '(1 1 1 1 1 1 1 1 1 1 ...)

markw

Posted 2013-11-09T01:51:48.960

Reputation: 47

1it doesn't output anything – cliffroot – 2016-05-23T14:01:30.847

0

Scala REPL (19 characters)

while(true)print(1)

Mikaël Mayer

Posted 2013-11-09T01:51:48.960

Reputation: 1 765

0

PureBasic - 17 chars

r:
Debug 0
Goto r

A slight variation on the classic BASIC infinite loop :-)

Fozzedout

Posted 2013-11-09T01:51:48.960

Reputation: 121

0

JavaScript, 23 characters

while(1)console.log(1);

rahulroy9202

Posted 2013-11-09T01:51:48.960

Reputation: 315

while(1)alert(1); – Timtech – 2014-02-04T16:41:41.813

@Timtech for(;;)alert(1) is even shorter – user2428118 – 2014-11-20T22:14:47.940

@user2428118 Yep, I've known that since then though. I must learn more all the time :) – Timtech – 2014-11-21T12:05:32.973

0

Processing, 26

for(int i=0;i<1;)print(1);

Prints 1 continuously.

The Guy with The Hat

Posted 2013-11-09T01:51:48.960

Reputation: 778

You might also be able to do for(;;) for an infinite loop and then you can add the print(1); – user41805 – 2016-12-02T18:20:54.733

0

Groovy, 14

for(;;)print 1

from the command line: groovy -e "for(;;)print 1"

krs

Posted 2013-11-09T01:51:48.960

Reputation: 160

0

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);}}

Ramasamy Kasiviswanathan

Posted 2013-11-09T01:51:48.960

Reputation: 11

Couldn't you also remove public, since methods are public by default? – mbomb007 – 2015-03-05T01:56:29.147

@mbomb007 public is needed to make the code executable. – user8397947 – 2016-05-28T15:50:07.547

2For 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, perhapsI. Change theString args[]toString[]a. Change theSystem.out.printlntoSystem.out.print`. – Justin – 2014-06-21T19:21:39.203

0

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.

g.carvalho97

Posted 2013-11-09T01:51:48.960

Reputation: 139

Because you this is php, you can just put while(true){print(0);} the <?php ... ?> isn't actually php anyway – addison – 2014-09-01T23:43:54.683

And the php portion of your answer, while(true){print(0);}, is actually 22 characters. – addison – 2014-09-01T23:45:24.660

0

C++ 29

main(){while(1)std::cout<<1;}

bacchusbeale

Posted 2013-11-09T01:51:48.960

Reputation: 1 235

1The 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 – 2014-07-03T23:27:31.920

0

SCALA 18

while(1>0)print(1)

Govind Singh

Posted 2013-11-09T01:51:48.960

Reputation: 111

0

AppleScript:

repeat until 1 < 0
    say "hi"
end repeat

mcgrailm

Posted 2013-11-09T01:51:48.960

Reputation: 101

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 – 2015-10-29T11:14:45.790

Because the question is a [tag:code-golf], could you please include the character count of your code? – ProgramFOX – 2014-07-11T18:29:50.987

I'm sorry, I'm new to this :) does that include , returns , spaces and tabs ? – mcgrailm – 2014-07-11T18:39:17.350

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 – 2014-07-20T08:29:35.697

0

Groovy - 15 chars

for(;;)print 1

Michael Easter

Posted 2013-11-09T01:51:48.960

Reputation: 585

0

Clojure - 18 15 chars

(while 1(pr 1))

Michael Easter

Posted 2013-11-09T01:51:48.960

Reputation: 585

0

CoffeeScript, 14

Pretty unoriginal and similar to JavaScript:

alert 6while 1

rink.attendant.6

Posted 2013-11-09T01:51:48.960

Reputation: 2 776

There is a loop keyword, this could be shortened down to loop alert 1 – eosterberg – 2015-04-11T16:03:06.433

0

GoLunar, 4 bytes

This is the equivalent of 5543 zeros in a row in Unary, which is equivalent to +[.] in BrainF***.

5543

mbomb007

Posted 2013-11-09T01:51:48.960

Reputation: 21 944

0

I haven't seen Thue used here much, so here we go:

Thue (22 19 bytes)

a::=ab
b::=~1
::=
a

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

0

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

M L

Posted 2013-11-09T01:51:48.960

Reputation: 2 865

0

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"

Qwertiy

Posted 2013-11-09T01:51:48.960

Reputation: 2 697

This is dependent to where you have stored the file, but it will always output. This is an example output. – Erik the Outgolfer – 2016-10-06T19:02:43.903

@EriktheGolfer, yes. – Qwertiy – 2016-10-06T21:34:01.160

0

><> Fish - 2 characters, I'm counting the shortest one.

Thijs beat me to it, but oh well. Here are a couple more ><> answers.

1n
-Infinite 1's, 2 bytes

   >"drlow ,olleH"l  
                  ?  
                  !  
   ^              <  
                  o  

-Infinite "Hello, world", 84 bytes.

Edit: Whoops. It's character count, not bytecount. I also fixed the first answer. Edit 2: Thanks mbomb007 for shaving off 1 character.

DJgamer98

Posted 2013-11-09T01:51:48.960

Reputation: 594

Why not just use 1n? – mbomb007 – 2015-10-15T15:46:20.300

@mbomb007 Whoops, forgot that I could do that. – DJgamer98 – 2015-10-15T15:49:05.750

"n also works. – mbomb007 – 2015-10-15T16:01:29.470

0

BotEngine, 1x3=3

Noncompeting as BotEngine is much too recent a language. Anyway, here we go:

>CT

It starts with a right-moving bot on the >. When it reaches the C, it creates a left-moving bot (which starts on the C.) On the next step, the left-moving bot reaches the > and is turned around to move right and the right-moving bot reaches the T, destroying itself and printing TRUE. The step after that, the other bot gets to the C starting the process over again.

>CF also works but prints FALSE instead of TRUE. Using P in this case would print empty lines instead.

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

0

Javascript ES6, 28 bytes

setInterval`console.log()`

I didn't want to code an infinite for loop like everyone else...

Try it here using anything BUT Firefox.

Mama Fun Roll

Posted 2013-11-09T01:51:48.960

Reputation: 7 234

0

Mouse-2002, 3 bytes

(0!)

prints 0 forever.


Alternatively, for a more interesting and (theoretically) infinite error with no loop, the Ackermann Function in 99 bytes in this language:

"M>"?a:"N>"?b:#Y,a.b.;$Y1%n:2%m:m.0=k:n.0=j:j.k.>[n.1+!|j.k.<[#Y,m.1-,1;!|#Y,m.1-,#Y,n.,n.1-;;!]]]@

Expanded:

"M>" ? a:
"N>" ? b:

1 a:
1 b:

#Y, a. b.;!

$Y 1% n: 2% m: ~ ack
  m. 0 = k: ~ store whether m == 0 in k
  n. 0 = j:
  j. k. > [ ~ if y>x
    n.1+ ~ print it
  | j. k. < [ ~ if x>y
    #Y, m. 1-, 1;
  | #Y, m. 1-, #Y, m.,n. 1-;;!
    ]
   ]
  ]
@
$

Errors recursively, forever, as long as the input was a positive nonzero integer. (result of a bug in the interpreter: the code is correct!)

cat

Posted 2013-11-09T01:51:48.960

Reputation: 4 989

0

, 4 chars / 7 bytes

↻ô1;

Try it here (Firefox only).

Translates to while(output(1)); in JS.

Mama Fun Roll

Posted 2013-11-09T01:51:48.960

Reputation: 7 234

output isn't a JS function... – mbomb007 – 2018-04-26T14:07:05.973

There isn't really an equivalent to that function in JS, I guess I made it a placeholder name for the custom output function that ESMin uses. – Mama Fun Roll – 2018-04-30T14:11:15.770

console.log would work – mbomb007 – 2018-04-30T14:51:44.877

The function doesn't output by lines, but rather appends to output... Perhaps it's more like a process.stdout.write. – Mama Fun Roll – 2018-04-30T20:08:12.937

0

R, 15 bytes

Infinitely prints 1

while(T)cat(1)

Argenis García

Posted 2013-11-09T01:51:48.960

Reputation: 223

0

Pyth, 4 bytes (Non-competing)

Pyth is a new programming lenguage, so this answer doesn't count.

.V"0

Explanation:
.V   - Forever loop
  "0 - Outputs zeros

AlexINF

Posted 2013-11-09T01:51:48.960

Reputation: 181

You should add a note to your title saying this is non-competing because the language is newer than the question. Also this can be golfed to #0 – Blue – 2016-02-20T12:56:08.207

0

ForceLang, 23 bytes

label l
io.write goto l

Looks weird, but it works. The key here is that goto does not interrupt the evaluation of the current line, and returns nil.

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

0

Pylons, 5

wp,1}

While 1, print the (empty) stack.

Morgan Thrapp

Posted 2013-11-09T01:51:48.960

Reputation: 3 574

0

Come Here, 21 bytes

COME FROM1 1TELL1NEXT

In the reference implementation, this prints infinitely many smiley characters. Don't ask me why.

SuperJedi224

Posted 2013-11-09T01:51:48.960

Reputation: 11 342

The smiley characters are printed because you are using Windows cmd. – Erik the Outgolfer – 2016-10-06T18:58:45.920

0

Clojure, 14 bytes

(pr(cycle[1]))

mark

Posted 2013-11-09T01:51:48.960

Reputation: 251

0

Brainfuck, 26 bytes

++++[>++++<-]>[>++<-]>+[.]

Do 4*4*2+1 (33, !) and the final loop is a infinite loop that only print the current memory cell (!).

TuxCrafting

Posted 2013-11-09T01:51:48.960

Reputation: 4 547

You could as well do +[.] (SOH), but then it would be a dupe. – Erik the Outgolfer – 2016-10-08T18:12:20.063

0

Haystack, 6 bytes (non-competing, the language came 2 years after the challenge)

>"a"o<

This will print a [infinity] times.

If the above code gives a syntax error because of the lack of | (that character is the needle. The ultimate goal of all Haystack programs is to find the needle in the haystack), one can simply append it to the end:

>"a"o<|

user8397947

Posted 2013-11-09T01:51:48.960

Reputation: 1 242

0

Ruby, 10 bytes

loop{puts}

This program prints out an infinite stream of newlines.

dkudriavtsev

Posted 2013-11-09T01:51:48.960

Reputation: 5 781

-2

C# (72)

using System; class P {static void Main(){for(;;) Console.Write('-');}}

Output enter image description here

Merin Nakarmi

Posted 2013-11-09T01:51:48.960

Reputation: 247

3I have no idea how to code in C# but I can still golf this" class P{static void main{for(;;) Console.Write(0);}} – MilkyWay90 – 2019-02-13T01:52:37.190

7This can easily be shortened to: class P{static void Main(){for(;;System.Console.Write(1));}} (60); if you insist on - to be outputted it would be 62 (replacing 1 with "1"). – RobIII – 2014-05-02T12:31:51.267