Too Big

Discussion in 'C Programming' started by Kamilche, Oct 4, 2003.

  1. Kamilche

    Kamilche Guest

    I switched to C a couple years ago. I've also been working on this
    huge, complex app. It's finally gotten so big, that I'm having a hard
    time keeping it all in my head, and find it difficult to continue to
    use C for its development.

    I have loved the performance C has given me, and have used it quite
    successfully on small to medium sized apps, and DLL's. But with this
    huge project, it's proving troublesome to use. I've redone enough of
    the app in other languages to do stress testing, and have settled on
    plain old VB6. It gives me about half the performance of C, with
    object orientation and great ease-of-use. For comparison, C++ totally
    lacks ease-of-use (though its speed is decent), and Python is slower
    than C for this app by a factor of 15.

    I just thought I'd post here, and let you guys know. I'll probably
    post a lot of the supporting modules I've written to Planet Source,
    for use by other C programmers, just so my time in writing those
    modules won't have been totally wasted. Thanks for all the help you
    have given me in this newsgroup.

    --Kamilche
     
    Kamilche, Oct 4, 2003
    #1
    1. Advertising

  2. Kamilche

    CBFalconer Guest

    Kamilche wrote:
    >
    > I switched to C a couple years ago. I've also been working on this
    > huge, complex app. It's finally gotten so big, that I'm having a hard
    > time keeping it all in my head, and find it difficult to continue to
    > use C for its development.

    .... snip ...

    I think that indicates a failure to partition correctly. C
    actually has very good capabilities to separate modules and limit
    interfaces, it just isn't especially good at enforcing such.
    Generally you should try to apply the rule of seven, because that
    is about the limit of easy human comprehension.

    I.E. a function should deal with no more than 7 items, including
    locals and parameters. I trust it has no globals.

    A compilation unit should expose seven functions and types. This
    often gets bent a bit.

    In C, heavy use of the word 'static' is your friend. Pare down
    the .h files to the bare essentials, plus enough commentary to
    serve as a reference guide.

    A compilation unit should probably not need to refer to more than
    7 other compilation units (apart from the standard library).

    You can build up your make files with these ideas in mind.
    Switching to an unstructured, unsupported, non-portable and
    proprietary language such as VB should be a major step backwards.
    The only thing that makes easier is a GUI user interface. You can
    always use it, or something like it, to call your well structured
    complex application and deliver its results.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Oct 4, 2003
    #2
    1. Advertising

  3. Kamilche

    Micah Cowan Guest

    (Kamilche) writes:

    > I switched to C a couple years ago. I've also been working on this
    > huge, complex app. It's finally gotten so big, that I'm having a hard
    > time keeping it all in my head, and find it difficult to continue to
    > use C for its development.


    This is usually (to me) a huge indication of poor design. You
    should *never* have to keep much of any program in your head: it
    should be plain-as-day just by looking at it. I'm very skeptical
    that simply changing your medium of expression (programming
    language) is going to improve that much. But hey, good luck.

    My advice would be, starting with the modules you find yourself
    wading through most frequently, a redesign which will enable you
    to find your way comfortably without having to actually read the
    low-level details.

    -Micah
     
    Micah Cowan, Oct 5, 2003
    #3
  4. Kamilche

    Kamilche Guest

    CBFalconer <> wrote in message news:<>...

    > I think that indicates a failure to partition correctly. C
    > actually has very good capabilities to separate modules and limit
    > interfaces, it just isn't especially good at enforcing such.


    The memory assists you get working with VB (and C++) are awesome. I
    grow weary of having to remember every function call for every data
    type... in VB, I just type the variable name, then a dot, and all the
    methods and variables pop up in a handy list, awaiting my selection.
    'Intellisense'.

    But it's more than that. There's better encapsulation available for
    OOP languages. I've been 'faking it' myself in C, but I recently
    stumbled across a bug that was so subtle and well-hidden, it's a
    miracle I found it. I know that happens in VB and other languages as
    well, but with C, everything is taking about 10x longer to code. Those
    bugs pop up a lot sooner, when you have the core of your app done in a
    month, as opposed to 10 months. Ya know?

    Maybe I just suck at C. It could be. Maybe I'm a child of the VB age,
    unable to learn how to use other languages effectively. I don't think
    so though. I cut my teeth on programming back before the Internet was
    around, and have programmed in quite a few languages - COBOL,
    HyperCard, VB, more.

    It would probably be better if I had someone to program with. Maybe it
    wouldn't seem so tough then. But I don't, and wishing won't make it
    so. These OOP languages with intellisense make up for it to some
    degree.

    I really like a lot of aspects about Python, though how it handles
    global variables suck. I wish it was in the same ballpark, speed-wise,
    because I'd use it if it was, even with its quirks.

    --Kamilche
     
    Kamilche, Oct 5, 2003
    #4
  5. Kamilche

    Mike Wahler Guest

    "Kamilche" <> wrote in message
    news:...
    > CBFalconer <> wrote in message

    news:<>...
    >
    > > I think that indicates a failure to partition correctly. C
    > > actually has very good capabilities to separate modules and limit
    > > interfaces, it just isn't especially good at enforcing such.

    >
    > The memory assists you get working with VB (and C++) are awesome.


    I think you're mistaking an IDE for a language.

    > grow weary of having to remember every function call for every data
    > type...


    Yes, I think you're mistaking and IDE for a language.

    >in VB, I just type the variable name, then a dot, and all the
    > methods and variables pop up in a handy list, awaiting my selection.
    > 'Intellisense'.


    That is not the Visual Basic language doing that, it's the IDE.
    I often use Visual Studio with Microsoft Visual C++ compiler.
    Visual Studio (an IDE) also has this 'pop up' feature listing
    class members when writing C++.

    > But it's more than that. There's better encapsulation available for
    > OOP languages.


    What are you talking about? Encapsulation is achievable in
    almost any language. Encapsulation is not a language feature
    in itself, it's a design strategy. Some languages have features
    which make encapsulation feel "more natural" than others.

    >I've been 'faking it' myself in C,


    No faking needed. C is perfectly capable of expressing
    encapsulation. The constructs used might differ from
    those used by other languages.

    >but I recently
    > stumbled across a bug that was so subtle and well-hidden, it's a
    > miracle I found it.


    Anyone will create hard to find bugs from time to time.
    IMO practice and experience, combined with code reviews,
    testing and debugging comprise the only remedy.

    > I know that happens in VB and other languages as
    > well, but with C, everything is taking about 10x longer to code.


    C is a 'lower level' language than some others, e.g. Visual Basic.
    It's good for some things, but for other things another language
    might be more appropriate. You seem to be on a quest to find the
    "best language." No such thing exists. A hammer is the best
    tool for pounding nails, a saw the best tool for cutting lumber.

    A good programmer will know several languages, and always be
    on the lookout for tools best suited for a given task.

    > Those
    > bugs pop up a lot sooner, when you have the core of your app done in a
    > month, as opposed to 10 months. Ya know?


    No I don't know. A language by itself cannot help your productivity
    or efficiency. Discipline and strategy, and careful selection and
    application of tools (including languages) can. IMO too many people
    start typing code when they still don't have a clear design and/or
    goal.

    >
    > Maybe I just suck at C. It could be.


    It seems to be you're having a difficult time distinguishing
    tools from design and strategy.

    > Maybe I'm a child of the VB age,


    Perhaps. It does cause me some concern that so many people
    who learn how to push and point and click with VB, and create
    an application somehow are led to believe that they've magically
    become programmers. They've merely learned how to operate the
    controls of one particular machine. They haven't learned what
    programming is at all. Programming is the analysis and solution
    of problems. This requires many tools, of which programming
    languages are a small set.

    > unable to learn how to use other languages effectively.


    Don't get so close to a given language, and don't try to
    apply concepts specific to one language to others. Try to
    view things more generally, and you'll more readily recognize
    how concepts common to all languages are best expressed and
    utilized in each.

    >I don't think
    > so though. I cut my teeth on programming back before the Internet was
    > around,


    I doubt that. Do you really know how old the internet is?
    Most folks don't.

    >and have programmed in quite a few languages - COBOL,
    > HyperCard, VB, more.


    COBOL is the only one of those three that I consider a
    'mature' language. This is only my opinion, but Visual Basic
    and Hypercard are only recent inventions, whose lifetimes
    are still in question. And both are very specialized, with
    limited scope.

    >
    > It would probably be better if I had someone to program with.


    Yes, two (or more) heads are almost better than one. Witness
    the (imo) success of the XP concept of "pair programming".
    But you're really not alone. You have these wonderful newsgroups. :)

    > Maybe it
    > wouldn't seem so tough then. But I don't, and wishing won't make it
    > so. These OOP languages


    None of the languages you mention are "OOP languages". Some
    have features which let you do OOP, but don't limit you to it.

    Also, don't believe that OOP (or any other paradigm) is
    the answer to all programming. OOP is very useful for
    some things, but not appropriate at all for others.

    >with intellisense


    "Intellisense" is a Microsoft technology which is part of
    their IDEs. It is *not* part of *any* programming language.

    >make up for it to some
    > degree.


    Yes, many if not all IDEs can enhance productivity. But imo
    the "flip side of the coin", is that many are misled into believing
    they're somehow part of a language with which they're being used.

    >
    > I really like a lot of aspects about Python, though how it handles
    > global variables suck. I wish it was in the same ballpark, speed-wise,
    > because I'd use it if it was, even with its quirks.


    This is more support for my statements above that a single language
    will *not* suffice for the professional programmer. One language
    simply cannot serve as an "all purpose tool." Learn many languages,
    and apply them to the task at which they perform the best.

    -Mike
     
    Mike Wahler, Oct 5, 2003
    #5
  6. Kamilche

    Serve La Guest

    "Kamilche" <> wrote in message
    news:...
    > I switched to C a couple years ago. I've also been working on this
    > huge, complex app. It's finally gotten so big, that I'm having a hard
    > time keeping it all in my head, and find it difficult to continue to
    > use C for its development.


    This is what I read:
    bad documentation, bad modularization.

    You shouldn't have to have any project completely in your head, no matter
    what language you use.
     
    Serve La, Oct 5, 2003
    #6
  7. Kamilche

    CBFalconer Guest

    Kamilche wrote:
    > CBFalconer <> wrote:
    >
    > > I think that indicates a failure to partition correctly. C
    > > actually has very good capabilities to separate modules and limit
    > > interfaces, it just isn't especially good at enforcing such.

    >
    > The memory assists you get working with VB (and C++) are awesome. I
    > grow weary of having to remember every function call for every data
    > type... in VB, I just type the variable name, then a dot, and all the
    > methods and variables pop up in a handy list, awaiting my selection.
    > 'Intellisense'.


    Try Cscope.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Oct 5, 2003
    #7
  8. Kamilche

    Kamilche Guest

    "Serve La" <> wrote in message news:<blp15e$l47$1.nb.home.nl>...

    > This is what I read:
    > bad documentation, bad modularization.
    >
    > You shouldn't have to have any project completely in your head, no matter
    > what language you use.


    I agree. But what do you in this regard? I have a memory module, a
    hash table module, a buffer module, etc., as do most C programmers I
    imagine.

    The hash table uses the memory module. The string module uses the
    buffer module, which uses the memory module. Now, whenever I use
    memory in the program, or a hash table, I have to remember or look up
    the syntax for every function I've ever written against those custom
    datatypes. Some I use so often, I have memorized - mem_alloc,
    mem_resize, etc. Some, I only use intermittently - buffer_create,
    buffer_add, etc.

    In the string class, I have to say 'buffer_add(blah, blah blah) to add
    stuff to the end of an internally manipulated buffer. I would LIKE to
    say 'string.add', and be done with it. Write once and forget it, sort
    of thing. I can't do that in C. Not only do I have to remember that
    I'm using a buffer for internal string manipulation, I have to
    remember the buffer function calls syntax as well. You see?

    Multiply that by the number of modules in a largish program, and
    you'll begin to see my weariness.

    --Kamilche
     
    Kamilche, Oct 6, 2003
    #8
  9. Re: Too Big [OT]

    Kamilche wrote:
    > CBFalconer <> wrote in message news:<>...
    >
    >

    (snip)

    > I really like a lot of aspects about Python, though how it handles
    > global variables suck. I wish it was in the same ballpark, speed-wise,
    > because I'd use it if it was, even with its quirks.


    Have a look at pyrex or psyco. Eventually keep your C code for the
    critical parts, wrap it as a Python module, and use Python for coding
    the logic.

    Bruno
     
    Bruno Desthuilliers, Oct 6, 2003
    #9
  10. Kamilche wrote:
    > CBFalconer <> wrote in message news:<>...
    >
    >
    >>I think that indicates a failure to partition correctly. C
    >>actually has very good capabilities to separate modules and limit
    >>interfaces, it just isn't especially good at enforcing such.

    >
    >
    > The memory assists you get working with VB (and C++) are awesome. I
    > grow weary of having to remember every function call for every data
    > type... in VB, I just type the variable name, then a dot, and all the
    > methods and variables pop up in a handy list, awaiting my selection.
    > 'Intellisense'.
    >


    Code completion is not a language feature, it's an IDE feature. And some
    good code editors offer code completion.

    Bruno
     
    Bruno Desthuilliers, Oct 6, 2003
    #10
  11. Kamilche

    Morris Dovey Guest

    Kamilche wrote:
    > CBFalconer <> wrote in message news:<>...
    >
    >> I think that indicates a failure to partition correctly. C
    >> actually has very good capabilities to separate modules and
    >> limit interfaces, it just isn't especially good at enforcing
    >> such.

    >
    > The memory assists you get working with VB (and C++) are
    > awesome. I grow weary of having to remember every function
    > call for every data type... in VB, I just type the variable
    > name, then a dot, and all the methods and variables pop up in
    > a handy list, awaiting my selection. 'Intellisense'.


    For C, I've found that the ctags approach (in combination with an
    editor that suports it) provides a similar capability. Typically,
    one puts the cursor on a function or variable name and uses
    either a keyboard shortcut or mouse click to see the code where
    the selected identifier is defined. Another keyboard shortcut
    disposes of the defining code and returns the editor to the
    original state.

    I've worked on several large, complicated application systems in
    MSWindows and *nix environments where this facility was
    absolutely essential.

    It's not really a language issue. It's much more an issue of
    using appropriate tools. You might find the webpage at

    http://ctags.sourceforge.net/tools.html

    to be of some interest. I'm not certain that the list of editors
    provided is comprehensive; but it looks like at least a good start.

    HTH
    --
    Morris Dovey
    West Des Moines, Iowa USA
    C links at http://www.iedu.com/c
     
    Morris Dovey, Oct 7, 2003
    #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. Martin
    Replies:
    0
    Views:
    494
    Martin
    Aug 4, 2004
  2. Shaguf
    Replies:
    0
    Views:
    560
    Shaguf
    Dec 24, 2008
  3. Shaguf
    Replies:
    0
    Views:
    506
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    277
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    257
    Shaguf
    Dec 24, 2008
Loading...

Share This Page