← I/O & Debugging · guided lesson

Fast I/O, Judges & Debugging

1 / 18 · story

the story

Standard input and output

Every tool here exists because something was too slow or broke without it. Here is what.

1969–72 · Ken Thompson, Dennis Ritchie and Doug McIlroy at Bell Labs (Unix)

Early Unix gave every program two ready-made files: standard input and standard output (file descriptors 0 and 1). The shell's < and > swapped them for files, so a program never needed to know where its data came from. Pipes appeared in 1972 at Doug McIlroy's suggestion, chaining one program's output into the next one's input. Online judges use exactly this: the test file becomes your stdin, and your stdout becomes a file they compare.

the problem it solved

Programs could be combined and tested without changing their code — just by redirecting where input comes from and where output goes.

why it matters: without it

Every program would need to know file names, and a judge couldn't run any submission the same way.

sources: Dennis M. Ritchie, The Evolution of the Unix Time-sharing System (1979; BLTJ 1984) ↗

also in this chapter: Fast input and output in Java · Online judges and verdicts · Exceptions and the call stack · Assertions (assert) · Debugging and testing your own code