[geeks] C++ style

Joshua D Boyd jdboyd at cs.millersville.edu
Thu Sep 19 13:59:53 CDT 2002


On Thu, Sep 19, 2002 at 12:58:22PM -0500, Jonathan C. Patschke wrote:

> Dictionaries, hashtables, dynamic arrays, trees, and the like?

Exactly.  Refering to them as modern was being somewhat sarcastic.
 
> > STL has many of these classes, but for various reasons, it isn't
> > practical for me to rely on them.
> Practical meaning "you don't have access to ANSI C++ runtime libraries"?

Err, do they come by default with VC++ 6.0 and gcc?  I'm not aware of
them.  I'm aware of some minimal basics, like string and iostreams, and
I'm aware of the STL, but wasn't aware of anything else considered
standard.  Might I point out that my education at school did not cover
things like STL, or "how the bloody thing works", or even "here are the
titles of the relevent books that you can find in our library".

> VC++ and G++ both support a fairly common subset of STL.  Also, why are
> you limiting yourself to floppies?  So you want an SSH account on my
> server so that you can at least use sftp or http (I can write an
> upload/download app quickly) to store your files?

I have rather limited disk space on the local machines at school.  I
don't actually intend to carry my solution on a floppy, I was just using
it as a guideline for the amount of space that could be dedicated for
this purpose.  If the space wasn't so limited, I'd just install SGI's
STL. 

I'll have to look harder.  My initial tests to see if enough of STL was
there were failing on school machines, and I wasn't even looking for
that much.  Basically, I was looking for dictionaries, vectors, and
trees.  Maybe there are some setting I don't know about.  I'll keep
looking if STL is supposed to be there.

As to the SSH account, what I want is an SSH account to do work on.  I'm
working at slowly preparing a server to colo, but I when ever I have a
few hours to spare for it, I keep getting bogged down in making postfix,
openssh, and GCC work properly.  It's been like this for a few months
now.  What I need is a block of time large enough to keep at it until I
get out of the circle of broken software and bad memories.
 
> Sounds like my current dilemma with C.  Every program I start has me
> reimplementing a hash table and a doubly-linked list.  I'm loathe to
> make my own library, because I don't want Yet Another Dependency, and I
> don't want to commit to glib because it's (L)GPL and I don't want YAD.

What I've been doing so far is having a common implementation of linked
list (I don't use doubly linked much) and vector handy, and embedding it
straight into the program rather than have a library depency.
 
> ACK!!!!  C++ libraries should -never- use (void *) in public interfaces.
> You're thinking in terms of C, not C++.  You're giving up the -huge-
> benefits of C++'s type-checking.  The whole point of the STL is that if
> you create an array that's supposed to hold TextFields, you can only put
> TextFields into it, and when you get things from it, they're
> automagically typecast to TextFields by the compiler.

Well, the point somewhat is that I want several types on the stack, in
the dict, or whatever, and I want to be able to query them when they
come off to find what they are.  Of course, for that, a base object
would be far more appropriate.

> Templates aren't slow at all.  Most of the fancy footwork happens at
> compile-time.  At runtime, you just have dynamic binding to consider,
> which you'd have to deal with in C++ anyway.  Templates will save you a
> -lot- of work in this case.
 
> Of course you like the idea of using (void *)--it's reminiscent of a
> more sane time, when C ruled the earth and Stroustrup was still trying
> to pick up sorority sisters.

What I really wish is that I could use another language altogether, but
just try to get a scheme and all the needed bindings together in a
platform neutral maner takes a lot of space and time, neither of which
are abundant for me.  The same goes for GNU smalltalk.

> I'm not sure -I- see the value when the STL is nearly omnipresent in
> current versions of most compilers.  Hell, -MIPSpro- is getting their
> act together in the next maintenance release.

I'm not using the current versions of compilers.  At school I'm using
VC++6, and GCC 2.95.4 and there is nothing I can do to get these
updated.  We have VC++.NET, but are being told not to use it for
assignments.  I think I have GCC 3.1 at home, but that doesn't help me
when I need the code to work on all. 
 
> > for everything, but that isn't really realistic with my current skill
> > set (or rather lack there of).
> 
> Pick up a copy of Bjarne's book, read about class templates, and
> meditate on it for a while.  Things will become clearer, and you won't
> even remember how you wrote C++ code without them.  Templates are a Good
> Thing, even if the syntax for expressing them sucks rocks.

I still like base classes, but when in rome (or where ever it is that
Bjarne's from)...

I'll have to keep and eye open for that book.  I don't currently have
the money to just order it off Amazon.

-- 
Joshua D. Boyd



More information about the geeks mailing list