Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Too Big

Reply
Thread Tools

Too Big

 
 
Kamilche
Guest
Posts: n/a
 
      10-04-2003
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
 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      10-04-2003
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 ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
 
 
 
Micah Cowan
Guest
Posts: n/a
 
      10-04-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
Kamilche
Guest
Posts: n/a
 
      10-05-2003
CBFalconer <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

> 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
 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      10-05-2003
"Kamilche" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> CBFalconer <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
>
> > 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


 
Reply With Quote
 
Serve La
Guest
Posts: n/a
 
      10-05-2003

"Kamilche" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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.


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      10-05-2003
Kamilche wrote:
> CBFalconer <(E-Mail Removed)> 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 ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
Kamilche
Guest
Posts: n/a
 
      10-06-2003
"Serve La" <(E-Mail Removed)> wrote in message news:<blp15e$l47$(E-Mail Removed)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
 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-06-2003
Kamilche wrote:
> CBFalconer <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
>
>

(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

 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-06-2003
Kamilche wrote:
> CBFalconer <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
>
>
>>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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM
Photos for email.... How big, is too big? Big.David.NJ@gmail.com Computer Support 8 01-30-2008 02:36 PM



Advertisments