Why is C good??? any experts?

S

Suresh

Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?
If it is no longer a choice of programming language...why people still study
it?
And also its not an OO language either...is there any advantages in being
not an OO language?

I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.
 
E

E. Robert Tisdale

Suresh said:
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?
If it is no longer a choice of programming language,
why people still study it?

New C programmers are required to maintain old C programs.
 
C

Chris Dutton

Suresh said:
Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?
If it is no longer a choice of programming language...why people still study
it?
And also its not an OO language either...is there any advantages in being
not an OO language?

I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

I think all of your questions boil down to "why choose C over something
else?"

There are two answers.

1. C is sometimes known as "portable assembler". The key concept
represented by this statement is that C is closer to the machine that
most other languages. It's possible to understand exactly what a C
program is doing because there isn't (necessarily) a lot of overhead
going on. You don't have to guess what other information the compiler
is including in order for things like polymorphism to work, and how that
additional information will impact things like memory layout of an
aggregate data structure.

2. C is everywhere. C is about as ubiquitous a language as anyone
could ever hope for. If you want to write a clean, portable, minimal
(few dependencies) program, there are very few systems where it won't
compile and run.
 
E

E. Robert Tisdale

Chris said:
C is sometimes known as "portable assembler".
The key concept represented by this statement is that
C is closer to the machine that most other languages.

I don't know what that means.
Which "machine" is C "close to"?
Is C "farther" from machines that are not "close to"
the machine that C is "close to".
What sort of topology allows this sort of reasoning?
It's possible to understand exactly what a C program is doing
because there isn't (necessarily) a lot of overhead going on.

People who claim to know "exactly what a C program is doing"
are almost never correct.
You don't have to guess what other information the compiler
is including in order for things like polymorphism to work,

If you need to "guess" at these things,
you don't understand the programming language.
 
J

Jack Klein

Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?
If it is no longer a choice of programming language...why people still study
it?
And also its not an OO language either...is there any advantages in being
not an OO language?

I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

Your last statement is complete nonsense. IT started with FORTRAN and
COBOL as the high level languages, and other things like JCL.
 
K

Kieran Simkin

You speak like C is an obsolete language. Most of the Linux (or most *n?x)
operating system and the programs that run inside it are written in C not to
mention countless applications that are still in very much active
development.
I don't speak on behalf of the newsgroup here, but I simply don't like
object orientation. I find it obfuscates things in my mind and doesn't
provide many advantages in most non-gui situations. So to answer your
question about object orientation, OO is not necessarily the Way
Forward(tm), it just has some advantages in some situations.
I just started teaching myself C recently and if my reason for using it
would interest you; I'm replacing a lot of old Perl and PHP scripts I wrote
which were performing things that PHP in particular wasn't designed to do,
namely running as daemons and doing a lot of statistical calculations.
Compiled C beats Perl and PHP in speed and reliability hands down on both
these applications (assuming well written PHP/Perl vs. well written C).
Another thing that draws me to C over interpreted languages like Perl and
PHP is that if a program performs oddly, I can usually make the assumption
that it's my code that's broken rather than the language I'm writing it in.
Yes, there have been several occasions on which this hasn't been the case
with PHP.
Maybe this answers your question, I've explained why I like C in preference
to object orientated languages like C++ or Java *spit* and I've explained
why I like C over other procedural languages (if you count PHP and Perl as
programming languages rather than scripting languages).


--


~Kieran Simkin
Digital Crocus
http://digital-crocus.com/
 
N

Neil Kurzman

E. Robert Tisdale said:
I don't know what that means.
Which "machine" is C "close to"?
Is C "farther" from machines that are not "close to"
the machine that C is "close to".
What sort of topology allows this sort of reasoning?

CPUs execute Op-Codes. The CPU does not know about languages.
C gives you more control over what the CPU will get.
..NET and Java... are not under the Programmers control.
People who claim to know "exactly what a C program is doing"
are almost never correct.

Then do not guess. Look at the .LST file and be sure.
If you need to "guess" at these things,
you don't understand the programming language.

Then explain Java and VB

C effectively the next step above Assembly.
It gives more control over memory usage and hardware access.
You pay for the control with more responsibility. More code to do the
same task.
And you get to watch for buffer overruns and memory leaks.
 
G

gswork

Suresh said:
Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?

Because you can create useful programs using it and...
In what way its better than any other languages?

No overwhelming way, but it is very flexible in allowing a multitude
of approaches and 'styles' of programming, has good facility for
'lower level' systems programming and is widely implemented with an
ISO standard to help programmers who port apps from one platform to
another.
If it is no longer a choice of programming language...why people still study
it?

Because it is, still, a choice for many.
And also its not an OO language either...is there any advantages in being
not an OO language?

Perhaps in the implmentation of compilers, for many it makes C easier
to learn (initially) too.
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

IT started way before C, but indeed the huge amount of legacy code,
especially in systems code, ensures C's future as much if not more
than any other language characteristic.
 
R

Rob Thorpe

Suresh said:
Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?

I'm not sure that it is better than any other languages, but it has
certain advantages:

* There are C bindings available for many libraries, probably more
than any other language.
* It is relatively simple. This means that it's not unreasonable to
understand nearly all of the language. Its much harder to reach a
good understanding of a more complex language like C++.
* If you understand the machine you are using its possible to write
quite fast C.
If it is no longer a choice of programming language...why people still study
it?
And also its not an OO language either...is there any advantages in being
not an OO language?

No, except you don't have to understand the OO parts. Which in most
languages I've used are really complicated.
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

No it didn't, but it is used heavily today.
 
C

CBFalconer

Neil said:
CPUs execute Op-Codes. The CPU does not know about languages.
C gives you more control over what the CPU will get.
.NET and Java... are not under the Programmers control.

_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|
/ _ \ \ ||
/ |\____\ \ ||
/ | | | |\____/ ||
/ \|_|_|/ | _||
/ / \ |____| ||
/ | | | --|
| | | |____ --|
* _ | |_|_|_| | \-/
*-- _--\ _ \ | ||
/ _ \\ | / `
* / \_ /- | | |
* ___ c_c_c_C/ \C_c_c_c____________
 
J

Joona I Palaste

I'm not sure that it is better than any other languages, but it has
certain advantages:
* There are C bindings available for many libraries, probably more
than any other language.

People have been mistaking those bindings for the C language itself for
decades. I don't know if that counts as an advantage.
 
R

Rob Thorpe

Joona I Palaste said:
People have been mistaking those bindings for the C language itself for
decades. I don't know if that counts as an advantage.

It certainly doesn't for reading a newsgroup about it. It means
people ask all kinds of things that few on the group know and most
would be better looking elsewhere.
It also means that a lot of people think of nasty win32 SDK things
when they're thinking of C.
 
J

John Bode

Suresh said:
Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?

"Good" depends on context. There are some tasks for which C is most
definitely *not* the right choice.
In what way its better than any other languages?

Compared to many other languages, C is "small" (few keywords, relatively
simple syntax, etc.), meaning C compilers are relatively easy to write,
meaning C compilers are available for everything from mainframes to
microcontrollers. C is also very flexible, giving the programmer a wide
variety of tools to accomplish various tasks.
If it is no longer a choice of programming language...why people still study
it?

Same reason people still study Fortran and COBOL -- there's a lot of legacy
code out there that needs to be maintained for whatever reason. It's almost
always cheaper to maintain an old program than to reimplement it in a new
language.
And also its not an OO language either...is there any advantages in being
not an OO language?

Mainly that the language is a little easier to learn (compared to something
like C++ anyway), and that the compilers are simpler to write. And not every
problem needs an object-oriented solution, anyway. There are cases for
which an object-oriented approach is overkill.
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

IT started long before C was around (whether it was called IT in those days
or not). What we consider IT probably started with COBOL.
 
G

gooch

Suresh said:
Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?

With few exceptions no programming language is either good or bad on
its own. Programmers can write good and bad code in any language out
there. The trick is to choose the appropriate language for the
application being developed. In a lot of cases where you want to have
good control over hardware and not have o deal directly with an
assembly language C is a good choice.
If it is no longer a choice of programming language...why people still study
it?

C is still widely used in many applications especially embedded
systems programming. As far as why is it often used to teach
programming, it is a fairly simple language to use for demonstrating
good programming practices and concepts so a lot of schools use it.
And also its not an OO language either...is there any advantages in being
not an OO language?

This is not exactly true. While C was not designed as an OO language
it is possible to implement virtually all of the functionalities of an
OO language such as Java or C++ in C. It is not as easy to do in some
cases and it would not make sense in all cases because it could make
the code somewhat convoluted. Where I work we do implement objects,
inheritence, polymorphism etc. in C when appropriate. This can help to
allow your code to be more reusable and fit more logically with an
OOAD approach (which we also use) than it might otherwise.
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

C was by no means the beginning of the programming languages. In fact
you can trace programming back as far as the 1800's (depending on who
you talk to maybe even farther).
 
D

Darrell Grainger

Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?

I feel it is a good language because it tends to have portable source
code, it is very mature, the library of standard functions is well defined
and understood, there is a wealth of code snippets and libraries
available and there are many programmers who know the language.

Additionally, as someone who comes from an assembly background, there is
something about C language that is intuitive for me. I have a certain
mindset and C language seems to mesh with it.
In what way its better than any other languages?

I would not say that it is better than any other language. Because it is a
mature language, the compilers for it have been around for a while. They
tend to generate code that is comparable to something most programmers
could do with hand assembly. Additionally, mixing assembly and C is
usually not very difficult. I can therefore write something in C, profile
it, find the hot spots, optimize them by hand in assembly.

I would not say that only C language has these features.
If it is no longer a choice of programming language...why people still study
it?

Moot. C language is still a language of choice.
And also its not an OO language either...is there any advantages in being
not an OO language?

Less overhead for small projects. How you design the program is different.
For someone who is used to procedural languages like C they might not take
to OO languages. Again, one strong reason to prefer one language over
another is because it just seems more intuitive.
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.

Legacy code is a big reason why COBOL is still around. I would imagine
that there will be a need for C programmers to maintain old projects.
Currently, there are still new C projects being created. So C language
hasn't become a maintenance language yet.
 
D

Darrell Grainger

I don't know what that means.
Which "machine" is C "close to"?
Is C "farther" from machines that are not "close to"
the machine that C is "close to".
What sort of topology allows this sort of reasoning?

Have you never heard someone use the expression "close to" as a way of
saying "similar in attributes"? For example, Latin is close to Italian,
meaning that the structure of the Latin language shares many similarity
with the Italian language.

With assembly language there is a one to one correspondence to machine
language (unless we are talking about algebric assemblers). If something
is similar to assembly language then it is "close to" assembly language.
Because there is a one to one correspondence between assembly language and
machine language, it could be said that it is also close to machine
language or close to the machine.

For example, I will notice that certain statements in C language will
always produce the same machine language on a given machine. This is not
to say that for all C language there is a one to one correspondence with
machine/assembly language. How similar C code will be to the machine
language will differ for each compiler on each architecture.
People who claim to know "exactly what a C program is doing"
are almost never correct.

Depend who you are talking to. If you talk to Electrical Engineers,
people with a hardware design background or embedded programmers you will
find that they really do know what a C program is doing. Most of them will
code in C but optimize and debug in assembler.
If you need to "guess" at these things,
you don't understand the programming language.

Strange, first you say that 'People who claim to know "exactly what a C
program is doing" are almost never correct.' and now you are implying that
people who understand a programming language don't need to "guess" at what
it is doing. So which is it?
 
E

E. Robert Tisdale

Neil said:
CPUs execute Op-Codes. The CPU does not know about languages.
C gives you more control over what the CPU will get.
.NET and Java... are not under the Programmers control.

How is C more "under the programmers control" than .NET and Java?
C effectively the next step above Assembly.

What does that mean?
Java doesn't emit C code.
It gives more control over memory usage and hardware access.

Really?
Please show us an example of how C gives more control
over memory usage and hardware access.
You pay for the control with more responsibility.
More code to do the same task.
And you get to watch for buffer overruns and memory leaks.

What does that have to do with the hardware?
 
E

E. Robert Tisdale

Darrell said:
Have you never heard someone use the expression "close to" as a way of
saying "similar in attributes"? For example, Latin is close to Italian,

With assembly language

The correct term is *assembler*.
there is a one to one correspondence to machine language
(unless we are talking about algebraic assemblers).

Here are the first five lines of an assembler listing:

.file "main.c"
.text
.align 2
..globl loop
.type loop,@function

Please tell us
which machine language instructions correspond to these lines.
If something is similar to assembly language
then it is "close to" assembly language.

How is C "similar" to assembler?
Because there is a one to one correspondence
between assembly language and machine language, it could be said that
it is also close to machine language or close to the machine.

I don't dispute that
assembler *instructions* correspond to machine instructions.
For example, I will notice that certain statements in C language
will always produce the same machine language on a given machine.

I have noticed that certain statements in C language
will *not* always produce the same machine language on a given machine.
Generally, the emitted code depends upon context.
Different compilers emit different machine code
for the same C language statements.
Different options can cause the compiler to emit different machine code
for the same C language statements.
This is not to say that, for all C language,
there is a one to one correspondence with machine/assembly language.
How similar C code will be to the machine language
will differ for each compiler on each architecture.

How, then, can C language code be "close" to machine language code
on each of these different architectures?
Depend who you are talking to. If you talk to Electrical Engineers,
people with a hardware design background

I have a hardware design background.
or embedded programmers you will find that
they really do know what a C program is doing.
Most of them will code in C but optimize and debug in assembler.

Most of us don't do this anymore.
We use good optimizing compilers instead/
Strange, first you say that 'People who claim to know
"exactly what a C program is doing" are almost never correct.'
and now you are implying that
people who understand a programming language
don't need to "guess" at what it is doing. So which is it?

You need read the assembler listing emitted by you C compiler
to know exactly what your C program is doing.
The assembler will depend upon

1. the machine architecture,
2. the compiler and
3. the options that you chose to compile your program.

C programmers are notoriously bad at predicting
what assembler code will be emitted
when they port their programs from one platform to another.
 
X

Xenos

E. Robert Tisdale said:
The correct term is *assembler*.

God, I hate it when people said that. No, it is Assembly Language. The
assembler is the tool that converts it to machine code. Do you say
"compiler" instead of "C"?
 
E

E. Robert Tisdale

Xenos said:
God, I hate it when people said that. No, it is Assembly Language.
The assembler is the tool that converts it to machine code.
Do you say "compiler" instead of "C"?

According to the Free OnLine Dictionary Of Computing

http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?Assembly+Language

Assembly Language

<language, robotics> (AL) A language for industrial robots developed at
Stanford University in the 1970s.

["The AL Language for an Intelligent Robot", T. Binford in Langages et
Methods de Programation des Robots Industriels, pp. 73-88, IRIA Press 1979].

["AL User's Manual", M.S. Mujtaba et al, Stanford AI Lab, Memo AIM-323
(Jan 1979)].
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top