Or, to be more specific:

• Take no input.
• Output Loading..., with a trailing space, but no trailing newline.
• Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can overwrite just the last character, or delete and rewrite the whole line, as long Loading... remains unchanged.

Rules

• The output text must look exactly as specified. Trailing newlines/spaces are acceptable.
• You should not wait 0.25 seconds before initially showing output - the first frame should be printed as soon as the program is run.
• Your program should be able to run indefinitely. For example, if you use a counter for frames, the counter should never cause an error by exceeding the maximum in your language.
• Although the waiting period between each "frame" should be 0.25 seconds, obviously this will never be exact - an error margin of 10% or so is allowed.
• You may submit a function, but it must print to stdout.
• You can submit an answer in a non-console (but still text-based) environment, as long as it is capable of producing the loading animation.
• This is , so the shortest solution (in bytes) wins. Standard code-golf loopholes apply.

Example

Here is the C++ code I used to create the example (ungolfed):

#include <iostream>
#include <string>

using namespace std;

int main() {
string cycle = "|/-\\";
int i = 0;

while (true) {
// Print current character
cout << cycle[i];

// Sleep for 0.25 seconds

// Delete last character, then increase counter.
cout << "\b";
i = ++i % 4;
}
}


May the best golfer win!

• Can submissions wait 0.25 seconds before initially displaying output? – ETHproductions Nov 27 '16 at 20:42
• No, but thanks for mentioning that, I'll add it to the rules @ETHproductions – FlipTack Nov 27 '16 at 20:43
• Is a trailing newline (after the animating symbol) acceptable? – Copper Nov 27 '16 at 20:43
• Of course :) @Copper – FlipTack Nov 27 '16 at 20:44
• @TheBitByte it means that, theoretically, nothing inside your program will cause it to error - such as a counter overflowing or reaching maximum recursion depth. – FlipTack Dec 15 '16 at 6:57

PHP, 58 bytes

for(;;usleep(25e4))echo"\rLoading... ","\\|/-"[$i=++$i%4];


uses carriage return = overwrites the whole line. Run with -r.

• @user59178: The assignment is needed to avoid integer overflow. Can you tell me how to run code with single and double quotes with -r? – Titus Nov 28 '16 at 14:29
• Those are both excellent points, I probably should have actually tried running it, rather than just looking at the code.:-) – user59178 Nov 28 '16 at 15:36
• On 64-Bit php, it would take over 73 billion years to overflow. I think that's acceptably close to forever. Also, 57, no -r required: Loading... <?for(;;usleep(25e4))echo'\|/-'[$i=++$i%4],~÷; – primo Dec 2 '16 at 12:45
• @primo: I tried ^H, but it doesn´t seem to expand to chr(8) everywhere. And no idea what it depends on. – Titus Dec 8 '16 at 15:52
• If using -r, it will likely depend on the terminal. – primo Dec 8 '16 at 19:54

Pascal, 116114107 105 bytes

where is my head.. Thanks to @manatwork for shaving few bytes!

uses crt;var c:char;begin while 1=1do for c in'|/-\'do begin Write(#13'Loading... ',c);Delay(250)end;end.


Ungolfed:

uses
crt;    // CRT unit has Delay function

var
c: char;

begin
while 1=1 do
for c in '|/-\' do
begin
Delay(250)
end;
end.

• True1=1 and that way you can remove the following space too. – manatwork Nov 28 '16 at 10:26
• Better use a single output statement rewriting the entire line: Write(#13'Loading... ',c);. (BTW, no need for , between character and string literals.) – manatwork Nov 28 '16 at 10:32
• @manatwork - thanks, that makes more sense – hdrz Nov 28 '16 at 10:34
• Oh, and no need for the ; in front of 1st end. – manatwork Nov 28 '16 at 10:38
• Got it. have to eat something.... – hdrz Nov 28 '16 at 10:57

Java, 173 115 bytes

• Version 2.0

Changed to lambda function/Thanks to @Xanderhall and @manatwork/115 bytes:

()->{System.out.print("Loading...  ");for(int i=0;;Thread.sleep(250))System.out.print("\b"+"\\|/-".charAt(i++&3));}

• Version 1.0

Initial Version/173 bytes:

class A{public static void main(String[]a)throws Exception{System.out.print("Loading...  ");for(int i=0;;){System.out.print("\b"+"\\|/-".charAt(i++%4));Thread.sleep(250);}}}

• “Your program should be able to run indefinitely.” – This will terminate when reaches Integer.MAX_VALUE after 17++ years with “java.lang.StringIndexOutOfBoundsException: String index out of range: -3”. – manatwork Nov 28 '16 at 11:08
• Can't test but will it i&3 do? – Roman Gräf Nov 28 '16 at 14:27
• Also, you are allowed to submit a function. You can get rid of the class declaration and just have void a(){myfunction} format. – Xanderhall Nov 28 '16 at 14:39

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

• print$><< – manatwork Nov 28 '16 at 9:30 • @manatwork Oh, cool! – Conor O'Brien Nov 28 '16 at 12:09 • You can use $. instead of initializing i, as explained here. Saves at least two bytes – daniero Nov 30 '16 at 17:43

Noodel, noncompeting 24 25 bytes

Cannot compete because Noodel was born after the challenge.

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

“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

-->
Loop ----------------------------------------------------------------------------------------
Loop ----------------------------------------------------------------------------------------
Loop ----------------------------------------------------------------------------------------
Loop ----------------------------------------------------------------------------------------


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>

• This is a pretty neat language. Welcome to PPCG :) – FlipTack Dec 28 '16 at 0:01
• @FlipTack Thank you:) This place is like a giant playground:)lol – tkellehe Dec 28 '16 at 0:40

Befunge, 60 bytes

"  ...gnidaoL">:#,_v
"|/"<v*:*6"}",,8<
"\-"^>:#->#1_$:#^ _  Since Befunge doesn't have anything like a sleep command, the delay is approximated with a long running loop. This will obviously need to be adjusted depending on the speed of the system on which it is run. You can test it on the codingground website. Wonder, 50 bytes f\@(ol ++"�Loading... ":#0"\|/-";%%25e4;f +1#0);f0  Replace � with the actual carriage return \r. Explanation f\@(...);f0: Infinitely recursive function f. :#0"\|/-": Modular indexing using the function argument and the string "\|/-". ol ++"�Loading... ": Return cursor to beginning of line, concatenate previous result to Loading..., and output. %%25e4: Sleep for 250000 nanoseconds. f +1#0: Call f on the argument incremented. • Would this reach maximum recursion depth and crash? – FlipTack Nov 29 '16 at 6:51 • I don't think so, although I haven't tried running it for very long. Sort of weird, given that I should know how the interpreter works. – Mama Fun Roll Nov 29 '16 at 6:56 C#, 165 123 bytes Quite a few bytes saved thanks to raznagul ! z=>{Console.Write("Loading... ");for(int i=0;;i++){Console.Write(@"|/-\"[i%=4]+"\b");System.Threading.Thread.Sleep(250);}};  Anonymous function with no return type. The integer parameter z is only used as a placeholder in order to slash 1 byte off. If input was allowed, the value 0 (or any other multiple of 4 to start from the same character) could be used as the iterator, reducing the byte count to 116 bytes: i=>{Console.Write("Loading... ");for(;;i++){Console.Write(@"|/-\"[i%=4]+"\b");System.Threading.Thread.Sleep(250);}};  Full program with ungolfed function: using System; public class Program { public static void Main() { Action<int> a = z => { Console.Write("Loading... "); for (int i=0;;i++) { Console.Write(@"|/-\"[i%=4]+"\b"); System.Threading.Thread.Sleep(250); } }; a(0); } }  No GIF for now, since I'm having trouble with some dependencies on a slightly older Linux distro... The cursor is displayed on the last character, this behavior can be changed by adding a space in the Loading... string. • I think this doesn't fulfill the third rule a i++ will eventually throw an overflow exception. – raznagul Nov 28 '16 at 15:41 • It won't overflow, since i is assigned the modulo of division by 4 when printing the line (i%=4). – adrianmp Nov 28 '16 at 15:57 • +1 this is indeed clever. You can save a lot of bytes by printing Loading once and then printing "\b" instead of setting the cursor position. Also you don't have to define r. You can use @"|/-\"[...] instead. – raznagul Nov 28 '16 at 16:10 • I don't know if it is allowed. But you add on byte for the initialization of z and then you z instead of i, in total saving 6 bytes. – raznagul Nov 28 '16 at 16:16 Befunge 98, 61 bytes Requires the HRTI (High Resolution Timers) fingerprint. "ITRH"4(v "g2:%4+1<,M',*93,aj*-d0T**::?'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*-d0T**::?'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). Batch, 888177 bytes :1 @FOR %%G IN (/,-,\,^|) DO @(echo Loading...%%G timeout/t 1 >a cls) @goto 1  (My first answer on Code Golf...) • The @echo off line is costing you ten bytes. Would it be cheaper to simply place an @ on each command individually? Or is there some reason that doesn't work? – user62131 Dec 4 '16 at 8:48 • @ais523 It's giving me some errors... I'm working on it – rahuldottech supports Monica Dec 4 '16 at 8:50 • @ais523 Done! Turns out if you're using DO ( ) with FOR, you just need to put a single @: DO @( ) – rahuldottech supports Monica Dec 4 '16 at 8:57 • Since nobody's said it, welcome to code-golf! Nice answer – FlipTack Dec 4 '16 at 16:29 • Still better than my 100-byte bash answer! – ckjbgames Feb 3 '17 at 15:13 PowerShell, 1167769 67 bytes for(){[char[]]'|/-\'|%{write-host -n rLoading...$_;sleep -m 250}}


cleaner than cls?

• Welcome to PPCG! – FlipTack Dec 15 '16 at 19:14

ES8 + HTML, 68 bytes

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


C++11, 209207180175 164 bytes

This might have been a good use for the new C++ literals, saving std::chrono::milliseconds(250) to just write 250ms or 0.25s, but unfortunately this requires using namespace std::chrono; which is longer in the end.

-2 bytes thanks to Flp.Tkc for using #import instead of #include. Saving lot more thanks to Flp.Tkc, learning about \r and \b. -2 bytes thanks to myself for c[++i%=4]. -5 bytes thanks to Roman Gräf. -9 bytes thanks to kvill for indexing into the string literal directly.

#import<iostream>


Golfed your initial example. If it does not work in your console, you have to add <<flush to see any output for +7 bytes.

Ungolfed:

#import <iostream>

int main(int i) {
A:
goto A;
}

• Will i overflow? – Zacharý Nov 28 '16 at 13:43
• @ZacharyT Ah, yes it would and negative % positive = negative in C++. Rolled back. – Karl Napf Nov 28 '16 at 14:15
• Tip: use #import<...> to save a couple bytes :) – FlipTack Nov 28 '16 at 15:08
• No need to define c, just use ...<<"|/-\\"[++i%=4] for another couple of bytes. – kvill Nov 28 '16 at 18:47
• @kvill Thanks! That feels a little pythonish. – Karl Napf Nov 28 '16 at 19:03

Nim, 81 80 bytes

import os
while 1>0:


This may require flushing with stdout.flushFile in some terminals.

• don't know nim but can't you write the for loop directly after the while 1>0;? Also can you maybe remove the whitespace between in and '|/-\\":? – Roman Gräf Nov 28 '16 at 20:00
• @RomanGräf Thanks, but those changes are beyond Nim! – kvill Nov 28 '16 at 20:53

PowerShell 57 Bytes

for(){'|','\','-','/'|%{"loading...$_";sleep -m 250;cls}}  • Welcome to PPCG! You can save a byte by using a char array instead of explicitly calling out each character -- [char[]]'|\-/' – AdmBorkBork Nov 29 '16 at 16:53 • Right, @TimmyD, Thx! – jyao Nov 29 '16 at 17:21 Ruby, 75 72 bytes $><<'Loading...  '
c='|/-\\'.chars
loop{$><<?\b+c.rotate![0] sleep 0.25}  Mathematica, 90 bytes 85 bytes Significantly longer than A Simmons' answer, but with fewer visual frills. t=0;RunScheduledTask[t=Mod[t+1,4],1/4];Dynamic["Loading... "<>"|"["/","-","\\"][[t]]]  • Wow! "|"["/", "-", "\\"][[t]] looks awesome. nice one! :) – Dan Oak Nov 29 '16 at 4:54 • Nice job! I count only 86 bytes (using the two-byte [[ and ]] instead of the three-byte 〚 and 〛). You can also save a byte with 1/4 in place of 0.25. – Greg Martin Nov 30 '16 at 5:47 Dyalog APL, 45 bytes Uses ─ instead of -. {⍵⊣⎕DL÷4⊣⍞←⍵,⍨⊃⎕TC}¨⍣≢'|/─\'⊣⍞←'Loading... '  ⍞←'Loading... ' print the string without newline '|/─\'⊣ replace it with the string of bars {...}¨⍣≢ indefinitely apply the below function on each character ⊃⎕TC first Terminal Control character (backspace) ⍵,⍨ prepend the argument (a bar character) ⍞← output that without newline (this overwrites the previous bar) 4⊣ replace that with a four ÷ invert that (yielding 0.25) ⎕DL DeLay that many seconds ⍵⊣ replace with (and return) the original argument T-SQL, 239182162159153152 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  • Maybe you should try golfing this? – Cyoce Nov 29 '16 at 16:08 • @Cyoce down to 182. – Nelz Nov 29 '16 at 16:22 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. 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. 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: • Many commands in TI-Basic are 1-2 byte tokens, which may make it appear to be a byte miscount. • Due to TI-Basic's very limited character set, the following characters have been replaced: |\ with +*. • This will only run correctly on the newest version of a TI-84+ CE or CSE. C, 11911810291 88 bytes #import<windows.h> i;f(){for(;;)Sleep(19*printf("\rLoading... %c","\\|/-"[i=(i+1)%4]));}  • Could char *c be char*c? – Zacharý Nov 28 '16 at 21:20 • Can you move the assignment into the index, for(;;){printf("\b%c",c[i=i>2?0:i+1])...? – Zacharý Nov 28 '16 at 21:39 • Have a look at my submission... i=i>2?0:i+1 is identically i=(i+1)%4. He can use incrementation in the index, then modulo in the loop. – LambdaBeta Nov 28 '16 at 21:41 • He can also save a byte (I think) by completely flushing with \r so he doesn't need the extra space in the "Loading... " string. – LambdaBeta Nov 28 '16 at 21:42 • I don't know C, but would i=++i%4 work? – FlipTack Dec 28 '16 at 18:04 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.

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.

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>


Charcoal, 34 bytes

Loading... Ａ⁰αＨＷ²⁵⁰¦¹«Ａ⁺¹ααＰ§|/-\α


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

Java 7, 121 118 bytes

void f()throws Exception{for(int k=0;;k++){System.out.print("\rLoading...


Gif animation:

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(
;
i++
){
usleep(1<<17);
}
}
*/

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


compiled with gcc 4.9.4

• Welcome to the site! – DJMcMayhem May 25 '17 at 22:22

Bash, 62 bytes

c='|/-\';for((;;)){ echo Loading... ${c:d++%4:1}^[M;sleep .25;}  where ^[ represents ESC (ASCII 0x1b), which typically you can get by pressing CtrlV and then ESC. ESC M is RI, reverse linefeed. If you don't care about running indefinitely, you can save 2 bytes by using a recursive function: c='|/-\';f(){ echo Loading...${c:d++%4:1}^[M;sleep .25;f;};f


JavaScript (ES6), 90 bytes

(F=(i=0)=>{(c=console).clear();c.log('loading... '+'|/-\\'[i]);setTimeout(F,250,-~i%4)})()

• i will eventually overflow, since it just keeps going up without modulation. This can be fixed at no cost with c.log('loading... '+'|/-\\'[i]);setTimeout(F,250,-~i%4)` – ETHproductions Nov 29 '16 at 1:58
• @ETHproductions Good catch, the poor user would only have to wait a mere 71 billion years. – George Reith Nov 29 '16 at 12:17