What is C suitable for nowadays?

M

Matthew Zhou

I am a students learning programming, and want to do some software
projects to practice myself.

However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

Many friends of mine suggest me move to C++ or Java. But I there must
be some places reserved for C (although they say C++ can do all the
jobs of C).

May any one give some general idea, when should I use C and when it
is better to try something else. So I can plan my learning more
efficiently, practicing C more in some fields.
 
F

Florian Weingarten

Matthew Zhou said:
May any one give some general idea, when should I use C and when it
is better to try something else. So I can plan my learning more
efficiently, practicing C more in some fields.

I would prefer C over any language in cases where execution time
matters (and where ASM would be overkill or out of question because
of portability issues). Take operating systems for example.. Most
parts of nearly all modern operating systems are written in C.


Flo
 
R

Richard Heathfield

Matthew Zhou said:
May any one give some general idea, when should I use C and when it
is better to try something else.

If you have to be persuaded to use C, you probably wouldn't be very good
at it. If your favourite language is a good fit for the problem, use
that. If not, try your second favourite.
 
S

santosh

Matthew said:
I am a students learning programming, and want to do some software
projects to practice myself.

However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

C is a general purpose programming language. It has been used in every
conceivable domain of programming. Currently, it's more used in system
programming. It's a preferred language for creating highly portable,
highly efficient programs.

May any one give some general idea, when should I use C and when it
is better to try something else. So I can plan my learning more
efficiently, practicing C more in some fields.

That's not possible. To become proficient in a language, you must
devote at least several months of effort learning it's syntax,
semantics, it's implementations and write various programmes with,
preferably of divergent natures. You can't "practise C more in some
fields."

C is a small language. Try giving it a shot. If you at all know the
basics of programming try _The C Programming Language_ by Kernighan
and Ritchie. It's probably the best out there. You'll know soon
whether you like it or not, and if not you can try other languages.
 
M

Matthew Zhou

Richard Heathfield said:
Matthew Zhou said:


If you have to be persuaded to use C, you probably wouldn't be very good
at it. If your favourite language is a good fit for the problem, use
that. If not, try your second favourite.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

C is my favourite language. I am just considering learning
others. Maybe in certain cases another language will be make the work
easier. But I for those work which C is the best choices I want to
practice more. And for others, I will try out to use some other
languages. At last I think I can know more or less about the right way
to combine the power of different languages.

Maybe I should change the title to "What is C not suitable for?"
 
P

Pierre Asselin

Matthew Zhou said:
I am a students learning programming, and want to do some software
projects to practice myself.
Okay.


However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

In my humble opinion, for whatever it's worth, two of C's strong
points are

1) Good support for both low-level and high-level programming.
2) Small physical size of the book "The C Programming Language",
by Kernigan and Ritchie (second edition only!).

#2 means that you can learn C from scratch in a relatively
short time. How short depends on how much you already know.

In my own case, many years ago, it was quick and easy because I
was transitioning from Pascal, a language designed for teaching
(Pascal User Manual and Report, another thin book). I only had to
pay close attention to the more difficult parts of C, such as the
relationship between arrays and pointers. I would not recommend
learning Pascal today.

The comp.lang.c FAQ is a good resource for the parts of the language
that tend to confuse beginners.

Many friends of mine suggest me move to C++ or Java. But I there must
be some places reserved for C (although they say C++ can do all the
jobs of C).

From what little I know about Java, it is high-level only and comes
with a good library. It depends on what you want to do.

Some people say that you can take C++ as your first programming
language, but I am really, really dubious. C++ is a large language
(no thin books) and a lot of it makes absolutely no sense unless
you already know a lot of computer science. I could see taking a
course in C++, if the instructor is really good and knows what he's
doing, but I think a self-taught beginner would quickly suffer from
information overload.
 
N

Nick Keighley

Matthew said:
I am a students learning programming, and want to do some software
projects to practice myself.

However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

C is a relatively small language that is reasonably easy to learn
completly.
It tends to produce code that is "close to the metal", that is each
line of
C compilers to a small number of hardware instructions.

C programs can be written that are space/time efficient.

C is implemented on a very wide variety of platforms. C89 is very
portable.

Many friends of mine suggest me move to C++ or Java. But I there must
be some places reserved for C (although they say C++ can do all the
jobs of C).

Linux is written in C. I believe Microsoft Windows was (and maybe
still is).
C is still widely used in embedded applications.

C++ adds OO, templates, exceptions and a vast library. It is harder
to
become completly familiar with C++ and there are pitfalls for the
beginner.
Sometimes the program is far from the bare metal.

a = b++;

could invoke many user defined functions.

I understand (I am not an expert in this area) some areas of C++
still
vary from compiler to compiler. Some of the more esoteric template
operations are not correctly implemented on all compilers. See the
Boost project.
May any one give some general idea, when should I use C and when it
is better to try something else. So I can plan my learning more
efficiently, practicing C more in some fields.

I like C. It's small, it's simple and it can be made to do some
amazing things.

C++ is usually regarded as more scalable to large projects and gives
you
a choice of paradigms (procedural, OO and generic). The library is
pretty
amazing as well.

Have you taken a look a python?
 
C

CBFalconer

Matthew said:
.... snip ...

C is my favourite language. I am just considering learning others.
Maybe in certain cases another language will be make the work
easier. But I for those work which C is the best choices I want to
practice more. And for others, I will try out to use some other
languages. At last I think I can know more or less about the right
way to combine the power of different languages.

Maybe I should change the title to "What is C not suitable for?"

Maybe you should consider learning to snip your quotes. There is
almost never any reason for quoting signatures. This is an
exception.
 
M

Matthew Zhou

In my humble opinion, for whatever it's worth, two of C's strong
points are

1) Good support for both low-level and high-level programming.
2) Small physical size of the book "The C Programming Language",
by Kernigan and Ritchie (second edition only!).

#2 means that you can learn C from scratch in a relatively
short time. How short depends on how much you already know.

In my own case, many years ago, it was quick and easy because I
was transitioning from Pascal, a language designed for teaching
(Pascal User Manual and Report, another thin book). I only had to
pay close attention to the more difficult parts of C, such as the
relationship between arrays and pointers. I would not recommend
learning Pascal today.

The comp.lang.c FAQ is a good resource for the parts of the language
that tend to confuse beginners.



From what little I know about Java, it is high-level only and comes
with a good library. It depends on what you want to do.

Some people say that you can take C++ as your first programming
language, but I am really, really dubious. C++ is a large language
(no thin books) and a lot of it makes absolutely no sense unless
you already know a lot of computer science. I could see taking a
course in C++, if the instructor is really good and knows what he's
doing, but I think a self-taught beginner would quickly suffer from
information overload.

Strongly agree with you. Actually I have no programming experience
before. One year ago I began to learn C++, though I did not learnt
much, at least I found that it is too complicated for a beginner like
me. So I gave up and spent the other 6 months on the K&R2. However I
think just learn something is not enough. So I think I need more
practice.

From my own experience, though not from programming, I have the
feeling that if I want to master some knowledge, I must practice. As I
was a new high school student four years ago, due to some needs, I
pushed myself to learn calculus, and I found that by practicing, by
solving problems, I can master it. And even today, I do a better job
than most of my colleague ( they are teaching by professors and I was
taught by myself and a book.By they way, since they are also students
in MATH department just like me, so they are comparable). Now I am
studying programming, so I think the situation should be some how
likely. Though it is a very different subject other than mathematics,
I think there is something remain the same---practice, solve problems.

But I do not know where to get some real world practicing. And also I
have no idea what should I practice more than others. I think I should
practice more for the field what C is good for. Of course, I will
practice more for the part which is harder, such as pointers and
arrays.

Thank you for all your replying, and if you can give me some ideas to
make me go in the right way.

And, thanks if any one point out that the idea of mine above is wrong
for programming and tell me why.
 
B

bluejack

However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

C's strength, IMO, is that it is close to the machine. It is usually a
short step from what you write in C to what the compiler generates by
way of actual machine instructions. This makes C an excellent language
for people with control issues, or for problems in which close control
over the machine is useful. One of the biggies is operating systems
(although at least one excellent, but commercially unsuccessful OS was
written in C++: BeOS). Another is applications that need to be small
and portable: embedded programming is a good field here.

Because C doesn't expand your source code in unexpected ways, there's
usually a pretty direct corralary between what you write, the size of
your binary, and the performance of your application. That doesn't
mean C is faster, or smaller -- that's in the programmer's hands. But
if you intend to write small, efficient code, C doesn't get in your
way.

C is suitable for projects of any size; many people will tell you that
for large applications, or distributed processing environments, C is
the wrong choice. This may be true, but it's not the fault of C: it's
a problem with the way people use C.
In practical or professional terms, C may be the wrong language to
study if you are aiming for those kinds of fields.

Perhaps more significant than the OO features, one difference that
distinguishes C from C++ or Java is the standard libraries that are
part of the language. Java and C++ both come with large, robust, and
(usually) efficient libraries; C does not. For rapid development,
someone familiar with the language and the libraries and starting from
scratch will often get more done more quickly in Java or C++ than in
C. Many C shops will have their own in-house suite of libraries
suitable to the kind of work the location undertakes. Others will have
third party libraries. It's usually not much work to get up to speed
with these libraries, especially for an expert, but it's an extra
step. And if you're starting a major project, you have to make the
call: buy or build your libraries.

As for the OOD: you *can* do anything in C that you can do in C++ or
Java, but it's not necessarily easy, or appropriate. (In fact, it is
arguable whether some of the stuff that's hard or ugly in C ever
really makes much sense in other languages anyway, but a professional
is better off not getting religious about this, and learning how to
read, maintain, and apply OOD in a clean, efficient manner.)

Another area is memory management: C offers ample opportunity for
inexperienced programmers to wreak havoc and destruction, and even
experienced programmers will manage to shoot themselves in the foot
now and then. Maybe I should only speak for myself here, but even
after 10 years of C programming, a careless typo on a late-night
session can create a bug that takes me hours to track down. Java is
substantially better in this regard, at a pretty big performance
penalty. C++, the "everything to everyone" language, is most often
used in ways that diminish this likelihood, but doesn't actually
prevent it.

In short: theoretically, there's rarely a case in which C is a bad
choice. Practically, I've come to the conclusion that it's more about
the culture of the shop than the project at hand. Professionally, I
think it's a poor strategy to declare a "favorite" language. The good
strategy is to maintain your curiosity about new languages,
techniques, technologies, algorithms, design patterns, and to throw
yourself into any new project open to the possibility that the best
tool for the job *might* be one that you're not familiar with.

Remember: languages are tools, and the professional wants to equip
himself or herself with all the right tools.
 
A

August Karlstrom

Matthew Zhou skrev:
I am a students learning programming, and want to do some software
projects to practice myself.

However, no one will only use one language to make all the tasks
done. And every languages has its strong and relatively weak side. So,
what about C?

Many friends of mine suggest me move to C++ or Java. But I there must
be some places reserved for C (although they say C++ can do all the
jobs of C).

May any one give some general idea, when should I use C and when it
is better to try something else. So I can plan my learning more
efficiently, practicing C more in some fields.

You might also want to take a look at Oberon:

http://www.zel.org/oberon/fromctoo.htm (and the links from that article).


August
 
A

arnuld

Strongly agree with you. Actually I have no programming experience
before. One year ago I began to learn C++, though I did not learnt
much, at least I found that it is too complicated for a beginner like
me. So I gave up and spent the other 6 months on the K&R2. However I
think just learn something is not enough. So I think I need more
practice.


if i must *compare* then i am also following the same path. now i
believe, there are some patters in learning programming that keep on
showing themselves.

From my own experience, though not from programming, I have the
feeling that if I want to master some knowledge, I must practice. As I
was a new high school student four years ago, due to some needs, I
pushed myself to learn calculus, and I found that by practicing, by
solving problems, I can master it. And even today, I do a better job
than most of my colleague ( they are teaching by professors and I was
taught by myself and a book.By they way, since they are also students
in MATH department just like me, so they are comparable). Now I am
studying programming, so I think the situation should be some how
likely. Though it is a very different subject other than mathematics,
I think there is something remain the same---practice, solve problems.

good, you have understood the *thing* and i took 1 year of my young-
hood only to confront it.

But I do not know where to get some real world practicing. And also I
have no idea what should I practice more than others.

try these 2 web-sites:


http://savannah.gnu.org
http://sourceforge.net/

just search with keywords "C projects" or "C++ softwares" or whatever.
these web-sites host Open-Source softwares and thousands of self-
taught programmers contribute to them. Linux and nearly all of the GNU
tools developed in the same way. i found them an excellent place to
learn real-life programming and giving something back to the
community, since i took so much :)

may be you will meet some of the best brains there....

good luck

:)


NOTE; i am also a newbie but i have analysed this software thing quite
a bit.
 
M

Matthew Zhou

bluejack said:
C's strength, IMO, is that it is close to the machine. It is usually a
short step from what you write in C to what the compiler generates by
way of actual machine instructions. This makes C an excellent language
for people with control issues, or for problems in which close control
over the machine is useful. One of the biggies is operating systems
(although at least one excellent, but commercially unsuccessful OS was
written in C++: BeOS). Another is applications that need to be small
and portable: embedded programming is a good field here.

Because C doesn't expand your source code in unexpected ways, there's
usually a pretty direct corralary between what you write, the size of
your binary, and the performance of your application. That doesn't
mean C is faster, or smaller -- that's in the programmer's hands. But
if you intend to write small, efficient code, C doesn't get in your
way.

C is suitable for projects of any size; many people will tell you that
for large applications, or distributed processing environments, C is
the wrong choice. This may be true, but it's not the fault of C: it's
a problem with the way people use C.
In practical or professional terms, C may be the wrong language to
study if you are aiming for those kinds of fields.

Perhaps more significant than the OO features, one difference that
distinguishes C from C++ or Java is the standard libraries that are
part of the language. Java and C++ both come with large, robust, and
(usually) efficient libraries; C does not. For rapid development,
someone familiar with the language and the libraries and starting from
scratch will often get more done more quickly in Java or C++ than in
C. Many C shops will have their own in-house suite of libraries
suitable to the kind of work the location undertakes. Others will have
third party libraries. It's usually not much work to get up to speed
with these libraries, especially for an expert, but it's an extra
step. And if you're starting a major project, you have to make the
call: buy or build your libraries.

As for the OOD: you *can* do anything in C that you can do in C++ or
Java, but it's not necessarily easy, or appropriate. (In fact, it is
arguable whether some of the stuff that's hard or ugly in C ever
really makes much sense in other languages anyway, but a professional
is better off not getting religious about this, and learning how to
read, maintain, and apply OOD in a clean, efficient manner.)

Another area is memory management: C offers ample opportunity for
inexperienced programmers to wreak havoc and destruction, and even
experienced programmers will manage to shoot themselves in the foot
now and then. Maybe I should only speak for myself here, but even
after 10 years of C programming, a careless typo on a late-night
session can create a bug that takes me hours to track down. Java is
substantially better in this regard, at a pretty big performance
penalty. C++, the "everything to everyone" language, is most often
used in ways that diminish this likelihood, but doesn't actually
prevent it.

In short: theoretically, there's rarely a case in which C is a bad
choice. Practically, I've come to the conclusion that it's more about
the culture of the shop than the project at hand. Professionally, I
think it's a poor strategy to declare a "favorite" language. The good
strategy is to maintain your curiosity about new languages,
techniques, technologies, algorithms, design patterns, and to throw
yourself into any new project open to the possibility that the best
tool for the job *might* be one that you're not familiar with.

Remember: languages are tools, and the professional wants to equip
himself or herself with all the right tools.

Thank you very much! :)
 
M

Malcolm McLean

Matthew Zhou said:
Strongly agree with you. Actually I have no programming experience
before. One year ago I began to learn C++, though I did not learnt
much, at least I found that it is too complicated for a beginner like
me. So I gave up and spent the other 6 months on the K&R2. However I
think just learn something is not enough. So I think I need more
practice.
C++ is a poor choice as a first language. A bit like trying to be an
organist without first learning the piano.
But I do not know where to get some real world practicing. And also I
have no idea what should I practice more than others. I think I should
practice more for the field what C is good for. Of course, I will
practice more for the part which is harder, such as pointers and
arrays.
You learn by writing real programs. In your situation, a real program is
probably a game. Unfortunately most games cannot be programmed in pure ANSI
C because of the lack of graphics.
I'd start off with a simple character-mapped game using curses or conio or
similar non-standard libararies. A nice first one is "asteroids" - print two
asterisks on each line and scroll the screen down. meanwhile the plyer
controls a ship on the bottom line he can move from left to right, and has
to dodge the stars. Very playable, and very easy.
 
R

Richard Heathfield

Matthew Zhou said:
C is my favourite language.

Then use C except when it hurts to do that.
I am just considering learning others.

Excellent idea. You may discover a new favourite, a language you like
better than C. And if not, at least you may learn some insights which
will inform your C programming. So you can't lose.
 
M

Malcolm McLean

Richard Heathfield said:
Excellent idea. You may discover a new favourite, a language you like
better than C. And if not, at least you may learn some insights which
will inform your C programming. So you can't lose.
Except there are too many languages doing similar things. People mentioned
Oberon and Python, for instance.

I use Perl for trivial scripts to drive my C programs, rather than hardcode
all the directory paths. The other day I had to ask my friend what
"continue" was in Perl. It turns out it is "next". Just a little detail, but
the sort of niggling inefficiency that means that nothing ever gets done in
time.
 
D

Default User

Malcolm said:
You learn by writing real programs. In your situation, a real program
is probably a game. Unfortunately most games cannot be programmed in
pure ANSI C because of the lack of graphics.

Unless you go with a text-adventure game.




Brian
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top