To C or not to C, that is the question...

R

Rehceb Rotkiv

Hello everyone,

I'm using Linux since quite a while now and I'm happy to notice that I'm
beginning to "know my way round". I can write little bash, sed and awk
scripts to help me with my everyday tasks and I've also had a thorough
look at Python, which is ideally suited for helping me with my work,
which is linguistic research, i.e. mainly text processing.

However, this does not seem to be of much use in understanding and
modifying source code of Linux applications, 90% of which seem to be
written in C. I do not want to write revolutionary new programs, I'd just
like to look under the hood of some Linux apps and perhaps write a little
patch here and there to adapt them for my purposes and, in this way,
maybe even contribute back to the Open Source community one day.

The problem is, C doesn't look at all like the newbie-friendly "written
pseudo-code" walk-in-the-park that is Python! Variable declarations,
pointers, memory allocations... I'm scared! My main concern is: Is it
even feasible for me to learn enough C for the above purposes in my
restricted spare time (which would be pretty much 8 PM till 8 AM! ;) or
should I leave that to the computer science students and full-time Linux
hackers?

I would be glad if you could tell me about your own experiences with C --
and whether I should or shouldn't learn it from your point
of view.

With best regards,
Rehceb
 
U

user923005

Hello everyone,

I'm using Linux since quite a while now and I'm happy to notice that I'm
beginning to "know my way round". I can write little bash, sed and awk
scripts to help me with my everyday tasks and I've also had a thorough
look at Python, which is ideally suited for helping me with my work,
which is linguistic research, i.e. mainly text processing.

However, this does not seem to be of much use in understanding and
modifying source code of Linux applications, 90% of which seem to be
written in C. I do not want to write revolutionary new programs, I'd just
like to look under the hood of some Linux apps and perhaps write a little
patch here and there to adapt them for my purposes and, in this way,
maybe even contribute back to the Open Source community one day.

The problem is, C doesn't look at all like the newbie-friendly "written
pseudo-code" walk-in-the-park that is Python! Variable declarations,
pointers, memory allocations... I'm scared! My main concern is: Is it
even feasible for me to learn enough C for the above purposes in my
restricted spare time (which would be pretty much 8 PM till 8 AM! ;) or
should I leave that to the computer science students and full-time Linux
hackers?

I would be glad if you could tell me about your own experiences with C --
and whether I should or shouldn't learn it from your point
of view.

Buy or borrow a copy of
"The C Programming Language"
by Brian W. Kernighan and Dennis M. Ritchie.
Prentice Hall, Inc., 1988.
ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback).

It's 272 pages long, including the index. In about one month you can
learn enough to become a C programmer with nothing to be ashamed of
(if you apply yourself). I don't think C is more difficult than
Python so if you became comfortable in Python you will be able to do
the same thing with C.

By the way, you've come to the right place to ask questions.
 
B

Barry

user923005 said:
Buy or borrow a copy of
"The C Programming Language"
by Brian W. Kernighan and Dennis M. Ritchie.
Prentice Hall, Inc., 1988.
ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback).

It's 272 pages long, including the index. In about one month you can
learn enough to become a C programmer with nothing to be ashamed of
(if you apply yourself). I don't think C is more difficult than
Python so if you became comfortable in Python you will be able to do
the same thing with C.

By the way, you've come to the right place to ask questions.

How has it been since you read it? Certainly more than one month.
Yes I mean to imply something.
 
U

user923005

How has it been since you read it?

It has not changed since I read it. I pick it up from time to time
(it's within arm's reach at my desk) and verify things.
Certainly more than one month.

I have read from in recently, if that is what you are implying. I
guess your first sentence was supposed to be "How long has it been
since you read it?"
If that is the case, it has been 20 years since I read it from cover
to cover. And yet if you master that simple book, less than 1/2 inch
thick, then you will definitely be an expert in the C language. In
fact, that is the main beauty of C. It is not something with
megabytes of features that takes years to learn.
Yes I mean to imply something.

I guess it will be better if you just come out and say it. Then we
can make fun of you and we'll all have a good belly-laugh.

Yes, I also meant to imply something.
 
B

Barry

user923005 said:
It has not changed since I read it. I pick it up from time to time
(it's within arm's reach at my desk) and verify things.


I have read from in recently, if that is what you are implying. I
guess your first sentence was supposed to be "How long has it been
since you read it?"
If that is the case, it has been 20 years since I read it from cover
to cover. And yet if you master that simple book, less than 1/2 inch
thick, then you will definitely be an expert in the C language. In
fact, that is the main beauty of C. It is not something with
megabytes of features that takes years to learn.


I guess it will be better if you just come out and say it. Then we
can make fun of you and we'll all have a good belly-laugh.

Yes, I also meant to imply something.

The next time you post something incorrect I will take the time
to correct it for you. I don't have a copy of K&R2, but I can
probably find a copy of K&R around here somewhere.

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

Barry
 
D

Dave Vandervies

Barry said:
My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

If the OP already has some skill in programming, a month of seriously
studying K&R2 will be more than enough to acquire a basic competence
with C.
Becoming an expert will take longer, but the OP seems to be interested
in acquiring basic competence, not becoming an expert.


dave
 
B

Barry

Dave Vandervies said:
If the OP already has some skill in programming, a month of seriously
studying K&R2 will be more than enough to acquire a basic competence
with C.
Becoming an expert will take longer, but the OP seems to be interested
in acquiring basic competence, not becoming an expert.


dave

Perhaps you should reply to my question about arbitrary returns
in correct portbable C.
 
U

user923005

The next time you post something incorrect I will take the time
to correct it for you.

Believe it or not, I will deeply appreciate it.
I don't have a copy of K&R2, but I can
probably find a copy of K&R around here somewhere.

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month.

In one month of intense effort, I believe that the OP could not only
become an adequate C programmer, but even be good enough for junior
level work on C projects. That is the main beauty of the C language.
The same thing cannot be said for C++ or .NET languages or even SQL.
The real excellence of C is its simplicity. That is one reason that I
really like it.
I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

No need to apologize. My opinion is no better than yours.
 
U

user923005

Perhaps you should reply to my question about arbitrary returns
in correct portbable C.

No poster is obligated to post replies in a subject for which he/she
lacks interest in responding. Structural arguments tend to foment
religious fervor (e.g. what about goto, what about multiple returns).

Let me say something about multiple returns:
1. They're bad.
2. I use them.

They are bad because they can cause a lot of problems, especially if
the routine is allocating resources like memory or file handles or
things of that nature. On the other hand, I often do a big heap of
tests right at function entry to see if things are in order. If (for
instance) your file name is NULL or the length of some string is -7 or
some other naughty-no-no I am liable to return right away, after
handling the error (if possible). And so I do not object to this
particular format:

<type> some_func(param_list,...)
{
/* do a heap of parameter checks... */
if (something_is_seriously_haywire)
{
handle_error();
return FOO_STATUS_FAILURE; /* Or *status = FOO_STATUS_FAILURE or
whatever... */
}

/* One hundred or more lines of important glop go here... */

return FOO_STATUS_SUCCESS;
}

Every rule is meant to be broken except one:
Use good sense when you write your program and always do the right
thing.
 
K

Keith Thompson

Barry said:
[...]

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

I have to agree with Barry. Working your way through K&R2 will give
you a good basic working knowledge of C, but it will hardly make you
an expert. That takes practice and experience.

But it's a good first step on the road to becoming an expert,
especially if you already have some programming experience.
 
K

Keith Thompson

Barry said:
Perhaps you should reply to my question about arbitrary returns
in correct portbable C.

It would help if you could explain just what you're trying to
accomplish.
 
B

Barry

user923005 said:
Believe it or not, I will deeply appreciate it.


In one month of intense effort, I believe that the OP could not only
become an adequate C programmer, but even be good enough for junior
level work on C projects. That is the main beauty of the C language.
The same thing cannot be said for C++ or .NET languages or even SQL.
The real excellence of C is its simplicity. That is one reason that I
really like it.


No need to apologize. My opinion is no better than yours.

Unlike you (I expect), I started my career writing assembly language
device drivers. When someone found the time to write a C compiler
for the devices I was using they (the devices) were nearly obsolete.
But I have been bitten more than once for writing sloppy C, and that
is the type of thing you don't learn from a month of reading K&R2.

Mr. Heathfield will certainly agree that he didn't learn C in a month.
I have never seen his book, but I do read his comments.
He recently posted a note about the knowledgeable posters on
c.l.c, and if you watch the comments from that list of folks
you will find it wasn't by accident.

Like I said, if I am wrong...it won't be the first time. Millions
of people use code I wrote in C every day. Since it "works"
only I know how poorly it was designed and written.

Barry
 
C

Clever Monkey

Barry said:
The next time you post something incorrect I will take the time
to correct it for you. I don't have a copy of K&R2, but I can
probably find a copy of K&R around here somewhere.

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.
Let's review the original reply, shall we?

"In about one month you can learn enough to become a C programmer with
nothing to be ashamed of (if you apply yourself)."

In terms of adequate understanding to poke around in non-kernel stuff on
Linux, I have to agree that one month will certainly give you enough
traction to get somewhere useful.

Especially since he then went on to say:

"By the way, you've come to the right place to ask questions."

I read this to mean that you will get further in your education if you
read, practice and ask questions about what you discover and don't
understand. A good place to ask such questions is this very forum.

If you already have the basics of programming, and can already wrap your
head around variables, logic and flow constructs, then C isn't much of a
stretch. It's just easier to make mistakes that crash and burn. Some
see this as a Good Thing in a learning language.

"A month (or so) to learn. A lifetime to master."
 
B

Barry

Keith Thompson said:
It would help if you could explain just what you're trying to
accomplish.

I made the mistake of referring to a previous note and did not
include the proper context. I apologize.

Barry
 
D

Dave Vandervies

Barry said:
Perhaps you should reply to my question about arbitrary returns
in correct portbable C.

Perhaps if you want useful answers you should read the ones you've
already gotten, and explain what's wrong with them in a way that lets
people establish that it's worth giving you another one.

You won't be getting any more from me, though.
**PLONK**


dave
 
B

Barry

Dave Vandervies said:
Perhaps if you want useful answers you should read the ones you've
already gotten, and explain what's wrong with them in a way that lets
people establish that it's worth giving you another one.

You won't be getting any more from me, though.
**PLONK**
I think you missed my point. I didn't want to see you make anymore
stupid posts to c.l.c. Hopefully it worked.
 
U

user923005

[...]>>> "user923005 said:
Buy or borrow a copy of
"The C Programming Language"
by Brian W. Kernighan and Dennis M. Ritchie.
Prentice Hall, Inc., 1988.
ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback).
It's 272 pages long, including the index. In about one month you can
learn enough to become a C programmer with nothing to be ashamed of
(if you apply yourself). I don't think C is more difficult than
Python so if you became comfortable in Python you will be able to do
the same thing with C.
[...]

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

I have to agree with Barry. Working your way through K&R2 will give
you a good basic working knowledge of C, but it will hardly make you
an expert. That takes practice and experience.

Here is what the OP asked:
"My main concern is: Is it even feasible for me to learn enough C for
the above purposes in my restricted spare time (which would be pretty
much 8 PM till 8 AM! ;) or should I leave that to the computer science
students and full-time Linux hackers?"

In what way is guru status implied here?
But it's a good first step on the road to becoming an expert,
especially if you already have some programming experience.

For someone who can already write code in Python, I guess that after
one month of intense effort learning the language, he could contribute
to open source projects at some level.

As evidence, I would say to examine the excellent progress of 'arnuld'
who is clearly going over K&R2 carefully. Now, Arnuld has been at it
for about two months, but C is also his first programming language.
For someone in that situation, I think K&R2 is probably not the ideal
choice because of its terseness. Maybe K. N. King's book or is easier
in that case.

At any rate, I think that someone who is already a programmer can
become adequate in C in one month to the level that they can
contribute to an open source project.

IMO-YMMV.

Obviously, it depends on the intelligence and motivation of the
student, but typically people who want to become programmers are
intelligent and motivated.
 
B

banansol

I think you missed my point. I didn't want to see you make anymore
stupid posts to c.l.c. Hopefully it worked.

This way I won't see _your_ stupid posts here anymore
**PLONK**
 
I

Ian Collins

Barry said:
Unlike you (I expect), I started my career writing assembly language
device drivers. When someone found the time to write a C compiler
for the devices I was using they (the devices) were nearly obsolete.
But I have been bitten more than once for writing sloppy C, and that
is the type of thing you don't learn from a month of reading K&R2.
Did you have to quote the entire thread just to say that?

A crap programmer could spend years studying a language and still write
crap code. A competent one should have no problem getting up and
running in C in a month.
 
K

Keith Thompson

user923005 said:
[...]>>> "user923005 said:
Buy or borrow a copy of
"The C Programming Language"
by Brian W. Kernighan and Dennis M. Ritchie.
Prentice Hall, Inc., 1988.
ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback).
It's 272 pages long, including the index. In about one month you can
learn enough to become a C programmer with nothing to be ashamed of
(if you apply yourself). I don't think C is more difficult than
Python so if you became comfortable in Python you will be able to do
the same thing with C.
[...]

My comment was not about the quality of K&R2, but your
statement that someone could be an adequate C programmer
in a month. I am sure we will get some comments from other
folks, and I expect them to agree with me. If I am wrong I
apologize up front.

I have to agree with Barry. Working your way through K&R2 will give
you a good basic working knowledge of C, but it will hardly make you
an expert. That takes practice and experience.

Here is what the OP asked:
"My main concern is: Is it even feasible for me to learn enough C for
the above purposes in my restricted spare time (which would be pretty
much 8 PM till 8 AM! ;) or should I leave that to the computer science
students and full-time Linux hackers?"

In what way is guru status implied here?
[...]

Sorry, I inadvertently snipped the paragraph to which I was actually
reacting.

Upthread, you (user923005) wrote:
| If that is the case, it has been 20 years since I read it from cover
| to cover. And yet if you master that simple book, less than 1/2 inch
| thick, then you will definitely be an expert in the C language. In
| fact, that is the main beauty of C. It is not something with
| megabytes of features that takes years to learn.

I took issue with your use of the word "expert". Apart from that,
we're probably pretty much in agreement.

Perhaps by "master that simple book" you were referring to something
that would take more than a month?

You can certainly become a reasonably decent C programmer given
personal potential, a copy of K&R2, and a month or so of work.
Becoming an expert requires more experience.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top