g | x | w | all
Bytes Lang Time Link
027Scratch 3.0 + Pen extension250105T181203Zmadeforl
030Commodore BASIC C64 used under emulation250102T172109ZShaun Be
nan121209T232723ZOrab
102jbasher2241213T165304Zmadeforl
028Perl 5241211T225354ZXcali
032Raku Perl 6 rakudo241101T210229Zxrs
021punchcode241210T173527Zmadeforl
041BrainChild241111T052310ZATaco
009Japt190721T203208ZShaggy
040atto241102T175030ZEurope20
nani try create using css style121211T034752Zhendra
026Thue240619T114029ZNone1
049Fortran GFortran240618T160752Zroblogic
067F# .NET Core240409T060057Zdtanku
016YASEPL240402T173522Zmadeforl
009Pip240402T014327Zlyxal
015Uiua240328T221140Znoodle p
047Swift240401T164322ZmacOSist
012Easyfuck240328T233103ZQuadrupl
040TIBasic240329T015821ZYouserna
066Python220929T133031ZJoao-3
036Mathematica 36 Bytes220929T173538Zydd
nan220929T152410Zbigyihsu
nan220929T153759Zbigyihsu
027Yabasic180322T191033ZTaylor R
051Python 3220702T220050Zayreguit
049Lua 5.4220828T174327Zc--
051Python 3211230T224027Zquintopi
007Befunge171128T220030ZJo King
033Factor + qw210811T162117Zchunes
047C gcc210811T040012ZM Virts
186HTML+JS210713T153725ZKamil Ki
019Add++210503T200256Zcaird co
005Vyxal210315T102647Zlyxal
012BRASCA210315T085105ZSjoerdPe
033AppleSoft BASIC210315T081324Zroblogic
005Jelly210315T081347ZUnrelate
042Zsh210315T072145Zroblogic
012Keg190729T042804Zuser8505
034Clojure190728T195036ZNikoNyrh
054JavaScript Node.js180321T202147Z1024x2
033R190725T093802ZFlounder
061Python190725T073813ZEdgyNerd
010Cubix190724T224527ZMickyT
012><>190724T212507ZConor O&
013Runic Enchantments190722T145751ZDraco18s
012APL Dyalog Unicode190722T133318ZJ. Sall&
008MathGolf190722T125210Zmaxb
053Java 8161004T133416ZKevin Cr
036PowerShell190720T093344Zmekb
020SmileBASIC180321T185709Z12Me21
018q/kdb+180202T222147Zmkst
031PHP171128T095057ZTitus
012Cubix171130T205156ZFlipTack
024Add++171130T194354Zcaird co
009Pyth 12171128T203230ZTornado5
007Befunge98 PyFunge171128T222854ZMercyBea
023Perl 6171128T221401ZSean
00705AB1E171128T101253Zscottine
053Tcl171127T190743Zsergiol
012Fission171127T180138ZKSmarts
01016bit x86 assembly code171126T212630Zpeter fe
014><>161004T141410ZAaron
037Powershell161004T140845Zwhatever
033Common Lisp161004T131443Zcoredump
157Mathematica121208T155656ZDavidC
068Python130108T022248Zboothby
068Common Lisp130104T223707ZMatthew
534Brainfuck130103T232233Zcaptncra
045C++121212T195359ZBrandorf
023ruby121212T171308Zsteensla
3938C121212T183829ZJoeFish
nan121208T151043Zprimo
nanprint has a return value of 1121208T211834Zhistocra
nan121207T162906Zrambo co
nanchopped off one character121207T162811ZKaroly H
nan121207T162756ZMichael
nan121207T162428ZNaftali

Scratch 3.0 + Pen extension, 28 27 blocks

just clarifying: this is a non-competing answer

enter image description here

check it out here (scratch website)

-1 block thanks to WeirdGlyphs

Commodore BASIC (C64 used under emulation), approximately 30 tokenised BASIC bytes

0PRINTMID$("/\",1+RND(.)*2,1);:RUN

When listing, the Commodore BASIC interpreter automatically adds in a space after the line number (as in the screen shot). For a less random but equally beautiful pattern, you may remove the third parameter from the MID$ argument, as follows (saving two tokens):

0PRINTMID$("/\",1+RND(.)*2);:RUN

and for a slightly more performant program, change the RUN to GOTO - this is one extra character, but no extra BASIC bytes, and as this is a one-liner, and we're using line zero we don't need to say which line we are going to (unless you are using Commodore BASIC 7 on the Commodore C128).

Commodore C64 using the "10 PRINT" popular one line program

Perl

perl -pe '$_="~"ge$_?"/":"\\"' </dev/urandom

jbasher2, 102 bytes

while 1 < 2
spawn random number between 0 and 1
get item from "\/" at that
output inline that
endwhile

very self explanatory LOL.

Perl 5, 28 bytes

1while print.5>rand?'/':'\\'

Try it online!

Raku (Perl 6) (rakudo), 32 bytes

loop {printf rand>.5??"\\"!!"/"}

Attempt This Online!

AWK, 38 bytes

END{for(;;)printf(rand()>.5?"/":"\\")}

Try it online!

punchcode, 21 bytes

hexdump:

00000000: 1D 01 2D 01 2F 01 0B 01 01 1D 03 04 19 06 01 04  | ..-./...........
00000010: 02 21 02 03 0D                                   | .!...

uncompiled:

-START  |
---OOO-O|
-------O|
--O-OO-O|
-------O|
--O-OOOO|
-------O|
----O-OO|
-------O|
-------O|
---OOO-O|
------OO|
-----O--|
---OO--O|
-----OO-|
-------O|
-----O--|
------O-|
--O----O|
------O-|
------OO|
----OO-O|

BrainChild, 41 bytes

include*;while 1putchar(47+45*(rand()%2))

Slightly Cleaned

include rand.bc;
while(1){
    putchar(47+45*(rand()%2))
}

Try It Online!

Japt, 9 bytes

Assumes an infinite stack.

ßOo"/\\"ö

Test it

ßOo"/\\"ö
ß             :Recursive call with (irrelevant) argument
 Oo           :  Explicit output (returns undefined)
   "/\\"      :    Literal string
        ö     :    Get random character

atto, 40 bytes

1printchr$(47+round(random)*45);
2goto 1

Try it here! Use Esc to terminate.

i try create using css style, and it's work

    <style>
      body {
        font-family: monospace;
        line-height:75%;
        letter-spacing:-3px;
      }
    </style>

this php code :

    <?php
      $i=10000;
      while($i) {
        if($i%200 == 0) echo '<br/>';
        echo chr(47 + 45 * rand(0,1));
        $i--;
      }
    ?>

Thue, 26 bytes

a::=ab
b::=~\
b::=~/
::=
a

Try it online!

Makes use of Thue's nondeterminism.

There are three rules, thr first replaces a to ab, the second and third removes a b and prints a / and . The second and third rules have equal probability to be run.

For some reason this program doesn't work on TIO, so the TIO link is link to the Thue Python interpreter with the input set to the Thue program.

Output: output

Fortran (GFortran), 49 bytes

2 call fput(char(47+45*int(2*rand(0))));goto2
end

Try it online!

F# (.NET Core), 6967 bytes

let r=System.Random()
while 1=1 do printf$"{char(92-r.Next(2)*45)}"

A console window shows the correct output. In the background, Visual Studio 2022 displays the submitted code.

Try it online: This code is not fully golfed - interpolated strings are a new(-ish) feature to .NET that TiO doesn't support.

YASEPL, 16 bytes

=a¢0,1*45+47›?1

explanation:

=a¢0,1*45+47›?1          packed
=a¢0,1                   create a random number between 0 and 1
      *45                times it by 45
         +47             add 47 
            ›            print it out in char form (without a newline)
             ?1          loop back to the first instruction

Pip, 9 bytes

W1ORC"\/"

Attempt This Online!

There's an orc in my code!

Explained

W1ORC"\/"­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌­
W1         # ‎⁡Forever:
  O        # ‎⁢  Print
   RC"\/"  # ‎⁣  A random character from "\/" 
💎

Created with the help of Luminespire.

Uiua, 15 bytes

⍢(&pf⊡⁅⚂"\\/")1

This goes in an infinite loop, so to try this without having your browser hang, first go to the Uiua pad, click the settings icon, and change "Exec limit" to a low number like 0.5 seconds. Then paste this code in and click Run.

Explanation: ⊡⁅⚂"\\/" gets a random number between 0 and 1, rounds it to the nearest integer, and picks either \ or / based on that. &pf prints that character without a newline. ⍢(…)1 is do … while 1.

I've found a couple other 15 byte solutions:

Swift, 47 bytes

import Darwin
while putchar(rand()%2*45+47)>0{}

This version is macOS-only; replace Darwin with Glibc if you're on Linux (this actually saves a byte). If you're in doubt, Foundation works on most platforms that support Swift.

This is pretty much the most direct port of the C answers you can get.

Easyfuck, 13 12 bytes

ImúUt␗J»␀␒ű€

Decompressed:

$[?%+P.J]@␂/\

How?

$[?%+P.J]@␂/\

$             copy 1st cell into storage
 [      ]     while loop
  ?%+         set 1st cell to 1 or 2
     P.J      move pointer by signed value of 1st cell, print, move pointer to 1st cell
         @    beginning of initializer data
          ␂/\ initializer data (2, 47, 92)
```

TI-Basic, 40 bytes

For(I,1,8
For(J,1,16
Output(I,J,sub("/\",randInt(1,2),1
End
End

Outputs to the entire home screen for monochrome TI-83/84-series calculators. For the color calculators, replace 8 and 16 with 10 and 26 respectively, for +1 byte.

Python, 66 bytes

import random
while 1:print(chr(47+random.randint(0,1)*45),end='')

Try it online!

Ungolfed:

import random
while True:
    slash_calc = 47 + random.randint(0, 1) * 45
    print(chr(slash_calc), end='')

Mathematica - 36 Bytes

Barebones with no formatting. I don't know why the slashes are different thickness

Grid@RandomChoice[{"/","\\"},5{8,5}]

enter image description here

Go, 78 bytes (fixed seed)

package main
import."math/rand"
func main(){for{print(string(`/\`[Intn(2)]))}}

Attempt This Online!

Prints to STDERR.

Random seed, 107 bytes

package main
import(."math/rand";."time")
func main(){Seed(Now().Unix())
for{print(string(`/\`[Intn(2)]))}}

Attempt This Online!

Also prints to STDERR.

Rust, 143 bytes, std only

use std::hash::*;fn main(){loop{print!("{}",b"/\\"[std::collections::hash_map::RandomState::new().build_hasher().finish()as usize%2]as char);}}

Attempt This Online!

This mess is because the Rust stdlib (at the time of writing) has no "proper" RNG API. So, I had to use the workaround described here to get a random number.

Yabasic, 27 bytes

-1 byte thanks to @ayreguitar

Mid$("\/",...) is used over Chr$() as the character codes for / and \ are 47 and 92, respectively.

While the GoTo structure of the original could easily be used for this answer, Do...Loop ends up being shorter due to the the structure of the Mid$ call.

Do?Mid$("\/",Ran(3),1);Loop

Try it online!

Python 3, 59 51 bytes

Using only 1 line (in the spirit of the original 10 PRINT):

from random import*;exec("while 1:print(end=choice('\/'))")

while 1:from random import*;print(end=choice('\/'))

Or (possibly not that random) using hash for just 47 bytes (but on 2 lines):

x=0
while 1:x=hash(str(x));print(end='\/'[x%2])

Try it online!

Lua 5.4, 49 bytes

::a::io.write(2>math.random(2)and"\\"or"/")goto a

Try it online!

Python 3, 52 51 bytes

from random import*
while 1:print(end=choice('\/'))

Try it online!

Saves at least 9 bytes over other python solutions here.

Edit: saved a byte via ayreguitar's comment

Befunge, 12 9 8 7 Bytes

Edit: James Holderness figured out an insane solution that uses three quotes instead.

?\","/"

Overflows the stack with a lot of excess characters for each symbol, but who cares when you can golf that 1 byte?

Old version

"/\"?>,#

(Note the trailing space) Trailing space apparently not needed (thanks MercyBeaucou)

Try It Online

"/\" Adds both / and \ to the stack
    ? Chooses a random direction to go in. Both up and down loop back around to the ? so it's 50% chance to go in either direction.
Going left
"/\"  >,#  Adds \ and / to the stack but only print the second, the / before heading back
Going right
      >,# Prints the top of the stack, the \ before heading back

This does start to fill up the stack, with one extra symbol for every symbol printed.

Factor + qw, 33 bytes

[ qw{ / \ } random write t ] loop

Try it online!

C (gcc), 47 bytes

main(){while(putchar(47+45*(rand()/(1<<30))));}

Try it online!

HTML+JS, 186

<pre style="letter-spacing:-3.5px;line-height:9px;;white-space: pre-wrap;line-break: anywhere;" onclick="setInterval(_=>this.innerHTML+='/\\'[2*Math.random()|0])">C l i c k   m e !</pre>

Add++, 19 bytes

D,f,,"\/"BX
Dx,$f,o

Try it online!

How it works

D,f,,    ; Define a function, f
    "\/" ; Push "\/"
    BX   ; Random choice

Dx,      ; Do, while x:
   $f,   ; Set x to the result of f
   o     ; Output with no newline

Vyxal, 5 bytes

{k/℅₴

No trying it online

It was a smart choice adding all of the two byte constants of 05ab1e and Jelly.

BRASCA, 13 12 bytes

1[`/\`1?#$o]

Try it online!

Explanation

1[         ]  - While 1:
  `/\`       -   Push \ and /
      1?      -   Push rand(0,1)
        #$    -   If truthy, swap the top two items, else skip.
          o   -   Print it!

AppleSoft BASIC, 33 bytes

33 bytes, verified here

1?MID$("\/",RND(1)+1.5,1);:GOTO1

35 bytes, using CHR$ conversion similar to C64.

1?chr$(47+45*int(2*rnd(1)));:goto1

Jelly, 5 bytes

Ø^XȮß

Try it online!

XØ^ß is a byte shorter, but prints a 0 before the slashes.

  X      Choose a random element from
Ø^       "/\",
   Ȯ     print it,
    ß    then call this link again.

Zsh, 42 bytes

for ((;;))printf ${(#)$((RANDOM%2?47:92))}

try it online

Keg, 12 bytes

You do not have to worry about the evenness 0f the output, because the range is 0 to 32767, and 32767+1 = 32768; it is an even number.

{~2%[\\|\/],

Clojure, 34 bytes

(loop[](pr(rand-nth"\\/"))(recur))

JavaScript (Node.js), 59 55 54 bytes

Original Answer

while(1){process.stdout.write(Math.random()>=0.5?"/":"\\")}

-4 bytes thanks to manatwork

while(1)process.stdout.write(Math.random()<.5?"/":"\\")

-1 byte thanks to Conor O'Brien

for(;;)process.stdout.write(Math.random()<.5?"/":"\\")

R, 33

Just interested to see whether this can be made smaller.

while(1)cat(sample(c('/','\\'),1))

Python, 61 bytes

from random import*
while 1:print('/\\'[randint(0,1)],end='')

Pretty self explanatory. Had to use the double backslash since backslashes are escape characters in Python.

Try it Online!

Cubix, 10 bytes

Du\'^>o$/;

Watch it run

    D u
    \ '
^ > o $ / ; . .
. . . . . . . .
    . .
    . .

Was an interesting one to do as i haven't played with the random direction generator much.

Directed north

Directed west

Directed south

Directed east

Print commands

><>, 12 bytes

x!\"/!
^o< <

Try it online!

The idea here is to use x in combination with the ^ below to both loop and choose a random horizontal direction. If the IP goes left from the x, it will skip the mirror / and quote the string "\!x!/", reflect upwards with \, wrapping around to the <, which redirects the IP to output the result and begin the loop again. If the IP goes right from the x, a similar thing will happen.

This is all thanks to the nice happenstance that / and \ are control flow modifiers in ><>, allowing us to save a ".

An alternative solution for 13 bytes is slightly more generic and generates a lot fewer side effects.

xa!o"/\"o!a
^

(You can replace the as with spaces; I have them placed here for clarity. In production code, you would want to do this replacement to avoid unnecessary stack population.)

Runic Enchantments, 13 bytes

`/-R`A*+k$!;

Try it online!

Slightly ungolfed for readability, with spaces to separate operational segments:

'/  2'RA  '- *+k $ !;

The difference of 45 is encoded in the - char literal, as chars are implicitly converted to integers when fed into a operator expecting a number value.

2'RA randomly generates a 0 or a 1, multiplied against the - and added to the / char resulting in either / or \, which is then printed after being coerced back to a char from an int. In the golfed version the  (0x02) serves as the 2.

Then the program loops forever by skipping the terminator, !;.

APL (Dyalog Unicode), 12 bytes

→≢⍞←'/\'[?2]

Try it online!

Tradfn body that prints indefinitely.

Thanks to @Adám for 5 bytes, and for pointing out that, with a little bit of CSS magic, TIO can print the actual pattern like in the image.

How:

→≢⍞←'/\'[?2] ⍝ Tradfn body
         ?2  ⍝ Roll (randomly select) an integer between 1 and 2
        [  ] ⍝ Use the result to index...
    '/\'     ⍝ ...the string containing the two slashes
  ⍞←         ⍝ Print it to the same line
 ≢           ⍝ Tally the result (yields 1)
→            ⍝ then 'goto' that line

MathGolf, 8 bytes

1Æû\/wq∟

Try it online!

Explanation

1          push 1
 Æ     ∟   do-while-true without popping using 5 operators
  û\/      push "\/"
     w     random char from string
      q    print without newline

Implicit popping doesn't seem to be working as intended when using do-while-true, or any other loop type. With this working correctly, the first 1 could be removed.

For a "working" 7-byter, you could do t{û\/wq, which replaces the do-while-true with a simple for loop, and begins the script by pushing the current timestamp in milliseconds to the stack. Currently, that means about \$1.56*10^{12}\$ iterations, which is "infinite" for most applications. However, this is not a valid answer, so the official answer is still 8 bytes.

Java 8, 60 59 54 53 bytes

v->{for(;;)System.out.write(Math.random()<.5?47:92);}

-1 byte thanks to @BenjaminUrquhart by replacing print with write, so '/' can be 47.

Explanation:

Try it online (times out after 60 sec).

v->{                     // Method with empty unused parameter and no return-type
  for(;;)                //  Loop indefinitely
    System.out.write(    //   Print:
      Math.random()<.5?  //    If the random decimal value in range [0,1) is below 0.5:
       47                //     Print forward slash
      :                  //    Else:
       92);}             //     Print backward slash

PowerShell, 108 90 86 54 53 37 36 bytes

for(){Write-Host "\/"[(Random 2)]-n}

Try it online!

SmileBASIC, 20 bytes

?"/\"[RND(2)];
EXEC.

q/kdb+, 18 bytes

Solution:

while[1;1"\\/"1?2]

Explanation:

A simple while(true) loop...

while[1;1"\\/"1?2] / the solution
while[1;         ] / while true do ...
              1?2  / 1 choose 2 (0 or 1)
         "\\/"     / string \/, index in at 0 or 1
        1          / print to stdout without newline

Extras:

Another 18 byte solution: {1"\\/"1?2}\[::;1]

PHP, 26 31 bytes

eight three bytes shorter than yours (without whitespace or braces),
two bytes shorter than primo´s solution (without the tag)
.

PHP 5.4.9 was the current version in December 1012, so ...

for($s="\/";;)echo$s[rand()%2];

requires PHP 5.5 or later for literal string indexing.

Run with -r or try it online.

Cubix, 12 bytes

D<^<!"/\"B!o

View in the online interpreter!

This maps out to the following cube net:

    D <
    ^ <
! " / \ " B ! o
. . . . . . . .
    . .
    . .

Explanation

Setup:

The IP begins heading east at the first !. This is the 'skip if truthy' command, which is False when there is nothing on stack, so no commands are skipped. "/\" enters stringmode and appends these two character codes to the stack. B!o is mostly a no-op here, only reversing the stack.

The IP now loops back around to the first !. However, there are now positive integers on stack, so the first " is skipped. This means / is no longer a character, but a mirror, sending the IP north into the main loop.

Main Loop:

The D command is the only source of randomness in Cubix. It sends the IP in a random direction. By blocking off South and East with arrows, we make sure the IP has a 50% chance of heading North, and a 50% chance of heading West.

If it heads West, the stack is reversed. If it heads North, the top character is printed.

This creates the random sequence of slashes, as desired.

Add++, 24 bytes

+1
W,R2,-1,*45,+47,H,x:1

Try it online!

Pyth - 12 9 bytes

#@,\/\\O2

Tested without loop code because the online interpreter dislikes infinite loops

Explanation:

#@,\/\\O2
#             Repeat until Error
 @            Implicitly print item number
       O2     random number between zero and two exclusive
  ,           of two item list containing
   \/         One character string /
     \\       One character string \

Befunge-98 (PyFunge), 7 bytes

? '/,\'

Try it online!

the ? sends the IP either left or right, so either / or \ is pushed before printing with ,. When executing the '/ or \' in the wrong order after printing, it just does things to the stack (divides or swaps), and then pushes an irrelevant character before repeating.

Perl 6, 23 bytes

loop {<\ />.pick.print}

05AB1E, 7 bytes

["/\"Ω?

Try it online!

["/\"Ω?  - Full program
[          Start an infinite loop
 "/\"      ... Push the string "/\" on the stack
     Ω     ... Pick a character from the top of the stack, at random
      ?    ... Print without a newline

Tcl, 53 bytes

while 1 {puts -nonewline [expr rand()<.5?"/":"\\\\"]}

Try it online!

Fission, 12 bytes

[#"\"R
W\"/"

Try it online!

16-bit x86 assembly code, 10 bytes

I don't remember if this one ended up in the book.

init:
scasb            ;read from where ES:DI points and compare to AL 
                 ;this sets flags similar to a subtraction 
salc             ;set mask in AL to 00 or FF 
and   al,'\'-'/' ;begin choosing character (AL is 00 or 2D) 
add   al,'/'     ;finish choosing character 
writec:
int   29h        ;write char in AL 
jmp   init       ;loop endlessly

><>, 14 bytes

I was hoping I could restrict it to a 3*3 square but didn't succeed.

"/\
~x/
o</
 !

You can try it here.

Powershell, 37 bytes

for(){Write-Host(Random("\","/"))-N}

unfortunately there seem to be no shorter aliases for Write-Host that don't cause a new line after every char.

Common Lisp, 33

(loop(princ(elt"/\\"(random 2))))

Mathematica 157 bytes

Lacking PETSCII, I rolled my own "\" and "/".

No cigar for brevity here.

Graphics[{Thickness[.005],RGBColor[0.73,0.55,1.],Line/@Flatten[Table[RandomChoice[{{{x,y},{x+1,y+1}},{{x+1,y},{x,y+1}}}],{x,40},{y,25}],1]},Background->Blue]

blue maze

Python, 68

In the "my language sucks at this" category, we've got Python!

import random,sys
while 1:sys.stdout.write(random.choice('/\\'))

Thanks to Ivo for a few chars on imports and choice.

Common Lisp - 68

(defun s(l)(elt l(random(length l))))(loop do(format t"~a"(s"/\\")))

Brainfuck - 534

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

My prng (from here) is both large and extremely slow. Perhaps a simpler LFSR or similar would suffice, but this works:

enter image description here

C++, 45 Chars

int main(){for(;;)cout<<(rand()%2?"/":"\\");}

Not going to win any awards for shortness, but I had already written this when I heard about the mentioned book, so I just golfed it.

The putchar trick also works in C++, getting you down to 43, but you can't avoid declaring the return type on main.

ruby, 27 23 chars

loop{$><<"/\\"[rand 2]}

$><< is 'print to stdout'.

C, 39 chars (38 on MSVC)

main(){while(putchar(rand()%2?47:92));}

enter image description here See it run.

On MSVC, we can replace putchar() with _putch() and save a byte, but it doesn't work in IDEOne.

main(){while(_putch(rand()%2?47:92));}

Since this has been migrated to codegolf...

PHP 30 bytes

<?for(;;)echo rand(0,1)?~Ð:~£;

The Ð is character 208, and the £ is character 163.

Sample usage (on a Windows box):

color 18 & php maze.php

Produces something similar to:

It works best with a monospace font that is exactly square (here I've chosen the standard system font 8x8). To go back to your default color, you can type color again without any parameters.

print has a return value of 1, so if you use that you can just wrap the whole expression in the while:

while(print chr(47 + 45 * rand(0,1));

You can probably golf it further too.

Not much better. Needs php 5.5+ for the array dereferencing feature.

while(1) { echo ['/', '\\'][rand(0, 1)]; }

chopped off one character:

while(1) { echo chr(2 + 45 * rand(1,2)); }

then remove the curly braces:

while(1) echo chr(2+45*rand(1,2));

another trick, with the same length:

while(1) echo chr(rand()%2*45+47);

The goto operator was added to PHP from version 5.3.0 so you could use the same method as you would in BASIC:

a: echo chr(47 + 45 * rand(0,1)); goto a;

I guess you can use recursion.

function slashes() {echo chr(47 + 45 * rand(0,1)); slashes();}

I guess you can use recursion.

function slashes() {echo chr(47 + 45 * rand(0,1)); slashes();}

...