Reputation: 33
I'm studying about C (ANSI) I/O and C (Unix) I/O and I have the following question:
If everything on a computer without abstraction is a stream of data(or dataflow, call it what you want), regardless of whether it came from a file or a socket, why do I need an abstraction layer called stream to handle this?
Upvotes: 0
Views: 225
Reputation: 180266
I'm studying about C ansi I/O and C unix I/O and i had the following question:
if everything on a computer without abstraction is a stream of data(or dataflow, call it what you want), regardless of whether it came from a file or a socket, why do I need an abstraction layer called stream to handle this?
I think you are confused about where the key abstraction lies: it is exactly the embodiment of the UNIX design philosophy that "everything is a file", realized in part by the fact that one set of low-level POSIX I/O functions handles all devices. Using those I/O functions is not accessing the computer without (device) abstraction.
On a POSIX system, you do not need streams, but it is often convenient to use them, at least because
On a non-POSIX system you possibly do need streams, because the low-level POSIX I/O functions may not exist. The latter are not specified by the C language standard, but rather by POSIX.
Upvotes: 0
Reputation: 241731
There are no abstractions inside a machine. The abstractions are all inside your head. "Dataflow" is an abstraction you use to think about very distinct mechanisms; if you view a computer "without abstractions", you won't see any "streams of data".
The "abstraction layer" is a concrete interface designed to make a bunch of complicated and idiosyncratic mechanisms controllable in a way which corresponds to the abstraction you use to design programs.
Upvotes: 2