Update
This commit is contained in:
parent
2c518b91ca
commit
3816e78230
19 changed files with 1805 additions and 1802 deletions
4
io.md
4
io.md
|
@ -1,6 +1,6 @@
|
|||
# Input/Output
|
||||
|
||||
In [programming](programming.md) input/output (I/O or just IO) refers to communication of a computer [program](program.md) with the outside environment, for example with the [user](user.md) in [real world](irl.md) or with the [operating system](os.md). Input is [information](information.md) the program gets from the outside, output is information the program sends to the outside. I/O is a basic and very important term as it separates any program to two distinct parts: the pure [computational system](computational_system.md) (computation happening "inside") and I/O which interconnects this system with the real world and hence makes it useful -- without I/O a program would be practically useless as it couldn't get any information about the real world and it couldn't present computed results. In [hardware](hardware.md) there exists the term "I/O device", based on the same idea -- I/O devices serve to feed input into and/or get output from a physical [computer](computer.md), for example keyboard is an input device and monitor is an output device (a computer without I/O devices would be useless just as a program without I/O operations).
|
||||
In [programming](programming.md) input/output (I/O or just IO) refers to communication of a computer [program](program.md) with the outside environment, for example with the [user](user.md) in [real world](irl.md) or with the [operating system](os.md). Input is [information](information.md) the program gets from the outside, output is information the program sends to the outside (note that "outside" doesn't mean just world physically outside the computer case but anything outside the program's inner state, i.e. for example a file on the disk is also "outside"). I/O is a basic and very important term as it separates any program to two distinct parts: the pure [computational system](computational_system.md) (computation happening "inside") and I/O which interconnects this system with the real world and hence makes it useful -- without I/O a program would be practically useless as it couldn't get any information about the real world and it couldn't present computed results. In [hardware](hardware.md) there exists the term "I/O device", based on the same idea -- I/O devices serve to feed input into and/or get output from a physical [computer](computer.md), for example keyboard is an input device and monitor is an output device (a computer without I/O devices would be useless just as a program without I/O operations).
|
||||
|
||||
Note that I/O is not just about communication with a human user, it also means e.g. communication over [network](network.md), reading/writing from/to [files](file.md) etc.
|
||||
|
||||
|
@ -12,7 +12,7 @@ This is because **I/O is inevitably messy**: an abstract, portable I/O library r
|
|||
|
||||
How to solve this? By separating I/O code from the "pure computation" code, and by minimizing and [abstracting](abstraction.md) the I/O code so that it is easily replaceable. Inexperienced programmers often make the mistake of mixing the pure computation code with I/O code -- it is then very difficult to replace such I/O code with different I/O code on a different platform. See [portability](portability.md) for more detail. Also if you don't have to, **avoid I/O altogether**, especially if your project is a library -- for example if you're writing a 3D rendering library, you do NOT actually need any I/O, your library will simply be computing which pixels to draw and what color they should have, the library doesn't actually have to write those pixels to any screen, this may be left to the user of the library (this is exactly how [small3dlib](small3dlib.md) works).
|
||||
|
||||
Also remember the ancient [Unix](unix.md) wisdom: "Text is universal interface".
|
||||
Also remember the ancient [Unix](unix.md) [wisdom](wisdom.md): "Text is universal interface".
|
||||
|
||||
I/O also poses problems in some programming [paradigms](paradigm.md), e.g. in [functional programming](functional.md).
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue