"lovecreatesbea ...@gmail.com" <lo************ ***@gmail.comwr ote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
Could you extract examples of the characteristics of C itself to
demonstrate what the advantages of C are? What are its pleasant,
expressive and versatile characteristics ?
This is a history lesson from my personal experiences. Despite it being a
bit long, I hope you take the time to read it.
I've programmed in a number of languages: C, PL/1, 6502 assembly, x86
assembly, FORTH, Pascal, Fortan, BASIC, etc.(fourteen total). I haven't
experienced newer languages like C++, PHP, Java, etc., or object oriented
ones: C++, Smalltalk. Given that, two of the things I value most in a
language are: 1) ease of programming and 2) pointers (which correspond to
addresses in assembly). Most of the languages I've experienced, fail both
of those. The exceptions are: C, PL/1 (or PL/I), FORTH and, perhaps, Pascal
(today).
PL/1, a precursor to Pascal, was basically Pascal (with pointers, like C),
and record structures that were supposedly based on COBOL. One big
difference was that variables were passed by reference. This _greatly_
eased programming. In hundreds of thousands of lines of code I wrote, there
were only two situations where I had to tell the compiler to pass by value.
Unlike C, one (basically) never had to be concerned about whether you were
passing in a value or an pointer to a function or procedure... Strings were
a fundamental type, but due to the way they were implemented for the machine
I programmed, I still viewed them as problematic.
FORTH is syntax free and not usually taught in academic settings. The
biggest problems are that 1) you have to think in terms of objects on the
stack like assembly, 2) you have to learn RPN, 3) the default words are
somewhat cryptic if you don't know assembly, and 4) you can't usually
generate compiled code. The last one is a big disadvantage. It's
interpreted like BASIC, so development is quick. That is an advantage.
Assembly can be trying, because there usually isn't an easy method to create
named variables or larger data types likes structures. In assembly,
everything is referenced by register name or memory address. So, where is
my loop counter? Did I put it in eax, esi, memory, zero page (6502
reference...).. . Did it get relocated or saved by the linked C code?
FORTRAN, as I experienced it, which was a few decades ago, was a complete
****ing nightmare. The only thing good about it was that numerical results
were accurate... Otherwise, I can't say anything good about it at all.
Hopefully, Fortran has been heavily modified since then.
Pascal, when I learned it, had limited pointer functionality. It was an
example of safe programming practices like Java. For the most part, the
language was easy to learn but didn't seem powerful (which I attribute to
the lack of actual pointers and inability to access the OS). Apparently, a
more complete type of pointer was added in the early '90's with a new
standard.
BASIC had the easiest method of string manipulation. This is the thing I
remember the most about BASIC. It was so easy, that I usually create the
MID$,LEFT$,RIGH T$, and a concatenation function when I'm programming in
languages other than C. C has less easy to use duplicate funtionality. The
other thing I remember is how much quicker it was to test and develop
programs. Compiling and running C over, and over again, is much slower.
As for C, it isn't as easy as Pascal, it can't do strings as easy as BASIC,
it is slower to develop in than BASIC or FORTH, it can't pass data as easy
as PL/1, but it captures the abilities of most early CPU's and modern RISC
CPU's. It's real strength is the closeness of it's featureset to assembly
language, named variables, and pointers. It's not that it's standardized or
somewhat portable or whatever excuse the others here want to promote.
And what are its disadvantages?
In addition to what I mentioned above,
1) There is no way to determine from a pointer in C what data it is pointing
to. You can point it to one variable and then reuse it to point into the
middle of another. This can cause programming errors and prevents
optimizations by the C compiler. (Yes, unfortunately, one of my preferred
language features is a hindrance to compiler advancement.)
2) C is frequently implemented using a single stack. This means that flow
control information (if, while, procedures, etc.) is stored on the same
stack as data. This allows for various stack overflow/underflow exploits or
programmer error.
etc...
Rod Pemberton