[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

}Re: [Sheflug] c++ & mem



> > > I don't follow. C and C++ code can be indistinguishable.
> > Key phrase, "can be" ;)
>
> So there is no "C code" and "C++ code" unless a specific feature is used.

Yes. C and C++ programs are written differently, and end up with different
binaries, link differently, etc. etc. Witness the trouble RH got into with
7.

> > Rubbish. Templates? Specialisation? STL? That's all about optimisation
of
> > generic code. As for performance penalties, yes, you expect to get a
penalty
> Optimization? Not exactly, stretching a point.

What *is* optimization then?! "Making things go faster / doing things more
efficiently". Doing things generically, taking into account of algorithmic
optimization *requires* specialization; you can't do it in C.

> Often you have to be explicit about it though (i.e. use flags).

Example?

> I don't
> why people seem to think C++ and Java are the only "OO languages". OO is a
> programmer feature, not a language feature. Using structs in C you can do
> a lot of what C does, and smaller and faster. Polymorphism is not really
> anything but artificial syntactic sweetener.

Nope. Trying to do C++ features in C is called "c-front", and it isn't great
(being polite). structs do not replicate objects, they don't even come
close. They can't encapsulate code (don't give me pointers to functions),
they don't data hide, they don't inherit, etc. etc. People write:
type func(types.. )
{

}

rather than
type func(types..) {

}

. because the { on it's own line signifies start of function. This is often
used to signify the fact that you can't nest functions. C has all sorts of
limits like this which just aren't there in C. OO certainly isn't a frame of
mind, it requires language support to be done properly. Perl isn't OO,
neither is C. It is *possible* to write OO type programs in either language,
but you end up replicating the OO functionality yourself. That isn't the
same as the language being OO.


> > > No it, tells you the C++ compiler is working.
> >
> > "g++ is gcc anyway, so if you've compiled things on your system before,
> > compiling that program tells you nothing".
>
> g++ is not gcc. (Dunno who's quote that is, but it isn't mine)

That quote's mine, and it was what your top reply was referring to
immediately. I.e., I said "Since gcc ~= g++, if you've compiled things on
your system, testing the compiler again on your system tells you nothing
new". You then said "No, it tells you your C++ compiler is working".

man gcc: first line of description:
    "the C and C++ compilers are integrated".
. they just use different linkers, a lot of the rest of it is identical.

> > iostreams doesn't work? In what way? How do iostreams "not work"?
libstdc++
> > is
> > a bit more than iostreams, anyhow...
>
> Ugly, ugly, ugly. I just can't stand them. :)

Hmmm. It's "ugly", therefore it doesn't work. :) Not sure I agree with that,
either. And how
    cout << "Value of myvar: " << myvar;
is "uglier" than
    fprintf(stdout, "Value of myvar: %d", myvar);
. I'll never know ;)

> printf() is more cryptic, but so much quicker and easier.

Quicker? With short arg lists, maybe so.. maybe not. But what if you need to
output a lot of items? Of different types? You need to make sure all the
types line up and everything. Ie.,
    fprintf(stdout, "Contents of struct are %d, %d, %d, %s, %x, %x\n",
            mystruct->num, mystruct->index,
            mystruct->content, &mystruct->item1, &mystruct->item2);
.. oh dear, we've broken it... I think I like better:
            myobject.printout();
            myobject::printout(void) {
                cout << "Contents of object are " << num << index << content
<<  &item1 << &item2;
            }

Cheers,

Alex.

---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.