Most versions of The Operating System Beginning with "W" utilise crash protection to prevent most infinite loops from being executed in full: The machine is likely to crash in a few hours' time, so the loop isn't infinite!

Examples below in C; other languages may vary or have weird alternative syntactic sugars (until) but in the end it will be a variation on one of the following four.

iterative

  • for(;;);
  • while(1);
recursive
  • void main() {main()}
  • a: goto a;
These last two are not recommended as in C (and a lot of other languages) they are not truly infinite; each function call requires a new entry on the stack, and each usage of goto (in C) "remember"s its previous location in memory. Thus either of the following, if run indefinitely, will eventually run out of memory and crash. If you must use one of these two, go with the first one, because structured programming kicks ass. There are, of course, languages where the behavior in examples 3 and 4 are normal; LISP and Scheme are able to handle and in fact encourage indefinite tail recursion loops, and Assembly and some forms of BASIC expect you to use simple goto jumps. In fact, in Scheme, the recursive infinite loop is the *only* kind.

I beg to differ: GOTO is not GOSUB. As every Commodore64 user knows, the amazing piece of code
10 PRINT "FOO BAR BAZ ARE MY BEST BUDDIES"
20 GOTO 10
can spin for days and days without any problem.

In other words, GOTO does not remember where it is coming from, uses no stack, and is just the right thing for coding infinite loops.

More to the point, notice that infinite loop has acquired a negative connotation, even if in fact there are systems where you really want the loop to be infinite; for example a telephone switch should just loop and loop.

Infinite Loop is also a street in Cupertino. It is the home of Apple Computers headquarters

infinite = I = Infinite-Monkey Theorem

infinite loop n.

One that never terminates (that is, the machine spins or buzzes forever and goes catatonic). There is a standard joke that has been made about each generation's exemplar of the ultra-fast machine: "The Cray-3 is so fast it can execute an infinite loop in under 2 seconds!"

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

An infinite loop is the result of a recursive function with no ending condition. That is, a function which calls itself over and over again. To better understand, read more on infinite loops.

OK, I'll state right now that I'm no good at reviewing novels. This will contain spoilers, and for all I know, it may even miss the point. Even the few novels I do read are usually science fiction, not romance, so I won't make any comparisons to other romance novels. The reason I feel compelled to write about Infinite Loop despite not being very qualified to do so is that it is clearly a small run print. It would be a shame for it to never be discovered by a wider audience.

Infinite Loop is a romantic lesbian novel. The blurb on the back of the book describes it as "more than an erotic road novel," but even that statement seems to over-emphasise the erotic parts of the story.

What made me notice the book in the first place was that it was about a geek girl. The protagonist, Regan O'Riley, appears to be at least somewhat based on the book's author, Meghan O'Brien. I consider this a good thing, as it's about time that a geeky character was actually in a story written by a geek. Regan doesn't grow out of being a geek to become a "normal" person like the geeky characters in too many Hollywood movies. She programs computers, wears Thinkgeek t-shirts, watches films like The Princess Bride and beats guys at video games.

The conversation Regan and Mel have about how midi-chlorians ruined the Force as an analogy for realising your own potential in the Star Wars prequels is as good as any dialogue written by Kevin Smith. Just in case you still weren't convinced of the geek authenticity, the book even gets its title from the protagonist's own use of a programming error as an analogy for how people too easily get stuck in the same daily routine for the rest of their lives.

Unlike a lot of romantic stories, the conflicts in this novel don't arise from the protagonist's problem attaining love. Instead, she falls in love and keeps it quite easily, and together, Regan and her lover conquer their fears and their pasts, to build a happier future together. They're always there to help each other, and together, they can overcome anything.

There's a scene in this novel that had me rooting for Regan just as much as the comparable one in the film Hackers made me cringe: some sexist guys are hogging an arcade game, and she ends up challenging them. This is from her point of view, though, and when those boys insinuate women can't play arcade games properly, and the story flashes back to how kids picked on Regan in school, it really got me emotionally invested in her playing the game.

The story is also about Regan's new-found lover, Mel. It's terrifying to watch her confront the father who disowned her, and the scene where she's reunited with her estranged brother had me on the verge of tears for several pages.

Sure, there's quite a few novels and films that present lesbians in a positive light, but this one presents a geek lesbian as someone who's happy that way. I just hope more fiction will be written by, and about, geek girls.

Of course, the erotic parts aren't bad either.

Quam's really long list of infinite loops in many languages

Horrible. Awful! Thousands of programming languages, and you guys only come up with infinite loops in two? Not to mention that we don't even get a whole C program! You think we can just dredge up that #include<stdio.h> int main(int argc, char** argv){} stuff from memory? Really, really unfit behavior.

Well, here's the list. The real list. Infinite loops in every language I deem significant. I plan to eventually include examples in erlang, bc, bash, Mumps, xBase, SQL (some dialect), lua, Javascript, assembler (probably MIX), Tcl, OCaml, Pascal/Delphi and whatever else looks good.

If you're already thinking of this as a waste of time, think of it not as a dictionary of totally useless programs but as a series of fetal Operating Systems.

Operating environment will be Ubuntu. I'll provide install and build instructions where necessary. Feel free to send in more, especially in unrepresented languages. The list will is categorized by programming language, and each may have multiple programs with explanatory titles.

Keep in mind that some of these programs will eventually fill all memory and swap. Don't run them if you don't know how to stop them. Anything that loops or recurses infinitely gets in. Solutions that quickly blow up the stack and die will be pointed out with the words "Stack Overflow" in the title. I will not venture guesses on ones that do not die within a few second; some of them may use constant space, and some may not store stack on the Unix stack area.

And remember, you brought this on yourselves. Basic and C. Christwagons.

 

Ada

Installation: Install package 'gnat'

Run: Put program in loop_forever.adb, run "gnatmake loop_forever", run loop_forever

One: What do you mean "Statement Expected"?

procedure Loop_Forever is
X : Integer := 0;
begin
loop
X := 0;
end loop;
end Loop_Forever;

Two: The compiler warned me this would happen. (stack overflow)

procedure Loop_Forever is
begin
Loop_Forever;
end Loop_Forever;

Arc

Installation: Install package 'mzscheme'; go to http://arclanguage.org/install and follow instructions

Run: See installation instructions for REPL

One: On a Horse With No Name

([_ _] [_ _])

Awk

Run with awk -- 'program text'

One and only: While

BEGIN { while(1){} }

Befunge

Sorry, this is rumor and conjecture for now.

One: Left and right

><

Two: Just left

<

COBOL

Installation: install package libncurses-dev and opencobol

Usage: cobc program.cob, run program

One: I hold E.W. Djikstra fully responsible

       IDENTIFICATION DIVISION.
PROGRAM-ID. InfiniteLoop.
PROCEDURE DIVISION.
PERFORM UNTIL 1 < 0
END-PERFORM
STOP RUN.

Common Lisp

Installation: Install package 'cmucl'

Use: "cmucl -eval 'program'" or "cmucl" and enter program at REPL

One: Loop

(loop)

Two: Do (stack overflow)

(do ()(nil))

Three: Infinite format control string loop (I'm not kidding about this)

(format t "~{~^~}" '(1))

Four: Recursively called format control string (I'm certainly not kidding about this but stack overflow)

(format t "~@{~}" "~:*~@{~}" 1)

dc

Usage: dc program.dc

One: Alonzo Church would be angered (stack overflow)

[dx]dx

Two: Recursively called macro (Stack overflow)

1[dd=x]dsxx

Emacs Lisp

Usage: Run emacs, enter program text and evaluate each line with Ctrl-j

One: Totally not copied from the Common Lisp section

(require 'cl)
(loop)

Two: Whiltey?

(while 't)

Fortran and Fortran 95

(Thanks to RPGeek who came in the middle of the night and chased off the ghost of Alonzo Church with a stick before giving me these)

Installation: install gfortran package

Run: Run command 'gfortran program.f90' - file extension is important

One: Good old fashioned Fortran

      program InfiniteLoop
100 goto 100
end program InfiniteLoop

Two: Newfangled and clearly not hardcore Fortran 95

program InfiniteLoop
do

end do
end program InfiniteLoop

Three: I'm guessing Fortran doesn't have anonymous recursive functions, so... (Stack overflow)

recursive subroutine infinity
call infinity
end subroutine infinity

program RecursiveLoop
call infinity
end program RecursiveLoop

Haskell

(A dozen or so thanks to Resiak who painstakingly crafted these)

Installation: Install package ghc

Run: Run 'ghc program.hs' then run a.out or program, whichever comes out >:|

One: The main... uh... example.

main = main

Two: Haskell people have the longest

main = do print (length [0..])

m4

Usage: m4 program.m4

One: Why does m4 have them funny slanty quotes

define(`_',`_')dnl
_

Two: The egg came first; this is just an optimization

define(`chicken',`egg')dnl
define(`egg',`chicken')dnl
chicken

Perl

Installation: Already installed

Use: perl program.pl or perl -e 'program text'

One: Redo

{redo}

Two: While

0while(1)

Three: For

for(;;){}

Four: The Ghost Of Alonzo Church is going to kill me for this (stack overflow)

&{sub{&{$_0}($_0)}}(sub{&{$_0}($_0)})

Five: Like four, but with a fixed point like a normal people use

sub f { f() }
f()

Six: Objects make everything better! Seriously.

{
package Recursor;
sub new { bless {}, shift } # Subclassable!
sub recurse_forever {
my $class = ref(shift); # Get my own class (subclassable!)
$class->new->recurse_forever;
}
}

Recursor->new->recurse_forever;

Seven: Even goto is shorter in perl

a: goto a

Python

Run with python program.py

One: This may be the only time you will ever notice the subtle problems with significant whitespace

while 1:
pass

Two: Plain recursive (Stack overflow)

def f():
f()
f()

Three: Alonzo Church is still going to kill me for the Perl one (Stack overflow)

(lambda x: x(x))(lambda x: x(x))

Ruby

Installation: Install package 'irb'

Use: Run ruby program.rb

One: Loop

loop {}

Two: Recursive (stack overflow)

def f();f;end
f()

Three: Why the Lucky Stiff and Alan Kay will both find and kill me (stack overflow)

Class C; def f;C.new.f;end;end
C.new.f

Four: Guy Steele will find me and make me read the Fortress spec (stack overflow)

f = nil
callcc { |x| f = x }
f.call()

Scheme

Installation: Install package 'mzscheme'

Run: Are you actually running all of these? What a rube. I mean, they work, but still.

One: Maybe Alonzo Church will forgive me if I act fast

((lambda (x) (x x)) (lambda (x) (x x)))

Two: Recursive, fixed-point

(define (f) (f))
(f)

Three: With some kind of actual loop syntax

(let loop () (loop))

Four: With call/cc, bane of human understanding

(let ((f '())) (call-with-current-continuation (lambda (x) (set! f x))) (f))

Sed

Run with sed -f program.sed and then give at least one line of input before closing input with Ctrl-D

One: GB2:B

: b
b b

Smalltalk

Install: Install package squeak

Run: Uh, run Squeak with the image, open the Tools tab, click and drag out a "Workspace", type program text into it, middle-click and click "do it"

One: Yes indeeeed!

true whileTrue

Whitespace

Installation: Screw you, man. I'm tired.

Run: Far and fast. You don't want in on this shit.

One: One.

   




End of List

Well, there you have it, folks. There's the rundown.

You didn't think I was gonna use some pansy language like Java, did you?

Log in or register to write something here or to contact authors.