g | x | w | all
Bytes Lang Time Link
121Swift 6250302T012837ZmacOSist
535Bespoke250325T092631ZJosiah W
083tcl170106T015532Zsergiol
060Casio BASIC fx9750GIII240910T141115Zmadeforl
194Mindustry241011T191353ZDornteuf
027Japt240911T151226ZShaggy
086GNU AWK240713T190737ZPedro Ma
086hyperscript240713T140759Znoodle p
nanJavaScript + HTML240331T135645Znoodle p
039Uiua240330T171255Znoodle p
036Easyfuck240326T013303ZQuadrupl
122YASEPL240208T191154Zmadeforl
356CLCINTERCAL psyscall240202T034321Z鳴神裁四点一号
098Scratch240125T012009Znoodle p
071C89240124T184221Zc--
065TIBASIC230728T045216Zjoyofori
031Pyth161130T065124Zinsert_n
036MATL161127T213519ZLuis Men
056Zsh220312T065710Zpxeger
093Python 3220311T225329ZLarry Ba
108Python 3 Windows210610T085152Zraspidui
061Julia210609T222647ZMarcMush
02605AB1E210609T203150ZMakonede
040reticular161128T032544ZConor O&
024Stax210226T073341ZRazetime
060Groovy180517T111218ZMatias B
083Yabasic180517T105618ZTaylor R
033><> with t.03 flag180517T090149ZJo King
038Japt180517T065251ZBubbler
224C++180112T172408ZColin Ro
074JavaScript ES6 + HTML170512T134537ZShaggy
073C function170525T222008Zepimatec
068ES8 + HTML171004T133749Zcopyrepl
056PHP170702T043903Zkip
121TSQL170702T025043ZWORNG AL
nan170619T103054ZTwometer
034Charcoal170619T091225ZASCII-on
082C170513T020523ZMD XF
008Snap!161130T061946Zwyldstal
059shortC170522T000841ZMD XF
109C++170512T144706ZClé
094Python 3161223T203850Zpython-b
140C#170131T104149ZMetoniem
100Bash170130T203330Zckjbgame
048PKod170201T161559ZOfftkp
123Commodore 64 or VIC20170131T172334ZShaun Be
046SmileBASIC170130T083411Z12Me21
057SmileBASIC170131T134205Zsnail_
025Noodel161227T223841Ztkellehe
143HTML/CSS161127T212251ZNeil
079tcl170106T021730Zsergiol
088C161128T210957ZSteadybo
057TIBasic CE/CSE only161228T201531ZJulian L
046awk161228T092319ZJames Br
067PowerShell161214T214013ZDan
135HTML/CSS 135 Bytes161129T032620ZBen Aubi
092Clojure161129T010129ZCarcigen
189Turing machine simulator161213T174928ZErik the
077Python 2161127T214639ZArtyer
nanHTML + JS ES6161127T224908Zdarrylye
057Powershell v4161128T135036Zcolsw
nanWindows Batch161128T062239Zuser6616
077Batch161204T082132Zundo
081F# interactive161203T222035Zpmbanka
109C#161202T123656ZGonç
283NASM x86_64161129T213154ZSamuel
086Scala161201T203246Zcorvus_1
061Befunge 98161130T213700Zninjalj
057Ruby161201T170323Zdaniero
073Forth161128T155018Zzeppelin
149TSQL161128T200453ZNelson
111C#161201T085659ZLuc
056MSDOS .COM file161128T213749ZMartin R
083Python 3161130T061117ZSherlock
057Ruby161128T030717ZConor O&

Swift 6, 108 123 121 bytes

C interop, gooooooooooooooooo...

import Darwin
let s=stdout
fputs("Loading... |",s)
while 0<1{"|/-\\".map{fputs("\u{8}\($0)",s)
fflush(s)
usleep(250000)}}

We print to stderr instead of stdout because stderr isn't buffered by default; this saves me a call to fflush(_:). Never mind, sometimes reading the question in full is a good idea.

We use fputs(_:) instead of puts(_:) to avoid the trailing newline. (And before anyone asks, no, we can't just use printf, because printf, being a C function that uses the ... syntax for varargs, is not available in Swift.)

Bespoke, 535 bytes

PUT XX:DIGITNINE BI
PUT XX:FOUR FIFTH
PUT XX:FOUR SEVENTH
PUT XXX:I BI FOUR
PUSH I H V
PUT XX:TRI BI
PUT XX:FOUR SEXTET
DO COPY
DO COPY
PUT XXX:I NUMBERZERO TRI
PUT XXX:I I NUMBERZERO
PUT XXX:I NUMBERZERO FIFTH
PUT XXX:I NUMBERZERO NUMBERZERO
PUT XX:DIGITNINE SEVENTH
PUT XXX:I I I
PUT XX:SEVENTH SEXTET
PUSH I
CONTROL WHILE
OUTPUT CH
DO COPY
CONTROL END
CONTROL DOWHILE
DO COPY
PUT XXXX:FIFTH I I I;STACKTOP QUOTIENTOF
PUSH FOUR STACKTOP MODULO
PUSH BI STACKTOP PLUS
DO COPYN
OUTPUT CH
PUSH INTEIGHT;OUTPUT CH
STACKTOP PLUSONE
DO COPY

A loading animation in a terminal, with the text "Loading... " and a clockwise-spinning line.

Note: at the speed that the Python-based Bespoke interpreter runs on my computer, a time interval close enough to 0.25 seconds happens every 5111 iterations of my program's main loop. Bespoke has no command for waiting a specific length of time.

(Also, the arithmetic I do on my counter will theoretically take longer and longer to do as it gets higher, because of the way ints work in Python. I can rewrite my program if this is an issue.)

tcl, 83

while 1 {lmap c {| / - \\} {puts -nonewline \rLoading...$c;flush stdout;after 250}}

Can be seen running on: http://tpcg.io/_6PBTFX

Unfortunately, this online compiler can not demonstrate it going back rewriting the line. In a local machine it can be seen.

Casio BASIC (fx-9750GIII), 64 60 bytes

"Loading..."
Lbl A
1+Ans Rmdr 4
Locate 12,1,StrMid("\\|/-",Ans,1)
For 0→I To 200
Next
Goto A

The timing is probably not accurate since the Casio fx-9750giii doesn't have any built-in time functions as far as I know, but I think I got pretty close.

Timing ranges on what device you use this on, since it uses a for loop to separate the frames.

Mindustry, 194 bytes

set s "|"
print "Loading... "
print s
printflush
wait 0.25
jump 8 notEqual s "|"
set s "/"
jump 1 equal
jump 11 notEqual s "/"
set s "-"
jump 1 equal
jump 0 notEqual s "-"
set s "\"
jump 1 equal

Must be connected with a message block (message1), which is used as stdout.

An interesting golf in this program is jump 1 equal: this is shorter than jump 1 always by 1 byte, and works due to the default arguments for jump being notEqual, x and false. It expands to jump 1 equal x false, which is evaluated as true, because x is null and null s apparently equal to false. (Reminds me of strange JS comparisons.)

I'll add a GIF of it later.

Japt, 29 27 bytes

Oq`LoÃHg... {°g"|/-\\"#út@ß

Test it

Oq`...{°g"..."#út@ß
Oq                      :Overwrite the output with
  `...                  :  Compressed string "Loading... "
      {                 :  Interpolate
       °                :    Postfix increment the first input variable (defaults to 0)
        g"..."          :    0-based index into the literal string
              #ú        :250
                t       :Set a timeout of 250ms
                 @      :To run the following function
                  ß     :  Recursive call

GNU AWK, 86 bytes

Run it on your terminal:

gawk -ltime 'BEGIN{for(printf"Loading... |";sleep(1/4)++k;)printf"\b"substr("|/-\\",k%4+1,1)}'

Try it online!

80 chars of code + 6 chars for arguments

This is just GNU AWK relying on its time extension and respecting all rules. No input, no BASH, no coreutils. Could be shorter, but the sleep function must be called after the first printf.

gawk -ltime              Runs GAWK with time extension.
                         Exactly the same as using @load "time", but shorter.

'
BEGIN{
 for(                    Begins the loop without input.
  printf"Loading... |";  Starts printing the first iteration without trailing line.
  sleep(1/4)++k;         Waits .25 second, which returns 0, and appends to the counting variable.
                         No big deal here. I just did it to save characters.
  ;)
 printf
  "\b"                   Prints a backspace
  substr("|/-\\",        appended to a sub-string of this monstrosity (\ is escaped)
   k%4+1,                starting at the character mod 4 + 1 (GAWK starts counting at 1)
   1)                    with length 1.
'

hyperscript, 86 bytes

Loading... <x _="init repeat forever increment n put '\\|/-'[n mod 4]into me wait 250"

Try it:

<script src="https://unpkg.com/hyperscript.org@0.9.8"></script>

Loading... <x _="init repeat forever increment n put '\\|/-'[n mod 4]into me wait 250"

init                            -- when the document is initialized
  repeat forever 
    increment n                 -- increment initializes n to 0
    put '\\|/-'[n mod 4]into me -- sets <x>'s innerHTML
    wait 250                    -- (250 milliseconds)

JavaScript + HTML, 48 + 20 = 68 bytes

setInterval(_=>a.innerHTML="\\|/-"[i++%4],i=250)
Loading... <a id=a>|

Since the animation is supposed to start immediately, I had to move the Loading text and the initial state of the animation to the HTML.

Uiua, 39 bytes

⍢(&sl1/4&pf⊂"\rLoading... "⊢.↻1)1$ |/-\

program running

For some reason it looks really slow in the GIF but I can assure you on my computer it waits for 1/4 of a second. You may also notice that in the GIF, the code has an extra backslash; that's because I have Uiua 0.9.5 installed on my computer. In 0.10.0, the way $ strings work is a bit different, and the extra backslash isn't needed.

Explanation:

⍢(…)1$ |/-\

This starts with “|/-\” on the stack and does the rest of the program in a loop forever. A byte is saved by using the raw string syntax $ |/-\ instead of the normal "|/-\\".

↻1

Rotate this string one character to the left.

&pf⊂"\rLoading... "⊢.

Combine the first character of this with the loading text, and print it. The \r causes the text to be printed over whatever was already there.

&sl1/4

Sleep for a quarter of a second. Using a fraction literal like this is a byte shorter than 0.25.

Easyfuck, 41 36 bytes

ymsĘ·^U¶ąĺw‹ž]€ ĎÁ␆n␈2´A•ŕ␐.\»>í90ďSOS

due to lack of unicode representations for c1 control characters, they have been replaced by their superscripted abbreviations

Decompressed:

<[.<U]<U[.<W<.<]@␈␙|␈␙\␈␙-␈␙/␀ ...gnidaoL

the gif

<[.<U]<U[.<W<.<]@␈␙|␈␙\␈␙-␈␙/␀ ...gnidaoL
<                                         go to the last cell
 [.<U]                                    go through cells backwards, printing and deleting until encountering a null character
      <U                                  delete the null character
        [.<W<.<]                          go backwards through characters looping when reaching the beginning, printing and waiting according to their values
                @                         marks the end of code
                 ␈␙|␈␙\␈␙-␈␙/␀ ...gnidaoL initializer data

YASEPL, 122 bytes

=sŔ,9=1)pipeſdivideſminusſ"\"=b$27»ſopenbracket=o|3`1!aŔ,9!c$a-s}1,250,3|`3!b~#"2J"~#"HLoading..."=g¥o,1~!o+%4!Ŕ,9|

it starts automatically, the compiler just takes a second to load the file so thats why there is a pause if you run this

I cant exactly make a GIF of this right now, but when I can i'll update.

this uses ANSI.

CLC-INTERCAL -psyscall, 356 bytes

Uses latest feature: syscall #9.

DO;1<-#12DO;1SUB#1<-#94DO;1SUB#2<-#317DO;1SUB#3<-#314DO;1SUB#4<-#2567DO;1SUB#5<-#377DO;1SUB#6<-#364DO;1SUB#7<-#248DO;1SUB#8<-#670DO;1SUB#9<-#188DO;1SUB#10<-#255DO;1SUB#11<-#255DO;1SUB#12<-#213DO;2<-#1DO:9<-#392¢#452DOCOMEFROM#9(4)DO;2SUB#1<-#122(2)DO;2SUB#1<-#126(1)DO;2SUB#1<-#15DO;2SUB#1<-#47DO.1<-#8DOCOMEFROM.1DOREADOUT;1+;2(666)DO.9<-#9(9)DO.1<-.1~#14

Running gif before fixing; spinning counterclockwise

Running CLC-INTERCAL program on Termux.

Ungolfed

DO;1<-#12          DONOTE ;1 <- "\rLoading... "
DO;1SUB#1<-#94
DO;1SUB#2<-#317
DO;1SUB#3<-#314
DO;1SUB#4<-#2567
DO;1SUB#5<-#377
DO;1SUB#6<-#364
DO;1SUB#7<-#248
DO;1SUB#8<-#670
DO;1SUB#9<-#188
DO;1SUB#10<-#255
DO;1SUB#11<-#255
DO;1SUB#12<-#213

DO;2<-#1           DONOTE ;2 is one of "|/-\"
                   DONOTE implicit .1<-#0 as iterator

DO:9<-#392¢#452    DONOTE const 250,000

DOCOMEFROM#9

(4)DO;2SUB#1<-#122 DONOTE /
(2)DO;2SUB#1<-#126 DONOTE -
(1)DO;2SUB#1<-#15  DONOTE \
DO;2SUB#1<-#47     DONOTE |
DO.1<-#8
DOCOMEFROM.1       DONOTE possibly from 4 2 or 1
DOREADOUT;1+;2
(666)DO.9<-#9      DONOTE sleep for :9 microseconds
(9)DO.1<-.1~#14    DONOTE right shift

Scratch, 98 bytes

enter image description here

Try it on Scratch!

define
forever
set[i v]to(((i)mod(4))+(1
say(join[Loading... ](letter(i)of[|/-\\]))for(.25)seconds

C89, 71 bytes

main(i){for(;;)usleep(4<<printf("Loading... %c\n[A","/-\\|"[i++&3]));}

Using printable characters the format argument to printf(3) would be "Loading... %c\n\x1b[A".


C (gcc) -O3, 65 bytes

The same but as a function. Requires tail-call optimization, otherwise it would overflow the stack eventually.

i;f(){f(usleep(4<<printf("Loading... %c\n[A","/-\\|"[i++&3])));}
/* main(){f();} */

TI-BASIC, 65 bytes

While 1:remainder(A+1,4)→A:Output(1,1,"Loading... "+sub("|/-\",A+1,1:Wait 1/4:End

TI CONNECT CE sadly does not allow screen recording so you'll have to enjoy my amazing camera skills instead.

yeahhhhhhhh!

Ungolfed:

While 1
remainder(A+1,4)→A
Output(1,1,"Loading... "+sub("|/-\",A+1,1
Wait 1/4
End

Explained:

While 1                                     Loop through everything forever
remainder(A+1,4)→A                          Set A to (A+1) mod 4
Output(1,1                                  Print at the first row, first column
          "Loading..."                      Loading...
                      +                     Concatenate string to...
                       sub( .... ,A+1,1     The A+1th characer of...
                           "|/-\"           This string
Wait 1/4                                    Pause for 0.25 seconds
End                                         End loop, go back to while.

According to this meta post, TI-BASIC is scored by token byte count, not characters. While is stored as a 1 byte token, and so is Output, while remainder is two bytes. It's kind of hard to count the tokens, so the best way is just to go to TI CONNECT and see how much space the program takes on the calculator.

Pyth, 31 bytes

Wm,p+"\rLoading... "d.d.25"|/-\

Interpreter here.

Loading GIF

Explanation

Wm,p+"\rLoading... "d.d.25"|/-\
    +"\rLoading... "d              Concatenate the string "\rLoading... " and the variable d
   p                               Print the result without a newline
                     .d.25         Sleep for 0.25 seconds
  ,                                Form a two-element list with the results of the two statements above. This is only needed to execute both statements in a single lambda function.
 m                        "|/-\    Map the above statement over the characters in the string "|/-\", setting the variable d to the character for each iteration
W                                  While the result of the map statement is true, do nothing

MATL, 36 bytes

1 byte removed using @flawr's idea of circularly shifting the string

'\-/|'`Xx1YS'Loading... 'y1)hD.25Y.T

Here is a gif recording from the offline compiler:

enter image description here

Or try it at MATL Online!

How it works

'\-/|'           % Push this string
`                % Do...while
  Xx             %   Clear screen
  1YS            %   Circularly shift thr string 1 step to the right
  'Loading... '  %   Push this string
  y              %   Duplicate the string of shifting symbols
  1)             %   Get the first character
  hD             %   Concatenate the two strings and display
  .25Y.          %   Pause for 0.25 seconds
  T              %   Push "true". This is used as loop condition, to it
                 %   generates an infinite loop
                 % End loop implicitly

Zsh, 56 bytes

while for i (\| / - \\)printf \\rLoading...$i&&sleep .25

Attempt This Online!

Python 3, 93 bytes

import time
while 1:print(end="Loading... "+"|/-\\"[int(time.time())%4]+"\r");time.sleep(.25)

Try it online!

Python 3 (Windows), 112 109 108 bytes

import time,os
while 1:
 for i in ['|','/','-','\\']:print("Loading... "+i);time.sleep(1/4);os.system('cls')

Python 3 (*nix), 111 110 bytes

import time,os
while 1:
 for i in ['|','/','-','\\']:print("Loading... "+i);time.sleep(1/4);os.system('clear')

Thanks @Dion for reducing 3 bytes in Windows version and add more info about *nix run!

Julia, 61 bytes

while 0!=@.print("\rLoading... "*["|/-\\"...])==sleep(1/4)end

(Don't) try it online!

gif demo

05AB1E, 26 bytes

[13甲½... ”"|/-\"NèJ?Ƶ–.W

[13ç”...”"..."NèJ?Ƶ–.W  # trimmed program
[                       # forever...
   ç                    # push character with codepoint...
 13                     # literal
    ”...”               # push "Loading... "
               è        # push character in...
         "..."          # literal...
               è        # at index...
              N         # current index in loop...
               è        # modulo length of...
         "..."          # literal
                 ?      # output...
                J       # joined stack...
                 ?      # without trailing newline
                    .W  # wait...
                  Ƶ–    # 250...
                    .W  # milliseconds

reticular, 40 bytes

:i=@C"Loading... "o"|/-\\".iHo14%w.i1+4,

enter image description here

I forgot to commit a bunch of things, including w. Oh well.

Explanation

:i=@C"Loading... "o"|/-\\".iHo14%w.i1+4,
:i=                                       set `i` to the TOS
   @C                                     clear the screen
     "Loading... "o                       output that string
                   "|/-\\"                push that string
                          .i              get `i`
                            H             get the `i`th character of that string
                             o            and output it
                              14%         push 0.25 (1/4)
                                 w        wait that long
                                  .i      get `i`
                                    1+    increment
                                      4,  mod 4
                                          this wraps around the beginning of the program,
                                          setting i to the said value
   

Stax, 24 bytes

Ñ!Δ╚«&╖ô^ô◙⌠≈%<╗∞█z9ÖºOT

Run and debug it

Delays 15 frames between each change, which at default 60fps should be equal to 1/4th of a second.

Explanation

W`lAtv>!`"|/-\"{[+p{|,}15*|:F
W                             loop forever
 `lAtv>!`                     push "Loading... "
         "|/-\"{            F for each char in "|/-\"
                [+p           add to Loading and print
                   {|,}15*    delay 1 frame 15 times
                          |:  clear the screen

Groovy, 60 bytes 59 bytes, 61 bytes

print'Loading...';for(;;)'|/-\\'.any{print"$it\b";sleep 250}

(modified to work with later versions of groovy, removed ascii cast)

Yabasic, 83 bytes

An anonymous function that takes no input and outputs to the console in graphics mode. Does not function with TIO.

Clear Screen
?"Loading..."
Do
?@(1,11)Mid$("|/-\\",i+1,1)
Wait.25
i=Mod(i+1,4)
Loop

><> with -t.03 flag, 33 bytes

'o!vooooo|\-/ ...gnidaoL
{[4<o8o:

Try it online!

The only part of the specification this doesn't implement is that the first frame should be printed as soon as the program is run which seems rather strict and unobservable. The first frame here take 1.08 seconds to print, and every frame after that takes 0.24 seconds.

Japt, 38 bytes

@Oq Oo`LoÃHg... `+"|/-\\"gW°%4)1
a#úiU

Try it online!

How it works

@Oq Oo`LoÃHg... `+"|/-\\"gW°%4)1
a#úiU

@               Declare a function...
 Oq               that clears the screen,
 Oo"Loading... "  prints this string,
 +"|/-\\"gW++%4   plus the spinner char (using a variable W),
 )1               and finally returns 1
                and implicitly store this function to U.

a       Call U once (return 1 is needed for this)
 #úiU   and call U every 250 milliseconds.

By the nature of Japt syntax, it's impossible to call U() directly (well, it's possible using JS directive $...$ but it's too long after all.) So we use U.a() method that calls U with numbers from 0 to infinity until U returns true. If you omit )1 at the end of the first line and try running it, your browser will hang.

Without the initial U() call, the output window will show the implicit output (seemingly random integer value) before first showing the Loading... text.

Finally, a#úiU actually translates to U.a(250 .i(U)), which registers the 250ms loop first and then passes the return value (which happens to be undefined) to U.a (which accepts optional function argument, but seems to do nothing special with undefined).

C++ (224)

This certainly isn't the shortest code to do this. I like doing coding challenges, so I'm posting it anyway.

#include <iostream>
#include <string>
#include <thread>
using namespace std;int main(){string s = "|/-\\";int i=0;cout<<"Loading... ";while(1){cout<<s[i];this_thread::sleep_for(chrono::milliseconds(99));cout<<"\b";i=++i%4;}}

JavaScript (ES6) + HTML, 77 74 bytes

f=c=>setTimeout(f,250,-~c%4,o.value="Loading... "+"|/-\\"[~~c])
<input id=o

Try It

(f=c=>setTimeout(f,250,-~c%4,o.value="Loading... "+"|/-\\"[~~c]))()
<input id=o>

C function, 73 bytes

i;f(){for(;write(1,"\rLoading... -\b\\\b|\b/",13+i%8);i++)usleep(1<<17);}

Tested on SystemResque-Cd 4.9.6 in this program:

#include <stdio.h>
#include <unistd.h>

/*
i;
f(){
        for(
            ;
            write(1, "\rLoading... -\b\\\b|\b/", 13+i%8);
            i++
        ){
                usleep(1<<17);
        }
}
*/
i;f(){for(;write(1,"\rLoading... -\b\\\b|\b/",13+i%8);i++)usleep(1<<17);}

int main(){
        f();
        return 0;
}

compiled with gcc 4.9.4

ES8 + HTML, 68 bytes

setInterval(e=>a.innerHTML='|/-\\'[++i%4],i=250)
Loading... <a id=a>-

PHP, 56 bytes

while(!usleep(25e4))echo"\rLoading... ",'\|/-'[@$i++%4];

T-SQL, 121 bytes

DECLARE @ CHAR W:SET @=IIF(@='/','-',IIF(@='-','\',IIF(@='\','|','/')))PRINT'Loading... '+@ WAITFOR DELAY'0:0:0.25'GOTO W

Java 7, 121 118 bytes

void f()throws Exception{for(int k=0;;k++){System.out.print("\rLoading... 
"+"|/-\\".charAt(k%=4));Thread.sleep(250);}}

Gif animation:

enter image description here

Charcoal, 34 bytes

Loading... A⁰αHW²⁵⁰¦¹«A⁺¹ααP§|/-\α

Try it online! Refresh command has changed since so it is different on TIO. Link to verbose code for explanation.

C, 92 89 82 bytes

i;f(){for(;;i=4)while(i--)dprintf(2,"\rLoading... %c","|\\-/"[i]),usleep(250000);}

Snap!, 8 blocks

8 blocks of Snap!

This was one of the very first algorithms I ever puzzled out on an Apple ][e

shortC, 59 bytes

i;f(){O;;i=4)Wi--)dR2,"\rLoading... %c","|\\-/"[i]),U250000

C++, 109 Bytes

There should be a lot to improve, it's my first golf code. Feedback is greatly appreciated :)

#import<stdio.h>
#import<unistd.h>
int b;main(){for(;;usleep(2500))printf("\rLoading...%c","-\\|/"[++b%=4]);}

Python 3, 94 bytes

Okay. First answer. EDIT: SAVED 8 BYTES EDIT 2: SAVED 1 BYTE EDIT 3: SAVED 11 BYTES EDIT 4: SAVED 3 BYTES EDIT: SAVED 5 BYTES EDIT: SAVED 2 BYTES

import time
while 1:
 for f in 0,1,2,3:print("Loading...","|/-\\"[f],end="\r");time.sleep(.25)

Ungolfed:

import time
while True: # Loop forever
    for f in [0, 1, 2, 3]: # Loop four times
    print("Loading...", "|/-\\"[f], end="\r") # Print Loading... then the current frame
        time.sleep(0.25) # Wait 0.25 seconds

C#, 183 180 178 170 161 140 bytes

I know a C# solution has already been posted, but this one is a fully functional console program (including usings) in less bytes!

Golfed

class P{static void Main(){for(int i=0;;){System.Console.Write("\rLoading... "+@"|/-\"[i=i++==3?0:i]);System.Threading.Thread.Sleep(250);}}}

Ungolfed

class P
{
    static void Main()
    {
        for (int i = 0; ;)
        {
            System.Console.Write("Loading... "+@"|/-\"[i = i++ == 3 ? 0 : i]);
            System.Threading.Thread.Sleep(250);
        }
    }
}

Yes, I'm probably very late, but I had to post it..!

EDIT: I figured someone else posted a 109 byte C# solution, oh well
EDIT 2: Thanks to the poster of the 109 byte C# solution, I managed to lose 3 more bytes by removing i<4 from my for loop, thanks!
EDIT 3: Removed C# 6 string interpolation and used good old + instead to save 2 more bytes.
EDIT 4: Not declaring a var for the animation characters anymore, instead I added them directly into the Write() method, saving another 8 bytes
EDIT 5: Removed the parameter string[]s from the Main method to save 9 bytes!
EDIT 6: Used carriage return instead of System.Console.Clear(), removed a using and moved the incrementing of i + the ternary inside of System.Console.Write(), all thanks to @CSharpie! (all this saved 21 bytes)

Bash, 100 bytes

while [ 1 ]; do for i in `echo '|/-\' | grep -o .`; do printf $'\rLoading...'$i;sleep 0.25;done;done

This is not nicely golfed, so please tell me where I can improve here.


This does work, and has been tested on a Raspbian Raspberry Pi, an Amazon server, and an Ubuntu machine. This would not work on a Solaris machine because the sleep command on those systems cannot take inputs less than 1.

PKod , 48 bytes ~ Non-Competing

Possibly the only way I can do this, as PKod only has one write-able variable lL=oo=ao=do=io=no=go=.ooo =|oyw=/oyw=-oyw=\oywl<

Explanation: l - Clear screen and since its the first char, allow printing no operation (NOP) chars
             L - NOP, thus print "L"
             =oo=ao=do=io=no=go=.ooo - Set as certain chars and print them.
             (space) - Another NOP, thus print a space
             =|oyw - Set char as "|", print it, then wait a quarter of a second and remove it
             =/oyw=-oyw=\oywl - Same as above, with different symbols to match the challenge
             < - Go back to the start

"Gif" (more like mp4): https://i.gyazo.com/577dd164313a6b2e5dbf40249efb435d.mp4

You can see quote marks around the code in the console, thats because cmd tries to do stuff with my "<" and would return an error. It's just to nicely pass the code to the interpeter without cmd interfering.

Commodore 64 (or VIC-20), 123 Bytes

0 A$="/|\-":A=1:FORI=0TO1STEP0:PRINT"{home}LOADING..."MID$(A$,A,1):A=A+1:GOSUB2:ON-(A>4)GOTO0
1 NEXT
2 FORX=0TO99:NEXT:RETURN

Using print 38911-(fre(0)-65536*(fre(0)<0)) tells me that I have consumed 123 bytes of the computers memory (on the C64); this will probably work on other variants of Commodore BASIC, such as the BASIC 7; you will need to use BASIC keyword abbreviations to enter it on a real C64 or VIC-20.

The BASIC listing from an emulator screen grab

In order to make it infinite*, you will need to disable the RUN/STOP key with a POKE, I think it's POKE 808,234 - that will mean you can't break into the BASIC listing without an Action Replay or a soft reset or something. The time delay can be altered in line 2 - increase the FOR X counter as required.

SmileBASIC, 51 46 bytes

CLS?"Loading... ";"|\-/"[3AND MAINCNT/15]EXEC.

SmileBASIC, 57 bytes

@L CLS?"Loading... "+"|/-\"[I]:I=(I+1)MOD 4 WAIT 15 GOTO@L

Ungolfed:

@L                       'loop start
CLS                      'clear console
?"Loading... "+"|/-\"[I] 'construct our output and print
I=(I+1)MOD 4             'inc counter, MOD to prevent overflow
GOTO @L                  'loop

Noodel, noncompeting 24 25 bytes

Cannot compete because Noodel was born after the challenge.

”|gAĖọẸ.?a5‘|/-\⁺ʂḷạÇḍ/4

Had to add a byte because messed up the compression algorithm:(

“Loading...¤‘|/-\⁺ʂḷạÇḍ/4

Try it:)

How it works

“Loading...¤              # Creates a string that is "Loading...¤" that is placed into the pipe.
            ‘|/-\         # Creates a character array ["|", "/", "-", "\"]
                 ⁺ʂ       # Adds two items in the pipe which will add the string to each character in the array. The 'ʂ' forces it to prepend rather than append.
                   ḷ      # Unconditionally Loop everything up until a new line or end of program.
                    ạ     # Basic animation, iterates through an object moving to the next index every call on that object and returns what is at that index.
                     Ç    # Clears the screen then prints what is in the front of the pipe and dumps what was displayed.
                      ḍ/4 # Delays for the specified amount of time (/4 => 1/4 => 0.25s)

Stepping The Pipe

-->
--> "Loading...¤"
--> ["|", "/", "-", "\"], "Loading...¤"
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]
Loop ----------------------------------------------------------------------------------------
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]
--> "Loading...¤|", ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:0>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:0>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:0>
Loop ----------------------------------------------------------------------------------------
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:0>
--> "Loading...¤/", ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:1>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:1>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:1>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:1>
Loop ----------------------------------------------------------------------------------------
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:1>
--> "Loading...¤-", ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:2>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:2>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:2>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:2>
Loop ----------------------------------------------------------------------------------------
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:2>
--> "Loading...¤\", ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:3>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:3>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:3>
--> ["Loading...¤|", "Loading...¤/", "Loading...¤-", "Loading...¤\"]<frame:3>

There currently is not a version of Noodel that supports the syntax used in this answer. Here is a script that is supported:

23 bytes

Loading...¤”Ƈḟḋḣ⁺sḷạÇḍq

<div id="noodel" code="Loading...¤”Ƈḟḋḣ⁺sḷạÇḍq" input="" cols="12" rows="2"></div>

<script src="https://tkellehe.github.io/noodel/release/noodel-1.1.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>

HTML/CSS, 183 180 163 161 160 147 143 bytes

a{display:inline-flex;overflow:hidden;width:1ch}c{animation:c 1s steps(4)infinite}@keyframes c{to{margin:0-4ch
<pre>Loading... <a><c>|/-\</pre>

Edit: Saved 3 bytes thanks to @betseg. Saved 17 bytes thanks to @manatwork. Saved 1 byte thanks to @Daniel. Saved 13 bytes thanks to @Ismael Miguel. Saved 4 bytes thanks to @Fez Vrasta.

tcl, 79

while 1 {lmap c {| / - \\} {puts -nonewline stderr \rLoading...\ $c;after 250}}

assuming I can write to stderr instead of stdout

C, 119 118 102 91 88 bytes

#import<windows.h>
i;f(){for(;;)Sleep(19*printf("\rLoading... %c","\\|/-"[i=(i+1)%4]));}

TI-Basic (CE/CSE only), 57 bytes

:ClrHome
:Disp "LOADING...
:For(A,1,5
:A-4(A=5→A
:Output(1,12,sub("+/-*",A,1
:Pause .25
:End

Notes:

awk, 46 bytes

In awk, with some help from ANSI codes and the rotor comes piped in:

{while(i=1+i%4)print"Loading... "$i"\033[1A"}

Try it:

$ echo \|/-\\|awk -F '' '{while(i=1+i%4)print"Loading... "$i"\033[1A"}'
Loading...[|/-\]

One byte comes off if NF is replaced with 4. I didn't wait to see if i iterates to oblivion.

PowerShell, 116 77 69 67 bytes

for(){[char[]]'|/-\'|%{write-host -n `rLoading... $_;sleep -m 250}}

cleaner than cls?

HTML/CSS 135 Bytes

Like my previous answer, but doesn't use a monospace font, saving 6 bytes (not 100% if that's allowed, so I separated the answers for separate voting).

Update - a non monospace font is allowed. This works!

@keyframes l{0%{content:'|'}25%{content:'/'}50%{content:'-'}75%{content:'\\'}}a:after{animation:l 1s infinite;content:'|'}
<a>Loading... 

Clojure, 93 92 bytes

#(do(print"Loading... -")(doseq[c(cycle"\\|/-")](print(str"\b"c))(flush)(Thread/sleep 250)))

Basically the Haskell answer (I swear I didn't cheat!).

It must be run in a console. IDE's REPL (Intellij) just prints a garbage character in place of the "\b".

And it's late, and I've never even created a GIF before, so I'm going to have to pass on that part.

Turing machine simulator, 189 bytes

0 * L r 1
1 * o r 2
2 * a r 3
3 * d r 4
4 * i r 5
5 * n r 6
6 * g r 7
7 * . r 8
8 * . r 9
9 * . r A
A * * r B
B - \ * C
B / - * C
B | / * C
B * | * C
C * * * D
D * * * E
E * * * F
F * * * B

Do not run on full speed, or it will not wait for ~0.25 s1.

1Dunno if actually within 10% of 0.25 s. Last 4 lines do the waiting job approximately.

Python 2, 81 79 78 77 bytes

import time
i=1
while 1:print'\rLoading...','\|/-'[i%4],;i+=1;time.sleep(.25)

Quite a simple solution that sleeps using time.

I use \r (A carriage return) to go back to the start of the line and then print the message overwriting the line.

I start with i=1 to avoid double escaping the \ (It is '\|/-' instead of '|/-\\').

In the past, I had used -~i to mean i + 1 to avoid parentheses. (Thanks to @Flp.Tkc for these -2 bytes!) (It was i=(i+1)%4 vs. i=-~i%4)

Now, I am just letting the counter rise forever, as technically Python ints can't overflow. Thanks to @Zachary T for pointing that out and saving a byte!
It only stops on a machine because the machine runs out of memory, but this takes 9.7 generations with 4GB of memory for that one int.

Thanks to @Kade for the -1 byte where print a,b prints a and b space seperated, so I don't need my own space.

Here's a gif of it working on Windows:

Loading

I tested it on a Linux VM too. I couldn't test it on a Mac.

HTML + JS (ES6), 20 + 51 50 = 70 bytes

setInterval(_=>a.innerHTML='|/-\\'[i=-~i%4],i=250)
Loading... <a id=a>-

-1 byte (Zachary T)

Check out my 132 byte HTML/CSS answer as well.

Powershell (v4), 57 56 54 53 58 57 Bytes

Back at the Bytecount I started with!

for(){cls;"Loading... "+"|/-\"[($a=++$a%4)];sleep -m 250}

The CLI in powershell will glitch out slightly on some computers, so it doesn't look perfect, but it's as good as I can feasibly get.

Moved $a++ into the for loop to save one byte, (no ;)

Then moved it into the array indexer, for another 2 byte save, thanks to Roman for pointing that out.

Also saved 1 more byte (;) by moving the Clear screen (cls) part into the for loop..

Issue and fix pointed out by TimmyD for the infinite aspect of the question, only +5 Bytes required, changed $a++%4 into ($a=++$a%4) so it will never go above 3.

Saved another byte by leaving the for loop totally blank, thanks to 'whatever' for pointing out that this is actually possible in Powershell Version 4!

New updated gif for the (final?) version of this answer.

Loading Gif

for(;;cls){"Loading... "+"|/-\"[($a=++$a%4)];sleep -m 250}

for(;;cls){"Loading... "+"|/-\"[$a++%4];sleep -m 250}

for(;;){"Loading... "+"|/-\"[$a++%4];sleep -m 250;cls}

for(;;$a++){"Loading... "+"|/-\"[$a%4];sleep -m 250;cls}

for(;;){$a++;"Loading... "+"|/-\"[$a%4];sleep -m 250;cls}

Windows Batch, 121 114 84 80 79 78 bytes

Just throwing this out for fun.

for %%b in (/ - \ ^|)do (cls
@echo Loading... %%b
ping 1.1 -n 1 -w 250>nul)
%0

I was not able to assign pipe (|) into the array, so I had to manually add it with another assignment. The delay is done with PING, which might not be accurate.

Output:

enter image description here

Edit:

Batch, 88 81 77 bytes

:1
@FOR %%G IN (/,-,\,^|) DO @(echo Loading...%%G
timeout/t 1 >a
cls)
@goto 1

GIF

(My first answer on Code Golf...)

F# (interactive), 81 bytes

async{while 1>0 do for c in"|/-\\"do printf"\rLoading... %O"c;do!Async.Sleep 250}

In order to run it in F# interactive, you have to pass it to Async.Start or Async.RunSynchronously.

For reference, a little longer non-async version:

while 1>0 do for c in"|/-\\"do printf"\rLoading... %O"c;System.Threading.Thread.Sleep 250

and a slightly outdated gif :)

enter image description here

C#, 168 136 123 109 Bytes

Golfed:

void S(){for(int a=0;;a++){Console.Write("\rLoading... "+"|/-\\"[a%=4]);System.Threading.Thread.Sleep(250);}}

Ungolfed:

void S()
{
    for(int a = 0; ; a++)
    {
        Console.Write("\rLoading... " + "|/-\\"[a%=4]);
        System.Threading.Thread.Sleep(250);
    }
}

See it working here:

enter image description here

Edit: Simplified the array.

Edit2: For is way better for this.

NASM x86_64 - 349 283 bytes

This should be run 64 bit linux systems

built using:

nasm loading_golfed.asm -felf64 && ld loading_golfed.o

%use altreg
global _start
section .data
o:db"Loading...  "
s:db"|/-\\"
b:db`\bx`
q:dq 0,250000000
_start:mov r0,1
mov r7,1
mov r6,o
mov r2,12
syscall
mov r2,2
l:mov r7,1
mov al,[s+r8]
mov [b+1],al
mov r0,1
mov r6,b
syscall
mov r0,35
lea r7,[q]
mov r6,0
syscall
inc r8
and r8,3
jmp l

animation:

saved 65 bytes - thanks user254948

enter image description here

Scala, 86 bytes

def t(i:Int=0):Any={print("\b"*12+"Loading... "+"|/-\\"(i));Thread sleep 250;t(i+1&3)}

Explanation:

def t(i:Int=0):Any={ //define a method t
  print(               //print...
    "\b"*12+             //a backspace character repeated 12 times to delete everything
    "Loading... "+       //the string "Loading... 
    "|/-\\"(i)           //and the i-th char of the char in question
  );
  Thread sleep 250;    //sleep 250ms
  t(i+1&3)             //call t with i incremented by one, but capped at 3
}

Like most other answers, it looks pretty standard console-like.

Befunge 98, 61 bytes

Requires the HRTI (High Resolution Timers) fingerprint.

"ITRH"4(v
"g2:%4+1<,M',*93,aj*-d0`T**::?'M,kb"Loading...
|/-\

Waits 250047 (63^3) microseconds using a busy loop, using the M (mark) and T (returns the number of microseconds since the last mark) instructions from the "HRTI" fingerprint.

After each line, it outputs "\n\eM", to force a flush, and reposition the cursor.


Version for terminals using 8-bit encodings with proper support for C1 control codes (59 bytes):

"ITRH"4(v
"g2:%4+1<,+f~',aj*-d0`T**::?'M,kb"Loading...
|/-\

This version outputs "\n\x8d" after each line. "\x8d" is the 8-bit equivalent of 7-bit "\eM", and is supported by e.g: xterm +u8 (xterm not in UTF-8 mode).

Ruby, 57 bytes

Same length as Conor O'Brien's answer, but a different approach:

%w(| / - \\).cycle{|c|$><<"Loading... #{c}\r";sleep 0.25}

Forth, 72, 73 bytes

EDIT:

Golfed

: L '| '/ '- '\ begin .\" \rLoading... " 3 roll dup emit 250 ms again ; L

Gforth version

The GNU Forth-only version can be brought down to 69 bytes like this:

'| '/ '- '\ [begin] .\" \rLoading... " 3 roll dup emit 250 ms [again]

Screencast

enter image description here

Try it online !

T-SQL, 239 182 162 159 153 152 149 bytes

Golfed:

DECLARE @c CHAR(5)='|/-\',@s CHAR,@ INT WHILE 1=1BEGIN SET @=1WHILE @<4BEGIN SET @s=(SELECT SUBSTRING(@c,@,1))PRINT'Loading... '+@s SET @=@+1 END END

Ungolfed

DECLARE @c CHAR(5) = '|/-\',
        @s CHAR(1),
        @ INT;
WHILE (1 = 1)
BEGIN
    SET @ = 1;
    WHILE (@ < 4)
    BEGIN
        SET @s = (SELECT SUBSTRING(@c, @, 1));
        PRINT 'Loading... ' + @s;
        SET @ = @i + 1;
    END
END

C# - 111 bytes

Just added some "creative [ac]counting" to existing C# answers.

void G(){for(var i=0;;i=i%4+1){Console.Write("\rLoading... "+"|/-\\|"[i]);System.Threading.Thread.Sleep(250);}}

Human readable version.

void G()
{
    for (var i = 0; ; i = i % 4 + 1)
    {
        Console.Write("\rLoading... " + "|/-\\|"[i]);
        System.Threading.Thread.Sleep(250);
    }
}

MS-DOS .COM file, 56 bytes

Here the file content in hexadecimal:

b4 09 ba 2c 01 cd 21 b2 2f e8 11 00 b2 2d e8 0c
00 b2 5c e8 07 00 b2 7c e8 02 00 eb ea b4 02 cd
21 b2 08 cd 21 b9 05 00 f4 e2 fd c3 4c 6f 61 64
69 6e 67 2e 2e 2e 20 24

The matching assembler code looks like this:

    mov ah, 9      ; Print "Loading... "
    mov dx, text
    int 21h
theloop:
    mov dl, '/'    ; Call "chrout" for "/", "-", "\" and "|"
    call chrout
    mov dl, '-'
    call chrout
    mov dl, '\'
    call chrout
    mov dl, '|'
    call chrout
    jmp theloop    ; Endless loop

chrout:            ; Sub-Function "chrout"
    mov ah, 2      ; Output the character
    int 21h
    mov dl, 8      ; Output backspace
    int 21h
    mov cx,5       ; Call "HLT" 5 times
timeloop:
    hlt            ; Normally HLT will wait ~55 milliseconds
                   ; (Assuming no keyboard key is pressed)
    loop timeloop
    ret            ; End of the function

text:
    ASCII "Loading... ",'$'

Python 3, 86 83 bytes

GIF to follow. Golfing suggestions welcome as this is still a little verbose. -3 bytes thanks to Flp.Tkc.

import time
i=1
while i:print(end="\rLoading... "+"/-\|"[i%4]);time.sleep(.25);i+=1

Ruby, 66 59 58 57 bytes

I saved 7 bytes when I remembered ruby's loop syntax. -1 byte thanks to manatwork (changed print to $><<)! -1 byte thanks to daniero!

loop{$><<"Loading... #{'|/-\\'[$.=-~$.%4]}\r";sleep 0.25}

Decently self-explanatory. Uses the nice fact that '...' strings don't need to have double-escapes I had to rework the string, so now the \ is at the end and must be escaped.