After read a whole OS written by C, someone asks `What is the advantage of C'

L

lovecreatesbeauty

After read a whole OS written by C (e.g. UNIX 6th Edition written by),
at the end (yes, at the last line of the text of the last chapter),
someone (sure, it's John Lions) asks `What is the advantage of C' (is
it your question also).

lovecreatesbeauty
 
B

Ben Pfaff

lovecreatesbeauty said:
After read a whole OS written by C (e.g. UNIX 6th Edition written by),
at the end (yes, at the last line of the text of the last chapter),
someone (sure, it's John Lions) asks `What is the advantage of C' (is
it your question also).

Could you rephrase this question, in English this time?
 
T

Tom St Denis

Ben said:
Could you rephrase this question, in English this time?

I'll assume he's repeating the question from the text, "What is the
advantage of C" I have to ask compared to what?

I mean C lets you do manual computations easily. But so does any other
language. So without a context listing possible "advantages" is a bit
hard.

Tom
 
P

pemo

Tom said:
I'll assume he's repeating the question from the text, "What is the
advantage of C" I have to ask compared to what?

I mean C lets you do manual computations easily. But so does any
other language. So without a context listing possible "advantages"
is a bit hard.

I *think* he means the very last bit in 'Suggested Exercises':

6.2 "Discuss the merits of the "C" as a systems programming language. What
features are missing? or superflous?"
 
L

lovecreatesbeauty

Tom said:
I mean C lets you do manual computations easily. But so does any other
language. So without a context listing possible "advantages" is a bit
hard.

Do you have the book handy? Even John did not mention the contrary
language(s).

lovecreatesbeauty
 
T

Tom St Denis

lovecreatesbeauty said:
Do you have the book handy? Even John did not mention the contrary
language(s).

No I don't. And I suspect many others don't either.

Why don't you provide more context for the question so we can all
participate.

Tom
 
T

Tom St Denis

pemo said:
I *think* he means the very last bit in 'Suggested Exercises':

6.2 "Discuss the merits of the "C" as a systems programming language. What
features are missing? or superflous?"

A "with" expression like found in Turbo Pascal would seriously rock.

e.g.

struct mystruct {
int this;
char that;
void *otherthing;
};

// ... code
struct mystruct *p;

with (*p) {
this = 3;
that = 4;
otherthing = "hello world";
}

That'd rock. Specially when dealing with nested structures e.g.

p[4]->this.item[3].value = 3

with (p[4]->this.item) {
value = 3;
key = "hello";
// blah
}

Now granted you can sorta emulate this with a macro, e.g.

#define SETALL2(p, k, v, k2, v2) \
do { \
(p) . k = v; \
(p) . k2 = v2; \
} while (0);

but that's less cool.

Tom
 
K

Keith Thompson

lovecreatesbeauty said:
Do you have the book handy? Even John did not mention the contrary
language(s).

There are hundreds, probably thousands, of other programming
languages. C has advantages with respect to each of them, and
disadvantages with respect to most of them.
 
G

Giorgio Silvestri

Tom St Denis said:
pemo said:
I *think* he means the very last bit in 'Suggested Exercises':

6.2 "Discuss the merits of the "C" as a systems programming language. What
features are missing? or superflous?"

A "with" expression like found in Turbo Pascal would seriously rock.

e.g.

struct mystruct {
int this;
char that;
void *otherthing;
};

// ... code
struct mystruct *p;

with (*p) {
this = 3;
that = 4;
otherthing = "hello world";
}

That'd rock. Specially when dealing with nested structures e.g.

p[4]->this.item[3].value = 3

with (p[4]->this.item) {
value = 3;
key = "hello";
// blah
}

Now granted you can sorta emulate this with a macro, e.g.

#define SETALL2(p, k, v, k2, v2) \
do { \
(p) . k = v; \
(p) . k2 = v2; \
} while (0);

I prefer

#define NEW_SETALL2(p, k, v, k2, v2) \
do { \
(p) . k = (v); \
(p) . k2 = (v2); \
} while (0)

without ';' and with parentheses around 'v' and 'v2'.

In this case you can use the macro as a function call

NEW_SETALL2(p,k,v,k2,v2);



Giorgio Silvestri
 
L

lovecreatesbeauty

Keith said:
There are hundreds, probably thousands, of other programming
languages. C has advantages with respect to each of them, and
disadvantages with respect to most of them.

It means nothing, it's too abstract. Could you go to some specific
facts? Thanks for concern.

lovecreatesbeauty
 
A

Andrew Poelstra

It means nothing, it's too abstract. Could you go to some specific
facts? Thanks for concern.

Compiled => faster than interpreted
Low-level => faster than all high-level languages
Optimized(*) => faster than most all other languages
Standardized => more portable than assembly languages

But then again, it's harder to code than most languages.

* Because of how old and widely supported it is, it has had extensive
research done on optimization, more so than most any other language
out there.
 
M

Morris Dovey

lovecreatesbeauty (in
(e-mail address removed)) said:

| Keith Thompson wrote:
||| Tom St Denis wrote:
|||| I mean C lets you do manual computations easily. But so does
|||| any other language. So without a context listing possible
|||| "advantages" is a bit hard.
|||
||| Do you have the book handy? Even John did not mention the contrary
||| language(s).
||
|| There are hundreds, probably thousands, of other programming
|| languages. C has advantages with respect to each of them, and
|| disadvantages with respect to most of them.
|
| It means nothing, it's too abstract. Could you go to some specific
| facts? Thanks for concern.

C is a useful alternative to writing mountains of assembly code for
system software development. It was not (originally) intended to be
all things to all people.

If you like doing computational kinds of things, there are languages
to do that job much more rapidly and easily. I still like APL for
mathemagical stuff (but nobody likes to _read_ anyone else's APL
programs - and people who _write_ APL almost universally refuse to
produce prose documentation of what they've done.)

If all you know is C, then it becomes the limit of your programmatic
problem solving capabilities. IMO, it's an excellent solution for the
problem it was intended to solve - but if you want to solve different
kinds of problems, then consider other languages.
 
C

Clever Monkey

lovecreatesbeauty said:
It means nothing, it's too abstract. Could you go to some specific
facts? Thanks for concern.
Specific to what? Keith's comment is pretty clear from where I stand.
C excels at some things, and shows its age in other ways. The smart
coder uses the appropriate tool for the job. If C don't fit, don't
force it.

For specifics one has to choose a specific language to compare it with.

Here: In general, a good C compiler makes tight, fast object code that
can be portable across literally hundreds of systems. However, the
responsibility for providing implementations of complex data structures
is yours.

Now, this entire statement is flameworthy because YMMV and others may
have a different idea about what constitutes a "disadvantage".

Think up a specific context under which to compare and contrast and you
may get more satisfying answers to your queries.
 
L

lovecreatesbeauty

Clever said:
C excels at some things, and shows its age in other ways. The smart
coder uses the appropriate tool for the job. If C don't fit, don't
force it.

Different C people may see part of all the exellent of C. No one knows
all, so your real C expertise and comments are welcome.
Here: In general, a good C compiler makes tight, fast object code that
can be portable across literally hundreds of systems.
Yes.

However, the
responsibility for providing implementations of complex data structures
is yours.

Yes.

lovecreatesbeauty
 
S

Skarmander

Andrew said:
* Because of how old and widely supported it is, it has had extensive
research done on optimization, more so than most any other language
out there.
I'm not sure that's entirely correct. It's more accurate to say that C
*compilers* have had extensive research on optimization done on them. It's a
slight but not completely trivial distinction.

Many languages have *potential* for optimization that's as least as great or
greater than that of C, but the compilers for them don't bear this out, even
though optimization in general has made great strides since the early days.
C as a language does not have some sort of spectacular difference with other
languages in this regard.

That said, there are two things that are in C's favor compared to other
languages, as far as performance goes. First, for most platforms, the cost
of operations is proportional to the difficulty of using them in C (or
implementing them if they're not primitive), so programmers are forced to
pay attention to what they're doing. Second, C's focus on portability and
leaving things unsaid that don't need to be said (and, again, requiring the
programmer to cope with them) generally enables compilers to make better use
of platform primitives.

C's performance crown is tarnishing a bit, though, as a result of machines
ever getting faster and programmers ever becoming more willing and more able
to trade performance for convenience. (I merely propose this as an
observation, not to judge it either way.)

S.
 
A

av

C is a useful alternative to writing mountains of assembly code for
system software development. It was not (originally) intended to be
all things to all people.

i'm not agree; 30kb of assembly file obj
are == 1mega obj for C language and (100mega? for C# .net etc obj
file)
 
A

av

i'm not agree; 30kb of assembly file obj
are == 1mega obj for C language and (100mega? for C# .net etc obj
file)

*what* a 30kb file obj result of compile from assembly code can do,
could do only a 1Mb file obj result of compile C code
if i will write 1Mb of obj file compile from assembly code it will
mean i include all algorithms that exist in that file :)
 
C

Chris Dollin

Tom said:
A "with" expression like found in Turbo Pascal would seriously rock.

It's pretty much redundant in C.
e.g.

struct mystruct {
int this;
char that;
void *otherthing;
};

// ... code
struct mystruct *p;

with (*p) {
this = 3;
that = 4;
otherthing = "hello world";
}

That'd rock.

The advantage over

p->this = 3; p->that = 4; p->otherthing = "hello world";

is negligable. Especailly because you /know/ which things
are in the structure and which are not, which in a Pascal-
type with you can't tell without finding the structure
definition.
Specially when dealing with nested structures e.g.

p[4]->this.item[3].value = 3

with (p[4]->this.item) {
value = 3;
key = "hello";
// blah
}

{
WhateverTypeItIs *pp = p[4]->this.item;
pp->values = 3; pp->key = "hello"; blah();
}
Now granted you can sorta emulate this with a macro, e.g.

#define SETALL2(p, k, v, k2, v2) \
do { \
(p) . k = v; \
(p) . k2 = v2; \
} while (0);

but that's less cool.

Not so much less cool, as not even on a thermal scale.
 
T

Tom St Denis

Chris said:
It's pretty much redundant in C.

Not really. Yeah you can work around it but it would be cooler if it
was a native function of the language. It would integrate well I think
as you'd just have scoping rules. E.g. variables in the struct/union
that you with'ed would take precedence over stuff external, e.g.

int this;
with (mystruct) { this = 4; }

Modifies the "this" in the struct. You'd have to be able to nest it
too...
The advantage over

p->this = 3; p->that = 4; p->otherthing = "hello world";

is negligable. Especailly because you /know/ which things
are in the structure and which are not, which in a Pascal-
type with you can't tell without finding the structure
definition.

yeah but if you see

somefile.c line 1033

p->npny = cba(SOME_VALUE);

Or someshit which is common in coporate code you still have to read the
headers to decipher wtf "npny" is and what else *p contains.
{
WhateverTypeItIs *pp = p[4]->this.item;
pp->values = 3; pp->key = "hello"; blah();
}

Yeah, that's clearly so much simpler. :)
Not so much less cool, as not even on a thermal scale.
Chris "with-hater since 1980ish" Dollin

Hmm ... right.

Anyways, given that I've been coding/developing in C for a while I too
know how to work around that and make it all maintainable. I'm just
answering the OPs question. If you were to add something to C, I think
with would be a cool thing to add.

Tom
 
M

Morris Dovey

Morris Dovey (in [email protected]) said:

| lovecreatesbeauty (in
| (e-mail address removed)) said:
|
|| Keith Thompson wrote:
|||| Tom St Denis wrote:
||||| I mean C lets you do manual computations easily. But so does
||||| any other language. So without a context listing possible
||||| "advantages" is a bit hard.
||||
|||| Do you have the book handy? Even John did not mention the
|||| contrary language(s).
|||
||| There are hundreds, probably thousands, of other programming
||| languages. C has advantages with respect to each of them, and
||| disadvantages with respect to most of them.
||
|| It means nothing, it's too abstract. Could you go to some specific
|| facts? Thanks for concern.
|
| C is a useful alternative to writing mountains of assembly code for
| system software development. It was not (originally) intended to be
| all things to all people.

This past weekend I was digging through an old BNF compiler program
and it occurred to me that there are probably an increasing number of
programmers who've never done any actual assembly language
programming. Just to provide the non-assembly folks with an historical
glimpse, I snipped out a tiny piece of code (output an 8-bit byte to a
disk buffer and write the buffer when full), expanded the tabs with
spaces, and saved it at the link below.

The environment was CP/M running on a Z80 microprocesor. The
commenting was so that I could pick up the code (even a quarter
century later!) and make sense of what I'd done. The function is
sufficiently common and straightforeward - and the comments are
sufficiently complete - that almost anyone should be able to follow
the logic.

To add a bit more perspective, the complete program listing was about
60 pages long. Portability would be a serious problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top