Learning C

M

mfasoccer

I am sorry if this is an inappropriate place to put this post, if so
please delete it.

I am wondering about a few things. Do you guys recommend learning C as
a second language, as someone who already knows java very well. And
what is the best way to learn C, books, tutorials, or what?

Thanks, any response would be great.
 
M

Micah Cowan

I am sorry if this is an inappropriate place to put this post, if so
please delete it.

Well, this is an entirely appropriate place for this post, but if it
had not been, deleting the post would be impossible (once you post to
USENET, it stays there, for the most part. Even "cancelling" a post
you made will may affect some but not all servers).
I am wondering about a few things. Do you guys recommend learning C as
a second language, as someone who already knows java very well. And
what is the best way to learn C, books, tutorials, or what?

Thanks, any response would be great.

I'd be willing to bet that most of the folks on this group began
learning C with a book. Unfortunately, there is a very high ratio of
crappy C books to useful C books. I strongly recommend you buy a copy
of K&R C ("The C Programming Language", by Kernighan and Ritchie, 2nd
edition), written by the actual inventors of C. The C language has
actually changed since then, but the language described there is still
the most portable version of the language, and that book is the most
widely recognized

When you've worked through that, you should probably buy a copy of "C:
A Reference Manual" by Harbison & Steele.

See also http://c-faq.com/resources/books.html, which gives a few
pointers on finding good books on C.

Participating in this newsgroup, or on alt.comp.lang.learn.c-c++, can
also be /very/ beneficial, /provided/:

1. You thoroughly familiarize yourself with the
rules-of-conduct/posting for the group. This can be accomplished
by reading about 2 weeks' worth of posts before posting
yourself. See what kinds of posts get good responses, and which
get poor ones.

2. You have the humility and good grace to receive constructive
criticisms, both of your code and of any errant behavior on the
group.

HTH,
Micah
 
M

mfasoccer

Thanks alot for the response, a few minutes after posting I searched
this group and found hundreds of other threads about the same topic. I
apoligize as well for double posting, that was a mistake even though
I'm sure it must look like I tryed to bump my thread.

I wanted as well, to bring forth another concern that I have with
programming in general. Many people say that ACTUALLY PROGRAMMING
real-world programs is the best way to get better. That theory makes
sense, but when I sit down to write a program in java, I often realize
that I have mastered the sytnax and searching and sorting algorithms,
yet I cannot apply this to a real-world program. Are there any books
for C or websites that explain the analytical thinking or other tactics
involved in practical uses of C?
 
R

Richard Heathfield

(e-mail address removed) said:
Are there any books
for C or websites that explain the analytical thinking or other tactics
involved in practical uses of C?

Your best starting point is the book Micah mentioned. It has a bunch of
exercises scattered throughout each chapter. Do them. It's astoundingly
good training for practical C use. As for analytical thinking, you could do
worse than stick around in comp.lang.c - some of the regular contributors
are fine exponents of the art. (See also Knuth's "The Art of Computer
Programming" - all three volumes - and don't be put off by the mathemagical
flavour.)
 
C

CBFalconer

Thanks alot for the response, a few minutes after posting I searched
this group and found hundreds of other threads about the same topic. I
apoligize as well for double posting, that was a mistake even though
I'm sure it must look like I tryed to bump my thread.

I wanted as well, to bring forth another concern that I have with
programming in general. Many people say that ACTUALLY PROGRAMMING
real-world programs is the best way to get better. That theory makes
sense, but when I sit down to write a program in java, I often realize
that I have mastered the sytnax and searching and sorting algorithms,
yet I cannot apply this to a real-world program. Are there any books
for C or websites that explain the analytical thinking or other tactics
involved in practical uses of C?

Our own Richard Heathfield has published such a book in "C
Unleashed". So have Kernighan & Pike "The Practice of
Programming". One of the best is Wirths "Algorithms + Data
Structures = Programs".

Get in the immediate habit of including adequate context in any
replies. Don't let the fact that you are posting through that
abortion of a usenet interface offered by google faze you. Read my
sig. below, and read the referenced URLs. Google IS NOT usenet.

All usenet articles need to stand by themselves. There is no
guarantee that any particular other article has ever reached, or
ever will reach, the reader. Even if it has, it may have been
deleted, or just be awkward to view. So quote adequately, and snip
quoted material that is irrelevant to your reply. Do not top-post,
your answer belongs after (or intermixed with) the material to
which you reply.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
M

mb1471

I hear it is very important to use a linux machine for c programming,
is this just a common myth or is there any truth there. I have been
considering switching to linux for this reason, but I'm not sure if
it's worth it..?
 
R

Richard Heathfield

mb1471 said:
I hear it is very important to use a linux machine for c programming,
is this just a common myth or is there any truth there.

It's a common myth - and like many myths, it has a huge amount of truth
behind it.

C is a portable language. Any box you can find a C compiler (or
cross-compiler) for, you can use for C programming. And if you write your
code carefully, very often the only thing you have to do to get your
program working on a different system is to recompile on the new system.
So, for example, you write your Widgetalyser on a Mac, get it working, copy
it over to a mainframe, recompile, and hey, presto! It works on the
mainframe too. And, one recompile later, it works on Linux too. And maybe
even on your mobile phone or microwave oven. (Er - maybe.)
I have been
considering switching to linux for this reason, but I'm not sure if
it's worth it..?

Oh, it's worth it all right. But perhaps you should put in a couple of years
on a Windows box first, just so that you'll be *really grateful* when you
change over. ;-)

Seriously, I don't like Windows (having used it for many years), I do like
Linux (having used it for a few years), but C doesn't care. You can get
good C compilers for Windows easily enough, legally for free in many cases.
The only thing to watch - er, one of a few things to watch is that you need
to be very firm with your typical Windows development environment. Be sure
to save your files with a .c extension, not a .cpp extension. Typical
Windows compilers will see a .cpp extension as an invitation to use C++
rules instead of C rules when compiling - with, as the saying goes, the
usual hilarious results.
 
R

Richard G. Riley

"(e-mail address removed)"posted the following on 2006-03-10:
Thanks alot for the response, a few minutes after posting I searched
this group and found hundreds of other threads about the same topic. I
apoligize as well for double posting, that was a mistake even though
I'm sure it must look like I tryed to bump my thread.

I wanted as well, to bring forth another concern that I have with
programming in general. Many people say that ACTUALLY PROGRAMMING
real-world programs is the best way to get better. That theory makes
sense, but when I sit down to write a program in java, I often realize
that I have mastered the sytnax and searching and sorting algorithms,
yet I cannot apply this to a real-world program. Are there any books
for C or websites that explain the analytical thinking or other tactics
involved in practical uses of C?

One great way is to analyse existing systems. You mentioned moving to
Linux : this is a great idea because you can compile and step through
existing apps with the debugger. Nothing brings you down to the real
"warm fuzzy" feeling that C can bring you : remember that C is a
compromise between high level and efficiency - when you know what you
are doing you can write C almost as efficiently as if you had hard
coded it in assembler. Efficiency aside, you will learn some good (and
bad) structures : the bottom line being, did you understand the flow
of the program after analysing it? If you did it might well be well
architected. I say might ... but that call comes with experience.

There are oodles of technical books out there
which are language independant including such legendary books as Knuth
- frankly they bore me to tears and are not indusive to a newbie
learning a specific language. The best programming book I ever read
was Kernighan & Ritchies C programming language : look it up on
Amazon. It is concise & practical and doesnt aim to dazzle the newbie
with unnecessary complications : it leads to concise, readable coding
style which makes use of the language as it should be used - not as
some nasty facelift of Java or Pascal.

Just stick with it : for the bang to the buck there are few languages
which come close to C.

Also, you'd better remember to include *some* context in your replies
or the usual suspects will be bombarding the NG with yet more
reminders about how to use googlegroups. Some even have .signatures
dedicated to just that.
 
N

Nick Keighley

Richard said:
"(e-mail address removed)"posted the following on 2006-03-10:

One great way is to analyse existing systems. You mentioned moving to
Linux : this is a great idea because you can compile and step through
existing apps with the debugger.

could we keep the platform bigotry down to a dull roar? Windows has
perfectly good debuggers available as well. So if you really want to
(I've never had the urge) you can "step through existing apps".

I've developed serious applications on both Linux and Windows. They are

both perfectly adequate. It is completly possible to develop
applications
on windows. For heavens sake Windows was *written* in C!

<snip>
 
J

Jordan Abel

mb1471 said:


It's a common myth - and like many myths, it has a huge amount of truth
behind it.

You forgot to mention what that truth is.

Linux, as a "unix-like" system, has a great deal of cultural heritage
that is a good "fit" for C, as C was originally developed for UNIX. This
can be useful [it's probably the type of system on which the implement-
ation of the standard functions is going to be most straightforward*],
but also dangerous [a lot of things that aren't really defined by the
standard are going to happen to work the way you'll assume they should]

*Note I wouldn't actually recommend trying to _read_ the glibc source,
though. If you seriously plan on doing that, get a unixy OS other than
linux. Say, FreeBSD. or Mac OSX. or SCO [well, that doesn't come with
source code, but i'm sure its source code is still more readable than
glibc even so]. really, anything.
 
R

Richard G. Riley

"Nick"posted the following on 2006-03-10:
could we keep the platform bigotry down to a dull roar? Windows has
perfectly good debuggers available as well. So if you really want to
(I've never had the urge) you can "step through existing apps".

No you cant. Firstly, I use multiple OSs : windows, OS/2 and Linux so
get away with your attempt to suggest this is an OS war bigotry.

Secondly, what system apps are you aware of in windows which come with
the C source code? Most are in C++ anyway. Most Gnome/Linux system is
in C. The OP was asking about C.
I've developed serious applications on both Linux and Windows. They are

both perfectly adequate. It is completly possible to develop
applications

Agreed. But see source comments above.
 
N

Nick Keighley

Richard said:
"Nick"posted the following on 2006-03-10:


No you cant. Firstly, I use multiple OSs : windows, OS/2 and Linux so
get away with your attempt to suggest this is an OS war bigotry.

Secondly, what system apps are you aware of in windows which come with
the C source code? Most are in C++ anyway. Most Gnome/Linux system is
in C. The OP was asking about C.

I thought you were implying Linux was better because the *debugger* was

better. I've never stepped through an existing application (that wasn't
broken)
with a debugger. If you say it's a good way to learn C, who am I to
argue.

But it *still* sounds bizzare to me

<snip>
 
R

Richard G. Riley

"Nick"posted the following on 2006-03-10:
I thought you were implying Linux was better because the *debugger* was

There is no "the debugger" : although gdb is prevalent in Linux -
albeit with several front ends.
better. I've never stepped through an existing application (that wasn't
broken)
with a debugger. If you say it's a good way to learn C, who am I to
argue.

I said its one way to get used to the structure and flow of
applications which is what he wants. Also, I do think a debugger can
give real insight into how C works in the real world : results of
operators there for you to see with no overhead of printfs which some favor.
But it *still* sounds bizzare to me

What does? Are we talking about the same thing? Do you doubt that
watching other, well written apps work is beneficial to a newbie? It
seems fairly clear to me that it can only help. Its how the entire
Open SW system works : people learning by doing and picking up on
other peoples work.
 
C

Chris Dollin

Richard said:
"Nick"posted the following on 2006-03-10:
There is no "the debugger" : although gdb is prevalent in Linux -
albeit with several front ends.


I said its one way to get used to the structure and flow of
applications which is what he wants. Also, I do think a debugger can
give real insight into how C works in the real world : results of
operators there for you to see with no overhead of printfs which some
favor.

The printf's are portable. The printf's work without manual intervention.
The printfs work without having to understand an additional tool.
What does? Are we talking about the same thing? Do you doubt that
watching other, well written apps work is beneficial to a newbie? It
seems fairly clear to me that it can only help. Its how the entire
Open SW system works : people learning by doing and picking up on
other peoples work.

You've conflated "learning by doing and picking up on> other peoples work"
with "watching ... apps work" and that with stepping through an application
using a debugger. I think that's misleading.
 
R

Richard G. Riley

"Chris"posted the following on 2006-03-10:
The printf's are portable. The printf's work without manual
intervention.

No they dont : you have to insert them in the code. But thats being
petty. Its rare that I find someone wanting their printfs to be
portable in a system process or a an X gui or a Win 32 winproc : they
dont work. Home grown or system supplied logging libraries possibly :
but can you really analyse them at run time? I cant : I like to step
through and see the flow of the app to get a feel for how the systems
heart is beating.
The printfs work without having to understand an additional tool.


You've conflated "learning by doing and picking up on> other peoples work"
with "watching ... apps work" and that with stepping through an application
using a debugger. I think that's misleading.

Really? Seems pretty straightforward to me and also how close on 100% of
Universities teach coding at some stage or other : adding modules to
existing systems. Maybe I'm a bit slow today but I'm not seeing the
subtleties of the point you are making here : the user is looking for
a way to learn how to structure applications and build them himself.

I fail to see how analysing existing, successful apps can be anything
other than beneficial. It doesnt take away the donkey work of learning
the lanugage basics, but it can make text book "science" much more
accessible and "real". I cant imagine becoming a programmer without
such practice, guidance and "practical training". Its the same in all
walks of life.
 
V

Vladimir S. Oka

Chris said:
You've conflated "learning by doing and picking up on> other peoples work"
with "watching ... apps work" and that with stepping through an application
using a debugger. I think that's misleading.

You've been trolled!

Especially in the light of the reply by the same person I couldn't
avoid seeing, as I'm forced to use Google from the office.
 
M

Mike Wahler

Nick Keighley said:
I thought you were implying Linux was better because the *debugger* was

better. I've never stepped through an existing application (that wasn't
broken)
with a debugger. If you say it's a good way to learn C, who am I to
argue.

But it *still* sounds bizzare to me

My $.02:

I learned C on MS-DOS systems. I found using a debugger
(even with 'working' code) to be an *extremely* good aid
in understanding the language and how it was implemented
on that system. E.g. when creating a new function, before
integrating it with the main program, I'd run it in a
'test harness' under a debugger, and more often than
not, I was able to find and fix bugs before they got
into the main application.

-Mike
 
D

Default User

Mike Wahler wrote:

I learned C on MS-DOS systems. I found using a debugger
(even with 'working' code) to be an extremely good aid
in understanding the language and how it was implemented
on that system. E.g. when creating a new function, before
integrating it with the main program, I'd run it in a
'test harness' under a debugger, and more often than
not, I was able to find and fix bugs before they got
into the main application.


Sure, but that's not what was claimed. The original statement said
"existing programs", so not the one under development. I don't think
tracing someone else's code is likely to be much of a learning tool.

Personally I've never found that even reading other code was useful for
learning basic programming. It teaches one how to read code, which is a
useful skill in and of itself, but not how to program. Only writing
code teaches you that.

An experienced programmer may well look at existing code for tips on
how to approach a problem, but that's another thing altogether.
 
M

Mike Wahler

Default User said:
Mike Wahler wrote:




Sure, but that's not what was claimed.

OK, perhaps I misunderstood. I was simply stating
that I found a debugger to be useful while learning
the language.

The original statement said
"existing programs", so not the one under development. I don't think
tracing someone else's code is likely to be much of a learning tool.

I think it can help (provided it's 'decent' code).
Personally I've never found that even reading other code was useful for
learning basic programming.

I have, especially textbook examples. I suppose this is
just a case of YMMV. :)
It teaches one how to read code, which is a
useful skill in and of itself, but not how to program. Only writing
code teaches you that.

I also think writing code is the probably the most useful way to learn.
My remarks about a debugger were in that context. "Write it, then
watch it."

An experienced programmer may well look at existing code for tips on
how to approach a problem, but that's another thing altogether.

-Mike
 
D

Default User

Mike said:
I have, especially textbook examples. I suppose this is
just a case of YMMV. :)

I don't mean short illustrative code examples as found in textbooks.
Those have been, hopefully, crafted for teaching purposes. That's not
usually the case with a full-blown program.
I also think writing code is the probably the most useful way to
learn. My remarks about a debugger were in that context. "Write it,
then watch it."

I would agree.



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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top