How to program my own code.

Discussion in 'C Programming' started by JoeNapoleon, Dec 10, 2011.

  1. JoeNapoleon

    JoeNapoleon Guest

    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.
    JoeNapoleon, Dec 10, 2011
    #1
    1. Advertising

  2. JoeNapoleon

    Eric Sosman Guest

    On 12/10/2011 7:57 AM, JoeNapoleon wrote:
    > 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!

    --
    Eric Sosman
    d
    Eric Sosman, Dec 10, 2011
    #2
    1. Advertising

  3. On Sat, 10 Dec 2011 08:24:32 -0500
    Eric Sosman <> wrote:

    > 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
    Wolfgang.Draxinger, Dec 16, 2011
    #3
  4. JoeNapoleon

    Seebs Guest

    On 2011-12-16, Wolfgang.Draxinger <-muenchen.de> wrote:
    > 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
    --
    Copyright 2011, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
    I am not speaking for my employer, although they do rent some of my opinions.
    Seebs, Dec 16, 2011
    #4
  5. JoeNapoleon

    ralph Guest

    On 16 Dec 2011 19:50:54 GMT, Seebs <> wrote:

    >On 2011-12-16, Wolfgang.Draxinger <-muenchen.de> wrote:
    >> 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.
    >


    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
    ralph, Dec 16, 2011
    #5
  6. On Fri, 16 Dec 2011 06:43:18 -0500, Wolfgang.Draxinger
    <-muenchen.de> wrote:

    > 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.

    --
    Morris Keesan --
    Morris Keesan, Dec 20, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    1
    Views:
    769
  2. BIGeasy

    My own program

    BIGeasy, Dec 3, 2004, in forum: C++
    Replies:
    2
    Views:
    347
    Howard
    Dec 3, 2004
  3. Saverio M.
    Replies:
    0
    Views:
    509
    Saverio M.
    Jul 3, 2006
  4. Replies:
    32
    Views:
    1,034
    Pascal Bourguignon
    Jan 25, 2008
  5. David Filmer
    Replies:
    17
    Views:
    258
    J. Romano
    Aug 18, 2004
Loading...

Share This Page