| Bytes | Lang | Time | Link |
|---|---|---|---|
| 027 | Scratch 3.0 + Pen extension | 250105T181203Z | madeforl |
| 030 | Commodore BASIC C64 used under emulation | 250102T172109Z | Shaun Be |
| nan | 121209T232723Z | Orab | |
| 102 | jbasher2 | 241213T165304Z | madeforl |
| 028 | Perl 5 | 241211T225354Z | Xcali |
| 032 | Raku Perl 6 rakudo | 241101T210229Z | xrs |
| 021 | punchcode | 241210T173527Z | madeforl |
| 041 | BrainChild | 241111T052310Z | ATaco |
| 009 | Japt | 190721T203208Z | Shaggy |
| 040 | atto | 241102T175030Z | Europe20 |
| nan | i try create using css style | 121211T034752Z | hendra |
| 026 | Thue | 240619T114029Z | None1 |
| 049 | Fortran GFortran | 240618T160752Z | roblogic |
| 067 | F# .NET Core | 240409T060057Z | dtanku |
| 016 | YASEPL | 240402T173522Z | madeforl |
| 009 | Pip | 240402T014327Z | lyxal |
| 015 | Uiua | 240328T221140Z | noodle p |
| 047 | Swift | 240401T164322Z | macOSist |
| 012 | Easyfuck | 240328T233103Z | Quadrupl |
| 040 | TIBasic | 240329T015821Z | Youserna |
| 066 | Python | 220929T133031Z | Joao-3 |
| 036 | Mathematica 36 Bytes | 220929T173538Z | ydd |
| nan | 220929T152410Z | bigyihsu | |
| nan | 220929T153759Z | bigyihsu | |
| 027 | Yabasic | 180322T191033Z | Taylor R |
| 051 | Python 3 | 220702T220050Z | ayreguit |
| 049 | Lua 5.4 | 220828T174327Z | c-- |
| 051 | Python 3 | 211230T224027Z | quintopi |
| 007 | Befunge | 171128T220030Z | Jo King |
| 033 | Factor + qw | 210811T162117Z | chunes |
| 047 | C gcc | 210811T040012Z | M Virts |
| 186 | HTML+JS | 210713T153725Z | Kamil Ki |
| 019 | Add++ | 210503T200256Z | caird co |
| 005 | Vyxal | 210315T102647Z | lyxal |
| 012 | BRASCA | 210315T085105Z | SjoerdPe |
| 033 | AppleSoft BASIC | 210315T081324Z | roblogic |
| 005 | Jelly | 210315T081347Z | Unrelate |
| 042 | Zsh | 210315T072145Z | roblogic |
| 012 | Keg | 190729T042804Z | user8505 |
| 034 | Clojure | 190728T195036Z | NikoNyrh |
| 054 | JavaScript Node.js | 180321T202147Z | 1024x2 |
| 033 | R | 190725T093802Z | Flounder |
| 061 | Python | 190725T073813Z | EdgyNerd |
| 010 | Cubix | 190724T224527Z | MickyT |
| 012 | ><> | 190724T212507Z | Conor O& |
| 013 | Runic Enchantments | 190722T145751Z | Draco18s |
| 012 | APL Dyalog Unicode | 190722T133318Z | J. Sall& |
| 008 | MathGolf | 190722T125210Z | maxb |
| 053 | Java 8 | 161004T133416Z | Kevin Cr |
| 036 | PowerShell | 190720T093344Z | mekb |
| 020 | SmileBASIC | 180321T185709Z | 12Me21 |
| 018 | q/kdb+ | 180202T222147Z | mkst |
| 031 | PHP | 171128T095057Z | Titus |
| 012 | Cubix | 171130T205156Z | FlipTack |
| 024 | Add++ | 171130T194354Z | caird co |
| 009 | Pyth 12 | 171128T203230Z | Tornado5 |
| 007 | Befunge98 PyFunge | 171128T222854Z | MercyBea |
| 023 | Perl 6 | 171128T221401Z | Sean |
| 007 | 05AB1E | 171128T101253Z | scottine |
| 053 | Tcl | 171127T190743Z | sergiol |
| 012 | Fission | 171127T180138Z | KSmarts |
| 010 | 16bit x86 assembly code | 171126T212630Z | peter fe |
| 014 | ><> | 161004T141410Z | Aaron |
| 037 | Powershell | 161004T140845Z | whatever |
| 033 | Common Lisp | 161004T131443Z | coredump |
| 157 | Mathematica | 121208T155656Z | DavidC |
| 068 | Python | 130108T022248Z | boothby |
| 068 | Common Lisp | 130104T223707Z | Matthew |
| 534 | Brainfuck | 130103T232233Z | captncra |
| 045 | C++ | 121212T195359Z | Brandorf |
| 023 | ruby | 121212T171308Z | steensla |
| 3938 | C | 121212T183829Z | JoeFish |
| nan | 121208T151043Z | primo | |
| nan | print has a return value of 1 | 121208T211834Z | histocra |
| nan | 121207T162906Z | rambo co | |
| nan | chopped off one character | 121207T162811Z | Karoly H |
| nan | 121207T162756Z | Michael | |
| nan | 121207T162428Z | Naftali |
Scratch 3.0 + Pen extension, 28 27 blocks
just clarifying: this is a non-competing answer
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).
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.
Raku (Perl 6) (rakudo), 32 bytes
loop {printf rand>.5??"\\"!!"/"}
AWK, 38 bytes
END{for(;;)printf(rand()>.5?"/":"\\")}
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))
}
Japt, 9 bytes
Assumes an infinite stack.
ßOo"/\\"ö
ßOo"/\\"ö
ß :Recursive call with (irrelevant) argument
Oo : Explicit output (returns undefined)
"/\\" : Literal string
ö : Get random character
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
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.
F# (.NET Core), 6967 bytes
let r=System.Random()
while 1=1 do printf$"{char(92-r.Next(2)*45)}"
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"\/"
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:
⍢(&pf⊡⁅⚂.)1$ \/— You save a byte by using a raw string literal and dropping the extra backslash, but you have to define it outside of the loop, and use an extra byte to duplicate it each iteration, so it's not shorter.⍢(&pf+×45⁅⚂@/)1— Multiply 45 by random 0/1, add that to/.
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='')
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}]
Go, 78 bytes (fixed seed)
package main
import."math/rand"
func main(){for{print(string(`/\`[Intn(2)]))}}
Prints to STDERR.
Random seed, 107 bytes
package main
import(."math/rand";."time")
func main(){Seed(Now().Unix())
for{print(string(`/\`[Intn(2)]))}}
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);}}
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 yabasic answer, Do...Loop ends up being shorter due to the the structure of the Mid$ call.
Do?Mid$("\/",Ran(3),1);Loop
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])
Python 3, 52 51 bytes
from random import*
while 1:print(end=choice('\/'))
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)
"/\" 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.
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
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]
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Ȯß
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.
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.
Cubix, 10 bytes
Du\'^>o$/;
D u
\ '
^ > o $ / ; . .
. . . . . . . .
. .
. .
Was an interesting one to do as i haven't played with the random direction generator much.
^Dredirect to the random direction pointer
Directed north
o\>loops around the cube, print empty stack and redirecting back into the print commands (stack is empty)
Directed west
^redirected back into the random direction pointer
Directed south
\'/>reflected to the east, push / onto the stack and redirect into the print commands
Directed east
u'\>uturn to the right, push \ onto the stack and redirect into the print commands
Print commands
o$/;^output top of stack, skip over the reflect, pop from the stack and redirect into the random direction pointer
><>, 12 bytes
x!\"/!
^o< <
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$!;
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]
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∟
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
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.
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
? '/,\'
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}
looploops forever.<\ />is a list of the strings\and/..pickpicks one of the two strings randomly..printprints that random string.
05AB1E, 7 bytes
["/\"Ω?
["/\"Ω? - 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
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]

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:

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




