How to program my own code.

J

JoeNapoleon

Why I can not program my own code if I don't look at other's code.
How can I program by myself and not look at the book. Thank you.
 
E

Eric Sosman

Why I can not program my own code if I don't look at other's code.
How can I program by myself and not look at the book. Thank you.

The C language is relatively terse, and a perfectly sensible
"utterance" in C may look like a random string of gibberish to the
unpracticed. When you're just beginning, code like `while(*p++=*q++);'
may be difficult to understand, and it even has a tiny trap that could
lead your understanding astray!

But practice will improve your skill in reading C, and you will
get that practice by reading others' code and reading code in books
(unless you're unlucky enough to read bad books or bad code, of
course; there is unfortunately no shortage of either). In a fairly
short time you will become able to read most C with reasonable ease,
and will only need to open the book in extreme cases. Trust me: This
skill *will* come, and it will come sooner than you imagine if you
read good code frequently.

Another effect is that reading good code will improve your own
writing of code: You will learn what some call C's "idioms" and when
to use them as building blocks in your own constructions. You will
learn how to write more clearly, to communicate your code's intent
to future readers (including yourself in six months' time) who may
be trying to figure out what your code is supposed to do as opposed
to what it actually does ...

So, all I can suggest is that you stick with it. Skill will come
with practice, and you will become more self-sufficient as your skills
improve. Good luck!
 
W

Wolfgang.Draxinger

But practice will improve your skill in reading C, and you will
get that practice by reading others' code and reading code in books
(unless you're unlucky enough to read bad books or bad code, of
course; there is unfortunately no shortage of either). In a fairly
short time you will become able to read most C with reasonable ease,
and will only need to open the book in extreme cases. Trust me: This
skill *will* come, and it will come sooner than you imagine if you
read good code frequently.

Just for reference, some of the IMHO best open source C code you can
read for getting the grip of C are the programs by Daniel J. Bernstein,
in particular qmail, djbdns and the underlying libdjb. To
be found here: http://cr.yp.to

Another IMHO very good reference for high quality C are the
dietlibc and libowfat of Felix von Leitner. http://www.fefe.de/dietlibc
http://www.fefe.de/libowfat


Wolfgang
 
S

Seebs

Just for reference, some of the IMHO best open source C code you can
read for getting the grip of C are the programs by Daniel J. Bernstein,
in particular qmail, djbdns and the underlying libdjb. To
be found here: http://cr.yp.to

I think this marks the first time I've ever heard anyone suggest that
djb's code is good for learning from. Robust in the face of attack, maybe.

A quick browse of some of it does not leave me more impressed than I
used to be.

-s
 
R

ralph

I think this marks the first time I've ever heard anyone suggest that
djb's code is good for learning from. Robust in the face of attack, maybe.

A quick browse of some of it does not leave me more impressed than I
used to be.

lol

I always have an amount of respect for anyone that is willing to
publish what they have written, as I have never been able to look back
at code I've written, after as little as six months, without the
occasional wince, slap to the forehead, and a desire to rewrite a bit
of it. <bg>

-ralph
 
M

Morris Keesan

Just for reference, some of the IMHO best open source C code you can
read for getting the grip of C are the programs by Daniel J. Bernstein,
in particular qmail, djbdns and the underlying libdjb. To
be found here: http://cr.yp.to

I looked at the qmail source in detail, almost 10 years ago, and found
it to be almost unreadable: it had an almost total absence of comments,
and the names of functions and variables were terse beyond reason,
typically one or two characters, whose meaning only became (slightly)
clear after reading the entire body of a function to figure out what it
did. I thought the design of the application was quite nice, but the
code was some of the *worst* I've ever seen.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top