Hi,
I've read several questions and often the answer was
'C knows nothing about [lots of different stuff here].'
Absolutely correct.
So if C knows that little as some people say, what are the benefits, I
mean do other languages know more or is it a benefit that C knows nearly
nothing (what I can think about is that C is the largest common divisor
defined on most available platforms)?
Other languages may know more: one language about this, another about
that and so on.
But C is designed to be present on an abstract mashine. That means
that mashine has no real device - but abstract streams, whereas
streams are diveded into:
inputstream - an stream that delivers characters from something
that is able to deliver characters, like
- a terminal with unkown behavior
- a file, where the programmer has no more knowledge
about as it can send a stream of characters
- a pipe
outputstream - a stream that receives characters from the
the program and sends it to somewhere that is able to
receive characters like
- a terminal with unknown behavior
- a file, where the programmer has no more knowledge
about as that it can receive a stream of characters
- a pipe
There are trillions of OSes on the market whereas each OS has its own
set of APIs.
Most of them have at least a C interface - but nothing (except of the
documentation of the OS) exists that defines which APIs are exist,
which kind of parameters, how many parameters and which sequence of
parameters they use. Some OSes have a number of subsystems, each with
theyr own set of APIs. C knows nothing of them! There are some
libraries are around who are fullifies different kints of work (like
linked lists, database access (different kinds of databases),
mathematical functions, different kinds of printers, scanners, tapes,
and so on, and so on... None of them have to do a bit with C - except
that many have interfaces, designed to be used by C programs.
Many of them are written in C with some properitary extensions
included, some are written in other programming languages, but with
interfaces to C programs included.
This question came to my mind when I was reading "Serial Number of the
Hard Drive" (Message ID:
[email protected]).
Because I often read 'Unix is written in C' I'm asking myself how an OS
can be written in C if it knows nothing about anything.
Oh yes, C knows absolutely nothing about that - but the OS has sets of
APIs, designed to be used from C programs. One or more of that is able
to ask the OS for the required information, others to write it, .....
C is a land of a programming language designed to be extended to do
anything a programmer may ever have in mind. But each extension is
more or less properitary and is NOT simply C as defined by the ANSI
standard. Many of thiese extensions have theyr own newsgroup (or more
than one!) whereas this extension is on topic.
C itself is nothing than a naked language with some syntax
constraints, a set of rules to programmers of C compilers, C
implementations, hosted and free standing environments and a bit less
strong for programmers of applications.
A free standing environment is an environment whereas is nothing known
than the hardware a C program has to run on. This means: absolutely no
I/O (as C knows absolutely nothing about devices), a minimum about
pointers (accessing a NULL pointer results in undefined behavior, a
NULL pointer is defined INSIDE a C source as binary 0 - even as the
mashine itself may use some other bitpattern to represent it (it is on
the compiler to make a binary 0 comparing to this bitpattern in
pointer context).
A hosted environment has knowledge about the underlying OS, so it can
use it to make the streams to connecting and correspondence to the
device in a standardised manner. The OS can, but must not deliver a
more complex set of APIs to C programs - but thiese are only
interfaces, defined by the OS, not the C.
And please stay on the newbiest level possible so I can understand that or
just tell me to wait 'till I learned more
All that above can be reduced to:
comp.lang.c handles the language C and its assigned standard library -
but it has nothing to do with properitary interfaces to a spezific OS
or device or library.
You may use C to write an OS (then you uses a free standing
environment, whereas you has to write any bit of I/O by yourself).
You may use C as defined by the ANSI C standard(s) (there are more
than one created over the years C exists now). Then you can use the
standard C library. Whereas the C library itself defines a set of APIs
to make some basic things (e.g. string handling, memory handling,
streamed IO and so on). All these is on topic here.
You may use C in the way your OS extends it - but this lts you alone
in one of the newsgrous defined to programm with the OS you're working
under, as this has nothing to do with C. You may use some libraries
created for doing special work - but then you have to find a newsgroup
that handles this specific library, because this library has nothing
to do with C, even if it is written itself in C.
That is because the language C and its standard library
- is itself complex enough to justify its own newsgroup
- knows nothing about real devices, because
handling with real devices is object of the OS
and the real hardware and has nothing to do with C
- is designed to work on an abstract mashine
that defines anything one needs to write a
C program in, whereas a C compiler for a
real mashine is able to produce code running
on it. It will give you more or less possibilities
to use properitary extensions - but these extensions
are not C as defined by the standard and unportable.
- is designed to be portable to any real mashine
that ever had/will be exist. But it lefts open
anything that is only defineable on a real mashine.
So using something that is only defined on a
properitary mashine makes the program incompatible and
at least unportable - and so you leaves the standard.
In short: Whenever you have a question about C, you're
welcome here. Whenever you have a question about something
C knows nothing about you have to go to a group that
knows about that.
--
Tschau/Bye
Herbert Rosenau
http://www.pc-rosenau.de eComStation Reseller in Germany
eCS 1.1 german is in beta testing