Productive C

Discussion in 'C Programming' started by Khookie, Jan 1, 2008.

  1. Khookie

    Khookie Guest

    Hi all

    OK, some stuff not necessarily related to the C spec, but please read
    - I would really appreciate advice from your collective experience.

    I'm currently writing a piece of software for the medical industry.
    It's going to be a HTTP server app serving pages so that multi-user
    deployment is real simple (and other reasons).

    Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    them, especially Python.

    I always find myself thinking whether I've made the right choice with
    C. At the moment, I find myself learning & reinventing stuff for C a
    fair bit. And I seem to be doing lots of debugging as well. For
    example earlier today, I forgot to update the header file when I
    repositioned a few char pointers in a struct. This stuffed me for
    about 2 hours - I couldn't figure out why reading struct values in
    another module had completely different values than to the module
    itself. Anyhow, I digress :).

    How are people's experiences with productive C coding? Do you find
    that you reach a certain point where you're fairly productive with C
    (not too much debugging, easier to add features, you're reusing your
    previously implemented functions and you know the standard library
    pretty well, etc.)?

    I also considered implementing the project in Python and then porting
    to C once it reaches maintenance mode... but then I'm not sure whether
    the gains made by sorting out a nice program structure quicker and
    having lots of libraries will be outweighed when I need to bring it
    over to C? Maybe I should check out an alternate language like C++/D?

    Anyone with thoughts in these areas?

    Chris
    Khookie, Jan 1, 2008
    #1
    1. Advertising

  2. Khookie

    Eric Sosman Guest

    Khookie wrote:
    > Hi all
    >
    > OK, some stuff not necessarily related to the C spec, but please read
    > - I would really appreciate advice from your collective experience.
    >
    > I'm currently writing a piece of software for the medical industry.
    > It's going to be a HTTP server app serving pages so that multi-user
    > deployment is real simple (and other reasons).
    >
    > Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    > news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    > them, especially Python.
    >
    > I always find myself thinking whether I've made the right choice with
    > C. At the moment, I find myself learning & reinventing stuff for C a
    > fair bit. And I seem to be doing lots of debugging as well. For
    > example earlier today, I forgot to update the header file when I
    > repositioned a few char pointers in a struct. This stuffed me for
    > about 2 hours - I couldn't figure out why reading struct values in
    > another module had completely different values than to the module
    > itself. Anyhow, I digress :).


    This is why it is a good idea (1) to #include the "exporting"
    header in the module that contains the definition and (2) to access
    struct elements by their names and not by what you think their
    order and offsets might be.

    > How are people's experiences with productive C coding? Do you find
    > that you reach a certain point where you're fairly productive with C
    > (not too much debugging, easier to add features, you're reusing your
    > previously implemented functions and you know the standard library
    > pretty well, etc.)?
    >
    > I also considered implementing the project in Python and then porting
    > to C once it reaches maintenance mode... but then I'm not sure whether
    > the gains made by sorting out a nice program structure quicker and
    > having lots of libraries will be outweighed when I need to bring it
    > over to C? Maybe I should check out an alternate language like C++/D?
    >
    > Anyone with thoughts in these areas?


    C is a relatively low-level and relatively general-purpose
    language. You may find that more specialized languages provide
    more built-in help for their specific tasks.

    Implementing in one language with the intent of porting to
    another strikes me as a poor idea, likely to lead to poor code.
    Next time you write a love poem to your Significant Other, try
    writing it in Russian and then hiring a professional translator
    to turn it into your S.O.'s favored tongue; compare the result
    to what you'd expect to get had you written in the chosen language
    in the first place.

    --
    Eric Sosman
    lid
    Eric Sosman, Jan 1, 2008
    #2
    1. Advertising

  3. Khookie

    Thad Smith Guest

    Khookie wrote:

    > How are people's experiences with productive C coding? Do you find
    > that you reach a certain point where you're fairly productive with C
    > (not too much debugging, easier to add features, you're reusing your
    > previously implemented functions and you know the standard library
    > pretty well, etc.)?


    That is true for me. A lot of it was developing habits appropriate for
    1) the language
    2) my applications and environment
    3) my personal strengths and weaknesses

    For example, I give more scrutiny to potential errors that would result in
    infrequent and hard to analyze symptoms (such as buffer overflow) than I do
    for errors which will result in a compiler error, since the latter will be
    much easier to find and fix.

    --
    Thad
    Thad Smith, Jan 1, 2008
    #3
  4. Khookie

    Chris Hills Guest

    In article
    <>,
    Khookie <> writes
    >Hi all
    >
    >OK, some stuff not necessarily related to the C spec, but please read
    >- I would really appreciate advice from your collective experience.
    >
    >I'm currently writing a piece of software for the medical industry.
    >It's going to be a HTTP server app serving pages so that multi-user
    >deployment is real simple (and other reasons).
    >
    >Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    >news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    >them, especially Python.
    >
    >I always find myself thinking whether I've made the right choice with
    >C. At the moment, I find myself learning & reinventing stuff for C a
    >fair bit. And I seem to be doing lots of debugging as well. For
    >example earlier today, I forgot to update the header file when I
    >repositioned a few char pointers in a struct. This stuffed me for
    >about 2 hours - I couldn't figure out why reading struct values in
    >another module had completely different values than to the module
    >itself. Anyhow, I digress :).


    Surely your static analyser picked it up?

    >
    >How are people's experiences with productive C coding?


    It's used a lot on high integrity systems.


    --
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
    /\/\/ www.phaedsys.org \/\/\
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Chris Hills, Jan 1, 2008
    #4
  5. Khookie

    Marc Guest

    > I'm currently writing a piece of software for the medical industry.
    > It's going to be a HTTP server app serving pages so that multi-user
    > deployment is real simple (and other reasons).


    Have you considered using a server side script language instead of C? PHP,
    for example. It's syntax is quite similar to C, so it won't be difficult to
    learn. Performance is the only reason I can find here to use C. Is
    performance really an issue?


    --
    Marc
    Marc, Jan 1, 2008
    #5
  6. Khookie

    Ivan Novick Guest

    On Jan 1, 7:49 am, Khookie <> wrote:
    > Hi all
    >
    > OK, some stuff not necessarily related to the C spec, but please read
    > - I would really appreciate advice from your collective experience.
    >
    > I'm currently writing a piece of software for the medical industry.
    > It's going to be a HTTP server app serving pages so that multi-user
    > deployment is real simple (and other reasons).
    >
    > Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    > news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    > them, especially Python.
    >
    > I always find myself thinking whether I've made the right choice with
    > C. At the moment, I find myself learning & reinventing stuff for C a
    > fair bit. And I seem to be doing lots of debugging as well. For
    > example earlier today, I forgot to update the header file when I
    > repositioned a few char pointers in a struct. This stuffed me for
    > about 2 hours - I couldn't figure out why reading struct values in
    > another module had completely different values than to the module
    > itself. Anyhow, I digress :).
    >
    > How are people's experiences with productive C coding? Do you find
    > that you reach a certain point where you're fairly productive with C
    > (not too much debugging, easier to add features, you're reusing your
    > previously implemented functions and you know the standard library
    > pretty well, etc.)?
    >
    > I also considered implementing the project in Python and then porting
    > to C once it reaches maintenance mode... but then I'm not sure whether
    > the gains made by sorting out a nice program structure quicker and
    > having lots of libraries will be outweighed when I need to bring it
    > over to C? Maybe I should check out an alternate language like C++/D?
    >
    > Anyone with thoughts in these areas?
    >
    > Chris


    Why are you even considering using C?

    If you don't know exactly why it is you are planning to use C probably
    you shouldn't be using it.

    There are many projects where C is the only viable option.... because
    of low level control , etc.

    It sounds like you don't need any of the advantages C has to offer.

    Regards,
    Ivan Novick
    http://www.0x4849.net
    Ivan Novick, Jan 1, 2008
    #6
  7. Khookie

    Mike Wahler Guest

    "Khookie" <> wrote in message
    news:...
    > Hi all
    >
    > OK, some stuff not necessarily related to the C spec, but please read
    > - I would really appreciate advice from your collective experience.
    >
    > I'm currently writing a piece of software for the medical industry.
    > It's going to be a HTTP server app serving pages so that multi-user
    > deployment is real simple (and other reasons).
    >
    > Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    > news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    > them, especially Python.
    >
    > I always find myself thinking whether I've made the right choice with
    > C.


    What were your reasons for choosing C for the project language?

    -Mike
    Mike Wahler, Jan 1, 2008
    #7
  8. On Jan 1, 10:49 am, Khookie <> wrote:

    > How are people's experiences with productive C coding? Do you find
    > that you reach a certain point where you're fairly productive with C
    > (not too much debugging, easier to add features, you're reusing your
    > previously implemented functions and you know the standard library
    > pretty well, etc.)?
    >


    Indeed, but in a fairly specialized domain. I know parts
    of the standard library very well, other parts not at all.



    > I also considered implementing the project in Python and then porting
    > to C once it reaches maintenance mode...



    Seem like a reasonable idea except for the bit about porting it
    to C (why would you want to do this?). Caveat: I know little about
    HTTP stuff, there may be a better choice than Python.

    - William Hughes
    William Hughes, Jan 1, 2008
    #8
  9. Khookie <> writes:
    > OK, some stuff not necessarily related to the C spec, but please read
    > - I would really appreciate advice from your collective experience.

    [...]
    > For
    > example earlier today, I forgot to update the header file when I
    > repositioned a few char pointers in a struct. This stuffed me for
    > about 2 hours - I couldn't figure out why reading struct values in
    > another module had completely different values than to the module
    > itself. Anyhow, I digress :).


    If you do things correctly, this particular kind of error should be
    nearly impossible to make in the first place. It sounds like you
    either have definitions for the same struct in two different places,
    or you're accessing members of the struct by some means other than
    referring to their names.

    Define the struct in a single header. Any source file that needs
    access to the struct definition has a #include for that header. The
    layout will never get out of synch because there's nothing to get out
    of synch.

    Another possible way to have this kind of problem would be to change
    the definition, but forget to recompile files that depend on it. A
    good build environment should prevent that from happening by forcing a
    file to be recompiled whenever something it depends on changes. <OT>A
    Makefile lets you specify the dependencies, but doesn't automatically
    guarantee you've specified them correctly.</OT>

    [...]

    > I also considered implementing the project in Python and then porting
    > to C once it reaches maintenance mode... but then I'm not sure whether
    > the gains made by sorting out a nice program structure quicker and
    > having lots of libraries will be outweighed when I need to bring it
    > over to C? Maybe I should check out an alternate language like C++/D?

    [...]

    At a previous job, I had planned to prototype a large chunk of code in
    Perl, and then reimplement in C for speed. It turned out the Perl
    code was more than fast enough (the major bottleneck was elsewhere),
    so rewriting in C wouldn't have helped significantly. (Whether Perl
    or C would have been a better implementation language in the first
    place is another question.)

    --
    Keith Thompson (The_Other_Keith) <>
    [...]
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jan 1, 2008
    #9
  10. Khookie

    Rico Secada Guest

    On Tue, 1 Jan 2008 07:49:34 -0800 (PST)
    Khookie <> wrote:

    > Hi all
    >
    > OK, some stuff not necessarily related to the C spec, but please read
    > - I would really appreciate advice from your collective experience.
    >
    > I'm currently writing a piece of software for the medical industry.
    > It's going to be a HTTP server app serving pages so that multi-user
    > deployment is real simple (and other reasons).
    >
    > Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    > news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    > them, especially Python.
    >
    > I always find myself thinking whether I've made the right choice with
    > C. At the moment, I find myself learning & reinventing stuff for C a
    > fair bit. And I seem to be doing lots of debugging as well. For
    > example earlier today, I forgot to update the header file when I
    > repositioned a few char pointers in a struct. This stuffed me for
    > about 2 hours - I couldn't figure out why reading struct values in
    > another module had completely different values than to the module
    > itself. Anyhow, I digress :).
    >
    > How are people's experiences with productive C coding? Do you find
    > that you reach a certain point where you're fairly productive with C
    > (not too much debugging, easier to add features, you're reusing your
    > previously implemented functions and you know the standard library
    > pretty well, etc.)?
    >
    > I also considered implementing the project in Python and then porting
    > to C once it reaches maintenance mode... but then I'm not sure whether
    > the gains made by sorting out a nice program structure quicker and
    > having lots of libraries will be outweighed when I need to bring it
    > over to C? Maybe I should check out an alternate language like C++/D?
    >
    > Anyone with thoughts in these areas?
    >
    > Chris


    Hi Chris.

    It looks like you haven't done a proper evaluation of language-use in
    your project.

    You must define exactly what you want to achieve and by doing that, you
    will better be able to judge what kind of language will meet your
    specific needs.

    If you are in doubt whether you should do it in C or Python then you
    haven't evaluated properly.
    Rico Secada, Jan 2, 2008
    #10
  11. Khookie

    Al Balmer Guest

    On Wed, 2 Jan 2008 11:45:19 +0100, Rico Secada <> wrote:

    >On Tue, 1 Jan 2008 07:49:34 -0800 (PST)
    >Khookie <> wrote:
    >
    >> Hi all
    >>
    >> OK, some stuff not necessarily related to the C spec, but please read
    >> - I would really appreciate advice from your collective experience.
    >>
    >> I'm currently writing a piece of software for the medical industry.
    >> It's going to be a HTTP server app serving pages so that multi-user
    >> deployment is real simple (and other reasons).
    >>
    >> Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
    >> news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
    >> them, especially Python.
    >>
    >> I always find myself thinking whether I've made the right choice with
    >> C. At the moment, I find myself learning & reinventing stuff for C a
    >> fair bit. And I seem to be doing lots of debugging as well. For
    >> example earlier today, I forgot to update the header file when I
    >> repositioned a few char pointers in a struct. This stuffed me for
    >> about 2 hours - I couldn't figure out why reading struct values in
    >> another module had completely different values than to the module
    >> itself. Anyhow, I digress :).
    >>
    >> How are people's experiences with productive C coding? Do you find
    >> that you reach a certain point where you're fairly productive with C
    >> (not too much debugging, easier to add features, you're reusing your
    >> previously implemented functions and you know the standard library
    >> pretty well, etc.)?
    >>
    >> I also considered implementing the project in Python and then porting
    >> to C once it reaches maintenance mode... but then I'm not sure whether
    >> the gains made by sorting out a nice program structure quicker and
    >> having lots of libraries will be outweighed when I need to bring it
    >> over to C? Maybe I should check out an alternate language like C++/D?
    >>
    >> Anyone with thoughts in these areas?
    >>
    >> Chris

    >
    >Hi Chris.
    >
    >It looks like you haven't done a proper evaluation of language-use in
    >your project.
    >
    >You must define exactly what you want to achieve and by doing that, you
    >will better be able to judge what kind of language will meet your
    >specific needs.
    >
    >If you are in doubt whether you should do it in C or Python then you
    >haven't evaluated properly.


    The question isn't actually about which language is better for the
    project - we don't have enough information to comment on that.
    However, I think we can answer the questions in the "How are people's
    experiences" paragraph with "Yes to all the above." The questions in
    the next to last paragraph, again need more information, except to
    comment that "sorting out a nice program structure quicker" comes with
    experience in C, and, depending on the project, may actually be easier
    in C than in a OO language.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Jan 2, 2008
    #11
    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. =?Utf-8?B?QXNobGV5?=

    Installation on productive system

    =?Utf-8?B?QXNobGV5?=, May 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    340
    Pete Wright
    May 24, 2004
  2. ToddLMorgan
    Replies:
    17
    Views:
    467
    Lawrence D'Oliveiro
    Apr 27, 2006
  3. microteq
    Replies:
    0
    Views:
    304
    microteq
    Aug 6, 2007
  4. java
    Replies:
    0
    Views:
    342
  5. Jacob Fugal
    Replies:
    34
    Views:
    309
    Gregory Brown
    Sep 13, 2006
Loading...

Share This Page