g | x | w | all
Bytes Lang Time Link
038Swift 6 Linux w/ C interop230712T030134ZmacOSist
015Ruby241003T183441ZJordan
015TIBasic TI84231224T164333ZMarcMush
011Uiua231224T062252Zchunes
030Minecraft Function230731T221811ZLostXOR
045Commodore BASIC Commodore C64/C128230627T130552ZShaun Be
026Racket230704T090515ZEd The &
028ARM Thumb machine code + Linux syscalls230715T082142Zlandfill
005Vyxal230628T190005ZThe Empt
002><> t0.5230710T001319ZJo King
112ELF x86/x64230709T215559Zengineer
022TIBasic TI84+230629T194802ZYouserna
038Python 2230629T152752ZDadsdy
019Javascript230626T060043ZDadsdy
004Japt230626T154530ZShaggy
005Vyxal j230629T102903Zemanresu
00505AB1E230629T095615ZKevin Cr
019GBZ80 machine code DMG mode230629T000602ZSNBeast
004*><>230628T125711ZBee H.
017PHP230627T101931ZKaddath
021Wolfram Language Mathematica230628T075058Zalephalp
013QBasic230627T173519ZDLosc
016PowerShell230627T171908Zuser3141
021Julia 1.0230626T181541ZAshlin H
039Python 3230626T053727ZAnttiP
019Perl 5230627T115304ZKjetil S
005Jelly230626T162614ZJonathan
036Nim230627T092414ZAdam
045C# Visual C# Interactive Compiler230627T073546ZLiefdeWe
093simply230627T001307ZIsmael M
nan230626T050135ZDadsdy
050Lua230626T214642Zbluswimm
006Bash + iputils230626T165924Zc--
010Charcoal230626T185136ZNeil
009Batch230626T104431ZNeil
014x8616 machine code230626T181213Z640KB
003MacOS shell230626T171853ZDigital
015GFABasic 3.51 Atari ST230626T153532ZArnauld
006Pyth230626T142859ZCursorCo
011shell + GNU/Linux core utils230626T102425Zmatteo_c
007MATL230626T091633ZLuis Men
023Arturo230626T082954Zchunes
025R230626T064810Zpajonk
030C gcc230626T065430Zdingledo
nanDesmos230626T062343ZAiden Ch
018Factor230626T060015Zchunes

Swift 6 (Linux w/ C interop), 41 40 39 38 bytes

import Glibc
while sleep(1)<1{print()}

Prints a newline every second. Needs import Darwin instead of import Glibc on macOS.

Swift 6 (pure), 55 bytes

while 0<1{print(try await Task.sleep(for:.seconds(1)))}

Ruby, 15 bytes

loop{p sleep 1}

Attempt This Online!

TI-Basic (TI-84), 15 bytes

startTimer
Disp Ans
Repeat checkTmr(Ans
End
prgmA

needs to be stored in prgmA for the recursion

based on and improved over Yousername's answer

Uiua, 11 bytes

⍥(&pπ&sl1)∞

Doesn't work online, but works locally.

⍥(&pπ&sl1)∞
⍥(       )∞  # infinite loop
     &sl1    # sleep for one second
  &pπ        # print pi

Minecraft Function, 30 bytes

say a
schedule function a:b 1s

Must be run as a function named b in a data pack named a. It prints [Server] a to chat once per second.

The first command simply says a, and the second command schedules the function to execute again in one second.

Commodore BASIC (Commodore C64/C128, C16/+4, VIC-20, PET), ~61 ~45 tokenised BASIC bytes

0printti$:b=val(ti$)+1
1ifval(ti$)<bthen1
2goto

This works by using the Commodore TI$ system variable. Firstly, this outputs the value of TI$ to the screen (which is in HHMMSS format). It then take the value of TI$ as a number and add one to it. It then waits until the current numeric value of TI$ is no longer a less significant number than the B variable, and then we GOTO line 0 to output the new value of TI$ to the screen. This continues until the STOP key is pressed, which will break the program (it may be continued with the CONT command).

Screenshot reflects an older iteration of this entry.

Output each second running on a Commodore C64

Racket, 43 37 28 26 bytes

Changelog

  1. Thanks to @Dadsdy for the -2 bytes.
  2. The -4 bytes comes from converting #lang racket to #!racket.
  3. Another -9 as I found out that language statements may go into the header of TIO, and as such, don't contribute to number of bytes.
  4. I just learnt about Racket's do loop! -2 bytes! 🎉

Code

(do()(#f)(write(sleep 1)))

Try it online!


Explanation

We create a do loop that runs infinitely. Since we used #f (false) in dos second argument, the loop won't terminate as it will only terminate if there is a #t value.

If we were to expand this out and make it more readable, it would look like this:

(do () (#f)
  ; (sleep 1) doesn't return anything, so #<void> will be printed.
  (write (sleep 1)))

The do loop acts a bit similar to JavaScript's while loop:

while (!false) {
  // ...
}

ARM Thumb machine code + Linux syscalls, 28 bytes

00: 2202       movs r2, #2    // 2 bytes
02: 2704       movs r7, #4    // write()
04: 2001       movs r0, #1    // stdout
06: a104       adr  r1, #0x18 // pointer to 0x18 "!\n"
08: df00       svc  #0        // syscall write(1, "!\n", 2)
0a: 27a2       movs r7, #162  // nanosleep()
0c: a001       adr  r0, #0x14 // pointer to 0x14
0e: 2100       movs r1, #0    // NULL
10: df00       svc  #0        // syscall nanosleep(&{1, 2593}, 0)
12: e7f6       b.n  #0x02     // jump to 0x02, r2 won't have changed
14: 0000 0001  .word 1        // 1 second
18: 0000 0a21  .word 0x0a21   // "!\n" or 2593 nanoseconds

Vyxal , 5 Bytes

{1¨w,

Try it online (collects all the output received in ten seconds (or sooner if it halts) and prints it all at once.)

><> -t0.5, 2 bytes

1n

Try it online!

><> has an extra flag to set the time between ticks, presumably to help with debugging. This code simply outputs a 1 every 2*0.5 seconds.

ELF (x86/x64, Linux), 112 bytes

Prints 'A' about once per second, indefinitely.

00000000: 7f45 4c46 fec0 505f e81b 0000 0000 0000  .ELF..P_........
00000010: 0200 3e00 0000 0000 0400 0000 4100 0000  ..>.........A...
00000020: 3800 0000 0000 0000 5e40 80c6 3f50 5a0f  8.......^@..?PZ.
00000030: 0504 2256 eb32 3800 0100 0000 0500 0000  .."V.28.........
00000040: 0000 0000 0000 0000 0000 0000 4100 0000  ............A...
00000050: 0100 0000 0000 0000 7000 0000 0000 0000  ........p.......
00000060: 7000 0000 0000 0000 5faf 0f05 eb96 0000  p......._.......

Try it online! (Prints 60 A's before TIO kills the process)

Explanation

The file abuses a lot of undefined behavior within the Linux ELF loader; the kernel is able to make a lot of (correct) assumptions when certain fields are not the right value. Here is the full NASM source.

Basically, the executable is just an ELF header, a program header (partially merged into the ELF header), and the actual program (which is spread throughout the two headers so that it doesn't take up any additional space). The full program calls sys_write(stdout, "A", 1), then sys_nanosleep({tv_sec=1, tv_nsec=112}, <nonsense valid pointer>), and then loops back to the start.

TI-Basic (TI-84+), 22 bytes

startTmr
While 1
If checkTmr(Ans:Then
Disp Ans
startTmr
End
End

Python 2, 38 Bytes

import time
while[time.sleep(1)]:print

TIO

Javascript, 22 20 19 Bytes

Thanks to @Kaiido for -2 Bytes Thanks to @Elias Holzmann for -1 Bytes

setInterval({},1e3)

https://jsfiddle.net/ry2sgkz7/

Japt, 7 4 bytes

Outputs a ReferenceError.
Any lowercase letter word work instead of the second i.

A³ii

Test it (Open your browser's console)

Vyxal j, 5 bytes

⁽kNḞU

Don't Try it Online! - it doesn't work there.

This one's kind of hilarious. It creates an infinite list of times, and then uniquifies them. The j flag is necessary due to how Vyxal handles printing infinite lists.

   Ḟ  # Generate an infinite list from...
⁽     # A function that returns
 kN   # The current time of day (hh:mm:ss)
    U # Get unique values

enter image description here

05AB1E, 5 bytes

[₄=.W

Keeps printing 1000\n every second.

Try it online.

Explanation:

[      # Start an infinite loop:
 ₄     #  Push 1000
  =    #  Print it with trailing newline (without popping)
   .W  #  Pop and sleep that many milliseconds

GBZ80 machine code (DMG mode): 19 bytes

21 0F FF 3E 01 E0 FF 06 78 76 70 05 20 FB 2F E0 47 18 F4

Assembly:

Entrypoint:
    ld hl, $ff0f
    ld a, $01
    ldh [$ffff], a ; only accept vblank interrupts

.outerLoop:
    ld b, 120

.innerLoop:
    db $76 ; directly encoded halt. saves one byte over "halt" in my assembler.
           ; since by deliberate design IE & IF is sometimes not zero here, we encounter the halt bug. fortunately, "ld [hl], b" is a one byte instruction whose duplication is, excluding time, transparent (with exceptions that would be familiar to those who encounter them)
    ld [hl], b ; discard the pending interrupt every other pass (even parity)
    dec b
    jr nz, .innerLoop

    cpl
    ldh [$ff47], a ; invert the palette
    jr .outerLoop

This is just counting vblanks, with some mangling to save a single byte from not loading an immediate to clear the vblank interrupt flag. The effect produced every second is inverting the screen colors. This does not work in CGB mode because the register for the DMG background palette does nothing in CGB mode.

*><>, 4 bytes

Prints "10" on startup, and once every second

a:nS

Try it online!

Explanation

a      # Push 10 onto the stack
 :     # Duplicate it
  n    # Pop a value off the stack, and print it as a decimal number
   S   # Pop a value off the stack, and sleep for 100ms * the popped value

PHP, 22 21 17 bytes

for(;;a)sleep(1);

Try it online!

I think the naive approach will be the shortest here. On TIO the output will be visible only when stopping the program of course

EDIT: saved 1 byte by echoing the falsey result of sleep, it works because sleep returns zero instead of false which would have lead to an empty string

EDIT 2: stole the suggestion from this JS answer by triggering a warning instead of an echo

Wolfram Language (Mathematica), 21 bytes

Dynamic@Floor@Clock@2

A dynamic object that alternates between 0 and 1 every second. This only works in the Notebook interface, so no TIO link.


Wolfram Language (Mathematica), 23 bytes

Echo@True~While~Pause@1

Try it online!

Prints True every second.

QBasic, 13 bytes

I'm not sure how rules-bendy to get, but here's the shortest possible version:

?
SLEEP 1
RUN

You can try it at Archive.org.

Explanation

?        ' Print a blank line
SLEEP 1  ' Wait 1 second
RUN      ' Restart the program

Once the screen is filled up with blank lines, you won't be able to see new output happening, and you can't select the outputted text. So here's a 15-byte version that will be visually different each time something is printed:

?0;      ' Print 0 without a newline
SLEEP 1  ' Wait 1 second
RUN      ' Restart the program

PowerShell, 16 bytes

Paste it into a PS console (Windows or Core) (not using TIO because that will only show the output once the script is stopped):

for(){sleep 1;1}

Will print 1 every second until Ctrl-C is pressed.
Nothing remarkable, just for the sake of completeness when it comes to languages.

Julia 1.0, 24 21 bytes

!x=!show(sleep(1))
!0

Try it online!

-3 bytes thanks to ovs: improve recursion, and redefine an operator (An argument has to be passed to it, but this can be ignored by the function)

Python 3, 40 39 bytes

import time
while[help()]:time.sleep(1)

Try it online!

Improved by Sisyphus

Perl 5, 19 bytes

say 2 while sleep 1

Try it online!

Jelly, 5 bytes

1œSṄ¿

A full program which prints 1 and a newline and then after (just over) one second has elapsed prints another, then repeats this step forever.

It's "just over" as it takes some time to do the work. The first pause could take more than 1 second on slow hardware as Jelly has to initialise Python, and itself (create an interpreter, import some cruft, etc.) and parse the code. Subsequent pauses are unlikely to be over the 1.01 second threshold however as it just needs to check that the result is truthy and print to STDOUT.

Try it online! (TIO does not output anything as a program runs, but kill it while in flight and take a look; killing within a second should give a single 1 in the "Output" section, leaving it running longer should give more outputted 1s for each second that passed.)

How?

1œSṄ¿ - Main Link: no arguments
1     - set the left argument to one
    ¿ - while...
 Ṅ    - ...condition: print {left=1} and a newline, and yield {left=1}
  œS  - ...action: sleep for {implicit right=left=1} seconds and yield {left=1}

Replace with Ȯ for no newlines.

Nim, 36 bytes

import os
while 0<1:echo 1;sleep 999

Attempt This Online!

C# (Visual C# Interactive Compiler), 45 bytes

Nothing special

for(;;){Thread.Sleep(1000);Console.Write(1);}

Try it online!

simply, 93 bytes

Outputs a 9x9 image with a random color, every 999 milliseconds - which is within the 10ms error range.

%C=run!CANVAS->init(9,9)run%C->ontick(fn()=>run%C->fillRect(0 0 9 9run%C->getRandomColor)999)

It does exactly what it's supposed to.


Ungolfed

This code does exactly the same.

$fn = anonymous function() {
    $color = call %canvas->getRandomColor();
    call %canvas->fillRect(0, 0, 9, 9, $color);
};

%canvas = call !CANVAS->init(9, 9);
call %canvas->ontick($fn, 999);

I'm too lazy to write a full English-like version.


If you need more information, to confirm it does do what it's supposed to do, just add this after the code:

// Golfed version:
call %C->showDebug();

// Ungolfed version:
call %canvas->showDebug();

To make sure it is running, just check that the (manually) underlined value changes at a rate of ~1 second:
Debug output

That value represents the number of frames that were actually drawn.
By default, the code avoids re-drawing the canvas if there were no updates.
And each call to fillRect will trigger a single update.

You can replace ontick with onframe or onclick to verify that the value really represents what I've said.

(,), 60 62 61 Chars or \$61\log_{256}(3)\approx\$ 12.09 Bytes

((),((()))((())))((()),((())))(,((()),(),(),,((())),()),,,())
((),((()))((()))) Sets variable 1 to -2.
((()),((()))) sets variable -2 (time) to itself. (AKA setting the current time to 0)
(, Start of loop
((()),(),(),,((())),()) If variable -2 (time) is at least 1, reduce it by 1 and output 1\n
,,,()) Loop forever

First solution sometimes had the second output less than a second after the first.

Lua, 50 bytes

o=os.time::a::t=o()repeat until t<o()print()goto a

Try it online!

A platform independent solution. You can make this shorter by using os.execute, but that solution is both platform dependent and not very interesting.

Bash + iputils, 6 bytes

ping 0

send ICMP ECHO_REQUEST to 0 (127.0.0.1) once per second.


Bash + procps-ng, 8 bytes

free -s1

Display amount of free and used memory in the system with one second between outputs.

Charcoal, 10 bytes

RWφψPI¬ΣKK

Try it online! Link is to verbose version of code. Uses control codes to toggle the top left corner between 1 and 0, so on TIO you need to let it run for a few seconds and then interrupt it to see the control codes and 1s and 0s. Explanation:

RWφψ

Repeat indefinitely, showing the current canvas with a 1000ms delay on each repeat.

PI¬ΣKK

Toggle the current character between 1 and 0.

Batch, 15 13 9 bytes

ping -t 0

After some initial output, outputs the following every second:

PING: transmit failed. General failure.

Edit: Saved 4 bytes thanks to @c--.

Previous 15-byte solution:

timeout/t 1
%0

Repeatedly outputs the following:


C:\Users\Neil>timeout/t 1 

Waiting for 1 seconds, press a key to continue ...0

C:\Users\Neil>262205.bat

When output is to the screen, the cursor is moved so that the 0 overwrites the 1.

x86-16 machine code, PC DOS, 14 bytes

00000000: b42c cd21 3ac6 74fa 8ac6 cd29 ebf4       .,.!:.t....)..

Listing

B4 2C       MOV  AH, 2CH        ; DOS API get system time function 
        SEC_LOOP: 
CD 21       INT  21H            ; Read time: DH = seconds 
3A C6       CMP  AL, DH         ; second changed? 
74 FA       JE   SEC_LOOP       ; continue polling if not 
8A C6       MOV  AL, DH         ; save new second 
CD 29       INT  29H            ; write AL to console 
EB F4       JMP  SEC_LOOP       ; loop indefinitely 

A standalone executable DOS COM program. Spams the DOS time function and writes the corresponding ASCII codepoint for the number of seconds.

Several minutes later...

enter image description here

MacOS shell, 3

top

On the Mac, top's default refresh period is 1 sec.


Linux shell, 7

top -d1

Unfortunately on Linux, top's default refresh period is more like 2 secs, so we need an extra 4 bytes.

Since this is just one command, both variants are shell-agnostic.

GFA-Basic 3.51 (Atari ST), 15 bytes

A manually edited listing in .LST format. All lines end with CR, including the last one.

DO
?0
PA 50
LO

which expands to:

DO
  PRINT 0
  PAUSE 50
LOOP

We could use DELAY 1 instead of PAUSE 50. Unfortunately, the shortest unambiguous abbreviation of DELAY is DELA.

Output

After 5 seconds:

output

Pyth, 6 bytes

#.d
.j

Try it online!

Explanation

#        # loop forever until error (no error will occur)
   .j    # imaginary number i, printed
 .d      # sleep for abs(i) seconds

It may seem weird that I have to sleep for \$|i|\$ seconds, why not just 1? While that would save a byte, unfortunately .d1 is a predefined macro which returns the amount of time which has passed since the program started, which is not really useful for this challenge.

shell + GNU/Linux core utils, 11 bytes

watch -n1 w

A bit of a boring answer.

MATL, 7 bytes

`@D1Y.T

This displays the natural numbers in order. Try at MATL online!

How it works

`      % Do...while
  @    %   Push iteration index, starting at 1
  D    %   Display
  1    %   Push 1
  Y.   %   Pause for that many seconds
  T    %   Push true. This is used as loop condition, causing an infinite loop
       % End (implicit)

Arturo, 23 bytes

whileø[1:s>>{a}1pause]
whileø[     ; start infinite loop (while loop with null for condition)
    1:s     ; push duration of 1 second to stack
    >>{a}1  ; create/overwrite file named a
    pause   ; pause execution for one second (which we left on the stack earlier)
]           ; end while

R, 27 25 bytes

Edit: -2 bytes thanks to @Dominic van Essen.

repeat show(Sys.sleep(1))

Try it online!

This works well on my local machine, but TIO accumulates output until it finishes execution, so you don't see the progress.

C (gcc), 30 bytes

Prints a newline every second.

main(){main(sleep(puts("")));}

Try it online!

Desmos, 5+3+3+2=13 bytes

Ticker expression (5 bytes)

a->-a

Ticker repeat delay (3 bytes)

999

Main expressions (3 bytes)

a=1

2 bytes for "file boundaries" (treat each expression as a separate "file"; there are 3 "files", so there are two "file boundaries", as per this comment)

Try It On Desmos!

To run, click the ticker icon (the metronome) near the top left of the screen. This switches the variable a between the values 1 and -1 every 999 milliseconds. While this isn't outputting onto the console or stdin in the traditional sense, you can still clearly see the code switching between the 1 and the -1, which hopefully emulates outputting close enough.

Factor, 18 bytes

[ .s ] 1e9 every .

Try it online!

every calls a function each time a duration has passed. If every is not given a duration such as 1 seconds, and instead given a number, it defaults to nanoseconds. Thus, one billion (or 1e9) means one second. .s simply prints the contents of the data stack without consuming them, which in this case will print the timer object every uses to do its thing. The . at the end is necessary to satisfy the stack effect checker by removing the item on the data stack (because Factor programs must end with an empty stack), even though it will never be reached.